Skip to content

Fix race condition in KeyProducerJavaZmqTest message delivery#149

Merged
bernardladenthin merged 1 commit intomainfrom
claude/fix-flaky-test-GAG43
Apr 2, 2026
Merged

Fix race condition in KeyProducerJavaZmqTest message delivery#149
bernardladenthin merged 1 commit intomainfrom
claude/fix-flaky-test-GAG43

Conversation

@bernardladenthin
Copy link
Copy Markdown
Owner

Summary

Fixed a race condition in the ZMQ socket test where the consumer could start reading before the message was fully delivered by the sender.

Key Changes

  • Moved senderReady.countDown() to after the message is sent and a delivery delay is applied
  • Added explicit delay after socket.send() to ensure the message is delivered before the consumer starts reading
  • Updated the comment to clarify that we're waiting for the message to be sent, not just the connection to be established

Implementation Details

The test was previously signaling readiness immediately after sending the message without waiting for delivery. This could cause the consumer thread to start reading before ZMQ had fully delivered the message through the socket. By adding a delay after socket.send() and moving the countdown after that delay, we ensure proper synchronization between the sender and consumer threads.

https://claude.ai/code/session_018nK6z7Ax5DwUTh2VhQqhbW

The senderReady latch was counting down BEFORE socket.send(), so
createSecrets() could start polling the queue before the ZMQ message
was even sent. On loaded Windows CI runners, this caused the 2-second
poll timeout to expire before the message arrived.

Fix: move senderReady.countDown() to AFTER send() plus an additional
establish delay, ensuring the message has been sent and had time to
travel through ZMQ before createSecrets() begins polling.

https://claude.ai/code/session_018nK6z7Ax5DwUTh2VhQqhbW
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 2, 2026

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.46%. Comparing base (71fd6a0) to head (87e7691).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #149      +/-   ##
============================================
- Coverage     74.50%   74.46%   -0.05%     
+ Complexity      562      561       -1     
============================================
  Files            84       84              
  Lines          2428     2428              
  Branches        208      208              
============================================
- Hits           1809     1808       -1     
  Misses          564      564              
- Partials         55       56       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bernardladenthin bernardladenthin merged commit d28a152 into main Apr 2, 2026
6 of 8 checks passed
@bernardladenthin bernardladenthin deleted the claude/fix-flaky-test-GAG43 branch April 2, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants