Repository navigation
SOLR-18623: Fix race-condition in ConnectionManager - #5301
HoustonPutman wants to merge 2 commits into
Conversation
…ionManager SyncConnected and Disconnected events are processed on an unbounded pool (since SOLR-17405), so they can be applied out of the order ZooKeeper delivered them. A Disconnected processed after the SyncConnected that followed it left ConnectionManager believing it was disconnected while ZooKeeper was connected, until the next reconnect. Number each event on ZooKeeper's event thread and ignore state changes from an event older than one already applied.
dsmiley
left a comment
There was a problem hiding this comment.
Well done! I especially like the test approach with the slow logging appender.
|
🤖 AI text below 🤖 (reviewed by Nick Shanin) I found another ordering case during session replacement: if the replacement's The follow-up on your exact head lets the connection wait detect a terminal replacement and retry, while retaining your sequence guard. It adds five ordinary deterministic tests. The nightly stress test waits for disconnect processing and uses Verified on Linux at
The branch preserves your commit ancestry. To take the tested changes: git switch SOLR-18623-connection-manager-event-ordering
git fetch https://github.com/nick-boss-tech/solr.git solr-18623-reconnect-liveness
git merge --ff-only dfde9bde0a348ad44e6f6ceec197d478ef11bfd0 |
psalagnac
left a comment
There was a problem hiding this comment.
Looks good, thanks for the fix.
I wonder if the added warn messages are actually warnings. I don't think they will be logged after something unexpected or partially broken happened.
Would it make sense to have info logs instead?
I agree they make more sense as |
|
@nick-boss-tech I added your changes to |
FWIW I am able to recreate this with |
Setup (same in both cases)In both cases the pool happens to finish B-Disconnected before B-Connected. Before Houston's change: no sequence checkApplying B-Connected late is technically wrong, since B isn't connected at t3. But it flips the flag, the waiter After Houston's change: stale events are ignoredIgnoring B-Connected is correct, since B really is disconnected. But that late |
|
Tldr; If you have some session A's expiry routine running and the session B it kicks off gets a This thread would for a brief moment think it was connected but quickly error out. But at least it wasn't stuck. Now I don't know what I think yet of @nick-boss-tech proposed fix to poll the connected state but I do think this is an issue. |
https://issues.apache.org/jira/browse/SOLR-18623
SyncConnected and Disconnected events are processed on an unbounded pool (since SOLR-17405), so they can be applied out of the order ZooKeeper delivered them. A Disconnected processed after the SyncConnected that followed it left ConnectionManager believing it was disconnected while ZooKeeper was connected, until the next reconnect.
Number each event on ZooKeeper's event thread and ignore state changes from an event older than one already applied.
Since this is the pre-curator ZK logic, this will only target
branch_9xandbranch_9_11