Skip to content

Commit

Permalink
Fix tenant removal on dequeue for legacy TreeQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
chencs committed Jul 1, 2024
1 parent c56cdfc commit a121631
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/scheduler/queue/tenant_querier_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,22 @@ func (tqa *tenantQuerierAssignments) removeTenant(tenantID TenantID) {
return
}
delete(tqa.tenantsByID, tenantID)

// TODO (casie): When cleaning up old TreeQueue, everything below this point can be removed, since
// tenantIDOrder is updated during tree operations in MultiQueuingAlgorithmTreeQueue.
// Everything below this point should be a no-op on the MultiQueuingAlgorithmTreeQueue
if len(tqa.tenantIDOrder) > tenant.orderIndex && tqa.tenantIDOrder[tenant.orderIndex] == tenantID {
tqa.tenantIDOrder[tenant.orderIndex] = emptyTenantID

// Shrink tenant list if possible by removing empty tenant IDs.
// We remove only from the end; removing from the middle would re-index all tenant IDs
// and skip tenants when starting iteration from a querier-provided lastTenantIndex.
// Empty tenant IDs stuck in the middle of the slice are handled
// by replacing them when a new tenant ID arrives in the queue.
for i := len(tqa.tenantIDOrder) - 1; i >= 0 && tqa.tenantIDOrder[i] == emptyTenantID; i-- {
tqa.tenantIDOrder = tqa.tenantIDOrder[:i]
}
}
}

func (tqa *tenantQuerierAssignments) removeQuerierConnection(querierID QuerierID, now time.Time) (resharded bool) {
Expand Down

0 comments on commit a121631

Please sign in to comment.