You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "DanielLeens (via GitHub)" <gi...@apache.org> on 2026/09/22 14:07:15 UTC

[PR] [Test][Connector-V2] Release PayPalClientTest's arrival latch before the response body write [seatunnel]

DanielLeens opened a new pull request, #12444:
URL: https://github.com/apache/seatunnel/pull/12444

   ### Purpose of this pull request
   
   `PayPalClientTest#closeWakesRetryWait` keeps failing on the `unit-test (11, windows-latest)` / `(8, windows-latest)` jobs of PRs that do not touch the PayPal connector, most recently on #11814 (2026-09-22) and #11215 (2026-09-18), always at the same assertion:
   
   ```
   PayPalClientTest.closeWakesRetryWait:416 expected: <true> but was: <false>
   ```
   
   That line is the first `arrived.await(NETWORK_WAIT_SECONDS, ...)`, i.e. the test gives up waiting for the request to reach the embedded server. #12370 widened that wait from 3 s to 15 s and the failure came back at the same line, and the open #12381 proposes widening it again to 60 s. The wait budget is not the problem: the latch is never counted down.
   
   ### Root cause
   
   `serve()` in the test counts `arrived` down only after it has written the reply body:
   
   ```java
   exchange.getResponseBody().write(reply.body);
   arrived.countDown();
   ```
   
   `closeWakesRetryWait` replies `503 {}`. `PayPalClient#execute` does not read the body of a transient status: it returns as soon as it has the status line, and its `finally` block calls `request.abort()`, which closes the socket. On Linux the server's 2-byte write still lands in the send buffer, so the countDown runs. On Windows a write into a socket the peer has already closed fails with an `IOException`; `serve()` swallows it in `catch (IOException ignored)` and never reaches the countDown, so the test waits out the whole budget for a request that arrived long ago. Whether the client's abort or the server's write wins is scheduling-dependent, which is why the failure is intermittent and only seen on the Windows legs.
   
   ### Fix (test-only)
   
   - Count `arrived` down before the body write for plain replies, so the client aborting the connection cannot skip it.
   - Also count it down in the `finally` block, so no response-side failure can leave a test waiting on the latch. The latch is a `CountDownLatch(1)`, so the second call is a no-op on the normal path.
   - The `bodyless` and blocking branches keep their existing order: `closeAbortsActiveBody` relies on the first body byte having been flushed when the latch is released.
   
   No assertion, expected value or wait budget changes. Compared with #12381 this removes the cause instead of widening the wait, which cannot help when the countDown is skipped.
   
   ### Files
   
   - `seatunnel-connectors-v2/connector-http/connector-http-paypal/src/test/java/org/apache/seatunnel/connectors/seatunnel/paypal/source/PayPalClientTest.java`
   
   ### How was this patch tested?
   
   Test-helper-only change, verified by this PR's GitHub CI (`unit-test` on all four matrix legs) per this initiative's no-local-build policy. Local checks were limited to `./mvnw spotless:apply -pl seatunnel-connectors-v2/connector-http/connector-http-paypal`.
   
   ### Check list
   
   * [x] No new Jar binary package is added.
   * [x] Documentation is not required.
   * [x] `incompatible-changes.md` is not required.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Test][Connector-V2] Release PayPalClientTest's arrival latch before the response body write [seatunnel]

Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on PR #12444:
URL: https://github.com/apache/seatunnel/pull/12444#issuecomment-5853336353

   Following up on the red badge here, since it is the last visible objection to merging this and it is not what it looks like.
   
   The two failing legs are both `ubuntu`, both fail inside `seatunnel-engine-server`, and they fail on two different tests, neither of which this PR can reach. Its diff is one file: `PayPalClientTest.java`.
   
   ```
   unit-test (11, ubuntu-latest)
     TaskExecutionServiceTest.testStaleTaskDoneCleansOnlyOwnedGenerationResources:639
     -> #12394 "[Test][Zeta] Isolate task execution fixture identities", open
   
   unit-test (8, ubuntu-latest)
     EngineStateStoreLogicalMetricExportsTest
       .collectShouldExportLogicalMetricsForSpecialStateStores:109
       expected: <2.0> but was: <0.0>
     -> #12453 "[Test][Zeta] Await asynchronous logical checkpoint metrics", open
   ```
   
   The part that matters for this PR is what happened on the same run:
   
   ```
   unit-test (8, windows-latest)   success
   unit-test (11, windows-latest)  success
   ```
   
   Both Windows legs passed. That is the platform where `closeWakesRetryWait` fails everywhere else, including on `dev` and on three of my own PRs. And `PayPalClientTest` itself ran green on all four legs, 23 of 23 on each of the two ubuntu jobs as well.
   
   So the evidence for this change is: the mechanism is understood and conceded, @goutamadwant measured 0 of 50 normally and 0 of 20 with the body write forced to throw, and its own CI is green on the platform in question while the only red is two unrelated engine tests that already have their own PRs open.
   
   I have no stake in how the engine flakes are handled, but they should not be what holds this one up.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Test][Connector-V2] Release PayPalClientTest's arrival latch before the response body write [seatunnel]

Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on PR #12444:
URL: https://github.com/apache/seatunnel/pull/12444#issuecomment-5852894012

   This is the fix. I read it against the source rather than taking the thread's conclusion, and it holds up.
   
   `PayPalClient.execute()` returns at the transient-status branch without ever touching the entity, and its `finally` calls `request.abort()` unconditionally straight after. On the server side `serve()` counted `arrived` down only after `exchange.getResponseBody().write(reply.body)` returned, with the write inside a `catch (IOException ignored)`. `closeWakesRetryWait` replies with a plain 503, so that is the exact branch it takes, and if the abort wins the race the write throws, the exception is swallowed, and the latch is never released. Moving the `countDown()` above the write makes the latch mean what its name says, that the request reached the server, which is true the moment `serve()` is entered and does not depend on the response being writable.
   
   The `finally` countdown is the right belt and braces rather than redundancy: it also covers the `InterruptedException` branch and any failure in the streaming path above. `arrived` is a `CountDownLatch(1)`, so a second `countDown()` is a no-op and there is no double-release concern.
   
   Two things worth saying since I have been on the other side of this thread.
   
   I supported #12381 on its own thread on the strength of a 4-of-6 failure rate I measured across my own PRs. That data was real but my conclusion from it was wrong: I read a wait that always consumed its full budget as evidence the budget was too small, when it was evidence the latch never fired. @SEZ9 got to the mechanism and @goutamadwant's 50-run numbers settled it, including 20 of 20 failures for #12381 with the body write forced to throw against 0 of 20 here.
   
   Second, a disclosure: this red leg is currently the only thing blocking my #12438, so I have an interest in it landing. That is also why I have corrected the pointer on that PR from #12381 to this one.
   
   This has been open since 09-22 with no review from anyone but its author. The diff is eight lines in one test file, it fixes the mechanism rather than the symptom, and it is the variant with measured zero failures. It deserves a committer.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Test][Connector-V2] Release PayPalClientTest's arrival latch before the response body write [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo merged PR #12444:
