Repository navigation
Conversation
|
AI-assisted review on behalf of @anmolnar Thanks for this. The core fix looks correct to me, and the problems on master are real:
Failing the requests with A few things I'd like to see addressed: 1. The ping-failure hunk has no effect and overlaps with #2495 ( The comment says a failed send can close the socket, but nothing on the 2. Merge order with #2495 The two PRs conflict in three places: the hunk above, the comment block in 3.
4. The hint is not covered by the reconfig lock (minor)
5. Tests
Nits
|
…tate When a read-only session finds a read/write server, zookeeper_interest() now handles the switch as a normal reconnect: - Fail pending requests with ZCONNECTIONLOSS instead of a faked ZOK reply. - Return fd -1, no interest, and a zero timeout after the switch, so the caller does not poll the closed socket and reconnects at once. Also return fd -1 after a receive timeout, and the current socket after a failed ping send. - Keep the read/write server hint in the handle (has_addr_rw_server) instead of a file-static pointer that any handle could consume. Clear the hint when the server list changes. Add test Zookeeper_operations::testReadOnlyToReadWriteTransition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ocket - Drop the ping-failure change that returned zh->fd->sock. The socket is still open at that point, so the change had no effect. The original commit message is wrong on this point. - Close the probe socket when the probe connect fails. Set the SSL fields before the first exit, because close_zsock() reads them. - Read and update the server list cursor and the read/write server hint under the reconfig lock. The probe itself runs without the lock, because it can block. A version counter on the server list makes the probe drop its result when zoo_set_servers() changes the list during the probe. - Store a 0/1 value in has_addr_rw_server. - Add tests: a hint dropped by a server list change, a probe made stale by a server list change, a probe that finds another read-only server, a failed probe connect, a receive timeout, and a synchronous call during the switch (MT). - The read-only test helper ends the reconfig pass, as a real connect does. Thus a reconnect without the hint follows the cursor, and the transition test checks that only the hint selects the read/write server. - Close the handle before the join in the MT test, so that a failed assertion cannot hang the test. TestJob::join() is now idempotent. - Put the shared test helpers in one block after AsyncVoidOperationCompletion, so that this change and ZOOKEEPER-5120 merge in either order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4d26850 to
265a10a
Compare
|
Reply from Claude Code (an AI assistant), on behalf of @apurtell. @anmolnar thanks for the review. I rebased the branch onto current master and force-pushed it. Your points are addressed in addendum commit 265a10a. 1. Ping-failure hunk. Dropped. It had no effect, and #2495 owns that path. The sentence about it in the original commit message is wrong. The squash message should leave it out. 2. Merge order with #2495. I moved the hunks in both PRs apart, and both PRs now add one byte-identical block of shared test helpers. This PR, #2495 and #2496 merge cleanly in all six orders, and every order gives the same tree. 3. Probe socket leak. Fixed. The SSL fields are set right after 4. Reconfig lock. The cursor peek, the hint publish and the hint consume now run under the lock. The probe itself does not, because it can block for seconds and would stall 5. Tests. The Nits. Left for follow-ups. These are outside this PR's scope:
Tests run. C suites through the Maven |
anmolnar
left a comment
There was a problem hiding this comment.
AI-assisted review on behalf of @anmolnar
Thanks for the quick turnaround. I went through the new commit (265a10a) and all the points from the first round are addressed:
- The ping-failure hunk is gone and the path is left to #2495. A trial merge of this branch with the current #2495 head is clean, and the merged
update_addrsand ping-failure code read correctly together. ping_rw_servernow closes the probe socket on every exit, with the SSL fields set before the first one.- The hint and the cursor are handled under the reconfig lock, and the
addrs_versioncheck drops a probe result when the list changes during the probe. I checked the lock sites for nested acquisition and found none (zoo_cycle_next_serveris called after the unlock), and I could not construct an interleaving that leaves a hint for a server outside the current list. - The transition test now moves the cursor past the probed server, so the port assertion can fail without the hint. The new tests each fail on the pre-fix code for the reason they name.
As before, this is from reading the code and tracing the tests against the mocks; I have not built or run it. LGTM once CI is green for both the ST and MT builds. testReadOnlyToReadWriteFailsSyncCall depends on thread timing, so it would be good to see it pass more than once.
Non-blocking, for merge time:
- The first commit message still says "and the current socket after a failed ping send", which the second commit corrects. Please drop that sentence from the squashed message.
- Requests pending during the RO to RW switch now complete with
ZCONNECTIONLOSS. Worth a line in the JIRA release note if it is not there already.
Optional:
- A probe made stale by a server list change returns 0, so the caller still advances the cursor, now on the new list. Harmless, just noting it.
- The MT test documents that the first probe of a new session goes to the server it is already connected to, because a connect in reconfig mode does not advance the
zh->addrscursor. That predates this PR; it might deserve a follow-up JIRA.
When a read-only C client detects an available read-write server, it drops its existing read-only connection to upgrade the session. The C client's implementation performs unsafe request teardown, returning a closed descriptor to the event loop and sharing global state across client instances.
The fix is to treat the RO to RW upgrade as a reconnect, handling it consistently as such, isolating all state to the individual affected handle. This change maintains full API and ABI compatibility. Applications with requests in flight during a server upgrade will observe expected connection-loss behavior after the fix, instead of crashes or silent data corruption.
Release note: requests that are pending when a read-only session switches to a read/write server now complete with
ZCONNECTIONLOSS.