Repository navigation
Wait for expansion services to listen before running XVR tests - #41035
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR fixes startup race conditions in cross-language ValidatesRunner tests by closing the leaked flock file descriptor (200) in child processes, polling for both expansion services to bind their ports in run_expansion_services.sh, and updating BaseExternalTest.waitForReady() to use plaintext channels, reset connection backoff, and wait up to 60 seconds.
🔍 General Feedback
- The root cause analysis and changes in
BaseExternalTest.javaandrun_expansion_services.shdirectly address the startup flakiness. - In
sdks/python/scripts/run_expansion_services.sh, the return status ofwait_for_portis currently not checked and gets overwritten by the trailingflock -u 200command, which prevents the script from failing fast with a non-zero exit code when an expansion service crashes or times out.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR resolves startup race conditions in cross-language (XVR) tests by closing the inherited flock file descriptor in backgrounded expansion service processes, polling until the expansion service ports are listening, and fixing BaseExternalTest.waitForReady() to use plaintext gRPC with backoff resets and a 60s timeout.
🔍 General Feedback
- The gRPC readiness polling and resource cleanup updates in
BaseExternalTest.javaare clean and well-structured. - In
sdks/python/scripts/run_expansion_services.sh,wait_for_portfailures are currently swallowed becauseset -eis not enabled and the trailingflock -u 200resets the script's exit status to0.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR resolves a race condition in Cross-Language ValidatesRunner (XVR) tests by ensuring both Java and Python expansion services are actively listening on their gRPC ports before test execution proceeds, and by fixing file descriptor inheritance for flock. The updates to run_expansion_services.sh (including failing fast via || exit 1 on startup/readiness failure) and BaseExternalTest.waitForReady() (adding .usePlaintext(), backoff resets, and proper channel cleanup) are clean, well-targeted, and ready to merge.
🔍 General Feedback
- Closing FD
200(200>&-) on backgrounded Java and Python expansion service processes properly prevents child processes from holding theflocklock open across the lifetime of the daemons. - Adding
|| exit 1to thewait_for_portchecks ensures startup failures are not masked by the trailingflock -u 200command. - Configuring
.usePlaintext(), callingresetConnectBackoff()onTRANSIENT_FAILURE, and ensuringchannel.shutdownNow()runs in afinallyblock while restoring the thread interrupt flag inBaseExternalTest.waitForReady()makes the Java client readiness check much more resilient.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41035 +/- ##
============================================
+ Coverage 58.29% 58.32% +0.03%
Complexity 2276 2276
============================================
Files 1136 1137 +1
Lines 169395 169512 +117
Branches 1482 1482
============================================
+ Hits 98746 98867 +121
+ Misses 68100 68096 -4
Partials 2549 2549
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Assigning reviewers: R: @jrmccluskey for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Summary
Fixes
PostCommit XVR JavaUsingPython Dataflow(beam_PostCommit_XVR_JavaUsingPython_Dataflow (3.14)) failure observed onmasterin run 42212921122.Root Cause
sdks/python/scripts/run_expansion_services.sh,startlaunched the Java and Python expansion services in the background and returned immediately afterkill -0, before the Python expansion service finished importingapache_beamand binding to its gRPC port (~38 seconds on Python 3.14 when 8 test workers start concurrently). Additionally, child processes inherited file descriptor200(flock), holding the lock open until the services stopped.BaseExternalTest.waitForReady(),ManagedChannelBuilder.forTarget(expansionAddr).build()omitted.usePlaintext(), did not callchannel.resetConnectBackoff()onTRANSIENT_FAILURE, and only waited 15 seconds (30 * 500ms). As a result, the first 5 of 20ValidateRunnerXlangTesttests failed immediately withStatusRuntimeException: UNAVAILABLE: io exception / Connection refused: localhost/127.0.0.1:41321, while the remaining 15 tests passed once the service finished binding.Changes
200(200>&-) when launching backgrounded expansion services inrun_expansion_services.shand poll until both Java and Python expansion services are listening on their ports (up to 60s, failing fast with|| exit 1if startup fails)..usePlaintext(),resetConnectBackoff(), and a 60s readiness timeout (120 * 500ms) inBaseExternalTest.waitForReady().Verification
PostCommit XVR JavaUsingPython Dataflowworkflow on branchfix/xvr-expansion-service-readiness: https://github.com/apache/beam/actions/runs/42258219149 (previous run https://github.com/apache/beam/actions/runs/42235263937 succeeded)