URL: https://github.com/apache/seatunnel/pull/12444


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Test][Connector-V2] Release PayPalClientTest's arrival latch before the response body write [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #12444:
URL: https://github.com/apache/seatunnel/pull/12444#issuecomment-5846306493

   Thanks for going to the trouble of stress-testing this locally — that kind of independent verification is exactly what a flake fix like this needs, since the failure was always intermittent and easy to "fix" by accident.
   
   Your numbers line up well with the theory: the base failures burning the *entire* wait budget (15s, then the full 60s under #12381) is consistent with the latch never being counted down at all, not with the request simply arriving late. And forcing the body-write `IOException` to reproduce it 20/20 on base while this PR's ordering stays at 0/20 is a good way to isolate the actual mechanism rather than just re-running the flaky path and hoping. That's more rigorous than what CI alone gives us here.
   
   On #12454: agreed that landing this PR and dropping the overlapping `PayPalClientTest` change from #12454 is the cleaner path. That PR bundles the same test file into a much larger, unrelated PostgreSQL CDC change, so keeping the PayPal fix scoped to this PR (which only touches that one file) avoids the two drifting apart or conflicting later. I'd support #12454's author trimming that hunk once this merges — happy to leave a note there pointing back here if that's useful.
   
   This PR itself hasn't changed since my last pass, and I still see it as ready to merge — the current `Build` failure is the same unrelated `unit-test (ubuntu-latest)` engine-server flake I traced down last time, not anything in `connector-http-paypal`. Thanks again for the extra confidence here.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Test][Connector-V2] Release PayPalClientTest's arrival latch before the response body write [seatunnel]

Posted by "goutamadwant (via GitHub)" <gi...@apache.org>.
goutamadwant commented on PR #12444:
URL: https://github.com/apache/seatunnel/pull/12444#issuecomment-5841261416

   I ran `PayPalClientTest#closeWakesRetryWait` in a loop locally (macOS, a loaded 10-core host, one fresh JVM per run). Base was `dev` at `deb16a3c3`. Each head was the PR's diff applied to that commit.
   
   **Unmodified test:**
   
   | | JDK 8 | JDK 11 (`-XX:ActiveProcessorCount=2`) |
   |---|---|---|
   | base | 0 / 50 | 5 / 50 failed, all at `PayPalClientTest.java:416` (`arrived.await`, same line as the Windows CI failures) |
   | this PR | 0 / 50 | 0 / 50 |
   | #12381 (arrival wait 60 s) | 0 / 50 | 1 / 50 failed, after the full 60 s wait |
   | #12454 (bodyless 503) | 0 / 50 | 0 / 50 |
   
   The base failures take 15 s, the whole wait. The #12381 failure takes the whole 60 s. So the latch is never counted down; the request is not just slow to arrive.
   
   **Forcing the failure:** I added a local-only switch that makes the server's body write throw `IOException`. That is the case this PR describes for Windows.
   
   - base: 20 / 20 failed at :416
   - #12381: 20 / 20 failed at the 60 s wait
   - this PR: 0 / 20 failed
   - #12454: 0 / 20 failed (its bodyless reply never writes a body)
   
   Counting down before the write, plus the extra `countDown()` in `finally`, covers the case where headers or body cannot be written. The assertions are unchanged. This looks like the right fix to me.
   
   #12454 changes the same test differently, by making the 503 bodyless. Both work in my runs. It might be simpler to land this one and drop the PayPal part from #12454, so the two don't conflict.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org