Skip to content

Commit

Permalink
Fix slow ingestion of ReprioritiseJob events (#3667)
Browse files Browse the repository at this point in the history
Call unique once per UpdateJobPriorities op, rather than once for every jobId added to the UpdateJobPriorities op

Signed-off-by: JamesMurkin <[email protected]>
  • Loading branch information
JamesMurkin authored Jun 11, 2024
1 parent e8d413e commit 8b38477
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions internal/scheduleringester/dbops.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/google/uuid"
"golang.org/x/exp/maps"

"github.com/armadaproject/armada/internal/common/slices"
schedulerdb "github.com/armadaproject/armada/internal/scheduler/database"
)

Expand Down Expand Up @@ -239,7 +238,7 @@ func (a *UpdateJobPriorities) Merge(b DbOperation) bool {
switch op := b.(type) {
case *UpdateJobPriorities:
if a.key == op.key {
a.jobIds = slices.Unique(append(a.jobIds, op.jobIds...))
a.jobIds = append(a.jobIds, op.jobIds...)
return true
}
}
Expand Down
3 changes: 2 additions & 1 deletion internal/scheduleringester/schedulerdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/armadaproject/armada/internal/common/database"
"github.com/armadaproject/armada/internal/common/ingest"
"github.com/armadaproject/armada/internal/common/ingest/metrics"
"github.com/armadaproject/armada/internal/common/slices"
schedulerdb "github.com/armadaproject/armada/internal/scheduler/database"
)

Expand Down Expand Up @@ -230,7 +231,7 @@ func (s *SchedulerDb) WriteDbOp(ctx *armadacontext.Context, tx pgx.Tx, op DbOper
Queue: o.key.queue,
JobSet: o.key.jobSet,
Priority: o.key.Priority,
JobIds: o.jobIds,
JobIds: slices.Unique(o.jobIds),
})
if err != nil {
return errors.WithStack(err)
Expand Down

0 comments on commit 8b38477

Please sign in to comment.