Skip to content

fix: flaky IngestionSmokeTest.test_runIndexTask_andKillData - #20962

Open
maheshrijal wants to merge 2 commits into
apache:masterfrom
maheshrijal:fix-flaky-ingestion-smoke-kill-data
Open

maheshrijal wants to merge 2 commits into
apache:masterfrom
maheshrijal:fix-flaky-ingestion-smoke-kill-data

Conversation

@maheshrijal

@maheshrijal maheshrijal commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #20909.

Description

KubernetesClusterDockerTest runs two Brokers, and both emit segment/metadataCache/sync/time as druid/broker. waitForNextBrokerCacheSync() returned on the first sync event from either Broker, but the sys.segments query can go to the other Broker, which may not have polled the Coordinator yet.

waitForNextBrokerCacheSync() now finds every Broker through node discovery and waits for a sync event from each one, matched by host. It skips syncs that started before the wait, because the HTTP emitter can deliver their events late.

The issue says the in-JVM Broker uses the default 60 s poll period. EmbeddedBroker sets it to 100 ms.

Tested locally: IngestionSmokeTest (6 of 6) and checkstyle pass. I did not run KubernetesClusterDockerTest.

Release note

None. Test-only change.


Key changed/added classes in this PR
  • IngestionSmokeTest

This PR has:

  • been self-reviewed.

Written with help from Opus 5.5 and Sol 6.2 Changes reviewed by me.

KubernetesClusterDockerTest runs two Brokers. The test waited for one
Broker metadata sync event and then checked sys.segments once. The query
can go to the other Broker, which may still list the unused segments.
Poll sys.segments until it is empty instead.

Fixes apache#20909.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🟢 Approval recommended

No actionable issues found in this review. The new polling checks the actual sys.segments result with the existing 60-second retry helper, addressing the two-Broker cache-sync/query race. The removed helper has no remaining callers.

Reviewed 1 of 1 changed files.

Validation: git diff --check passed; no build or tests were run.


This is an automated review by Codex GPT-5.6-Luna(max)

@FrankChen021 FrankChen021 added the Approval Recommended Used when AI completes a review and reports no findings label Nov 24, 2026
@kfaraz

kfaraz commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@maheshrijal , thanks for the fix.

Wouldn't it be more appropriate to wait on the sync of both the Brokers and then proceed with the query?
I generally advise using LatchableEmitter and waiting on metrics instead of doing waitForResult since the former does not involve any sleep and loop.
There are some cases where waitForResult is kind of the last resort right now, but in the future, I would like to get rid of it.

@maheshrijal

Copy link
Copy Markdown
Contributor Author

@maheshrijal , thanks for the fix.

Wouldn't it be more appropriate to wait on the sync of both the Brokers and then proceed with the query? I generally advise using LatchableEmitter and waiting on metrics instead of doing waitForResult since the former does not involve any sleep and loop. There are some cases where waitForResult is kind of the last resort right now, but in the future, I would like to get rid of it.

I went with this approach because I was referring to the waitForResult javadoc which allows this when there is no metric to wait for. A single sync event doesn't tell us which Broker will answer the query so I treated this as the case. Waiting for the next sync from each Broker matched by host would avoid the retry loop and fixes the same race. I'll update the PR to do that.

Replace the sys.segments polling with a wait for the next
segment/metadataCache/sync/time event from each Broker found through
node discovery, matched by host, as suggested in review. Skip syncs
that started before the wait, since the HTTP emitter can deliver them
late.
@maheshrijal

Copy link
Copy Markdown
Contributor Author

@kfaraz can you re review please. waitForNextBrokerCacheSync() now waits for the next sync from each Broker(matched by host) It also skips syncs that started before the wait, since the HTTP emitter batches events and can deliver an older sync late

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🟢 Approval recommended

No actionable issues found. The updated helper waits for a post-wait metadata sync from every discovered Broker and matches events by advertised host and port before checking sys.segments.

Reviewed 1 of 1 changed files.

Validation: git diff --check 088172524d52c8729efd331f1bcda252b271ac75..3010107e0ab252c3b6e2375ee06cc88da06bd64a passed; no build or tests were run.


This is an automated review by Codex GPT-5.6-Luna(max)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approval Recommended Used when AI completes a review and reports no findings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: IngestionSmokeTest.test_runIndexTask_andKillData (KubernetesClusterDockerTest)

3 participants