Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race in TestMultiDimensionalQueueAlgorithmSlowConsumerEffects #9360

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -375,39 +375,45 @@ func TestMultiDimensionalQueueAlgorithmSlowConsumerEffects(t *testing.T) {
for _, weightedQueueDimensionTestCase := range weightedQueueDimensionTestCases {
numTenants := len(weightedQueueDimensionTestCase.tenantQueueDimensionsWeights)

tqa := newTenantQuerierAssignments()
tqaNonFlipped := newTenantQuerierAssignments()
tqaFlipped := newTenantQuerierAssignments()
tqaQuerierWorkerPrioritization := newTenantQuerierAssignments()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could just initialize them right in the tree constructor the same way we do the round robin states since we never reference them again, but nbd

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do reference them again in the treeScenarios initialization


nonFlippedRoundRobinTree, err := NewTree(tqa, &roundRobinState{}, &roundRobinState{})
nonFlippedRoundRobinTree, err := NewTree(tqaNonFlipped, &roundRobinState{}, &roundRobinState{})
require.NoError(t, err)

flippedRoundRobinTree, err := NewTree(&roundRobinState{}, tqa, &roundRobinState{})
flippedRoundRobinTree, err := NewTree(&roundRobinState{}, tqaFlipped, &roundRobinState{})
require.NoError(t, err)

querierWorkerPrioritizationTree, err := NewTree(NewQuerierWorkerQueuePriorityAlgo(), tqa, &roundRobinState{})
querierWorkerPrioritizationTree, err := NewTree(NewQuerierWorkerQueuePriorityAlgo(), tqaQuerierWorkerPrioritization, &roundRobinState{})
require.NoError(t, err)

trees := []struct {
treeScenarios := []struct {
name string
tree Tree
tqa *tenantQuerierAssignments
}{
// keeping these names the same length keeps logged results aligned
{
"tenant-querier -> query component round-robin tree",
nonFlippedRoundRobinTree,
tqaNonFlipped,
},
{
"query component round-robin -> tenant-querier tree",
flippedRoundRobinTree,
tqaFlipped,
},
{
"worker-queue prioritization -> tenant-querier tree",
querierWorkerPrioritizationTree,
tqaQuerierWorkerPrioritization,
},
}
for _, tree := range trees {
for _, scenario := range treeScenarios {
testCaseName := fmt.Sprintf(
"tree: %s, %s",
tree.name,
scenario.name,
weightedQueueDimensionTestCase.name,
)
testCaseObservations := &testScenarioQueueDurationObservations{
Expand All @@ -417,7 +423,7 @@ func TestMultiDimensionalQueueAlgorithmSlowConsumerEffects(t *testing.T) {
}

// only the non-flipped tree uses the old tenant -> query component hierarchy
prioritizeQueryComponents := tree.tree != nonFlippedRoundRobinTree
prioritizeQueryComponents := scenario.tree != nonFlippedRoundRobinTree

t.Run(testCaseName, func(t *testing.T) {
queue, err := NewRequestQueue(
Expand All @@ -434,9 +440,9 @@ func TestMultiDimensionalQueueAlgorithmSlowConsumerEffects(t *testing.T) {

// NewRequestQueue constructor does not allow passing in a tree or tenantQuerierAssignments
// so we have to override here to use the same structures as the test case
queue.queueBroker.tenantQuerierAssignments = tqa
queue.queueBroker.tenantQuerierAssignments = scenario.tqa
queue.queueBroker.prioritizeQueryComponents = prioritizeQueryComponents
queue.queueBroker.tree = tree.tree
queue.queueBroker.tree = scenario.tree

ctx := context.Background()
require.NoError(t, queue.starting(ctx))
Expand Down Expand Up @@ -482,7 +488,7 @@ func TestMultiDimensionalQueueAlgorithmSlowConsumerEffects(t *testing.T) {
testCaseReports[testCaseName] = report

// ensure everything was dequeued
path, val := tree.tree.Dequeue(&DequeueArgs{querierID: tqa.currentQuerier})
path, val := scenario.tree.Dequeue(&DequeueArgs{querierID: scenario.tqa.currentQuerier})
assert.Nil(t, val)
assert.Equal(t, path, QueuePath{})
})
Expand Down
Loading