GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — [fix][meta] Fix leader elections settling on a lock deleted while they read or write it by merlimat · Pull Request #27321 · apache/pulsar Conversation
Contributor
Motivation
These elections pick the load manager leader and the extensible load manager's channel owner Which stores are exposed:
For example, on Oxia, broker B starts its election while broker A, the leader, shuts down in a rolling restart:
B now reports A as the leader, although the lock is gone. If B is the only other candidate, nobody leads until A The new tests force that order by holding the result of the read, or of the write, until the deletion was ModificationsThe election counts the deletions of the lock it's notified of, whatever its state: if (notification.getType() == NotificationType.Deleted) { lockDeletions++; } A cycle takes the count before it reads the lock and before it writes it. If the count changed by the time the if (lockDeletions != lockDeletionsBeforeRead) { // The lock may have been deleted after it was read: the leader it names may be gone log.debug().attr("path", path) .log("A deletion of the lock was notified while reading it. Reading it again."); return elect(); } if (internalState == InternalState.ElectionInProgress && lockDeletions != lockDeletionsBeforeWrite) { // The lock may have been deleted once written: read it again rather than lead without it log.debug().attr("path", path).attr("value", value) .log("A deletion of the lock was notified while taking it. Reading it again."); FutureUtil.completeAfter(result, elect()); } In the example, B reads the lock again, finds it empty and takes it, or follows whoever took it first. B publishes Each cycle compares against its own count, so an overlapping cycle (say, a session revalidation during a #26712 makes Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:If the box was checked, please highlight the changes
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…y read or write it LeaderElectionImpl.handlePathNotification() ignored the notifications unless the election had settled (LeaderIsPresent), while an election cycle reads the lock, and may write it, as ElectionInProgress. When the store notified the deletion of the lock before it delivered the result of a read or a write that came before the deletion, the election dropped the deletion and settled on what was gone: - A candidate that read the lock of a leader that then went away followed it. It kept reporting that leader, and nothing made it elect again: Created notifications are ignored, and only a Reconnected or SessionReestablished event revalidates. With no other candidate, nobody led. - An election that wrote the lock, which was then deleted, led without it. ZooKeeper isn't exposed: ZKMetadataStore completes the operations and dispatches the watch events on its single event thread, in order. Oxia is: OxiaMetadataStore completes them on the Oxia client's threads, and the notifications come on a separate stream dispatched on the event thread. The election now counts the deletions of the lock it's notified of. A cycle takes the count before it reads the lock and before it writes it, and reads the lock again instead of settling if the count changed.
codelipenghui
requested changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reviewed head The deletion counter addresses the reported missed-notification races, but the successful-write retry introduces a shutdown regression: closing during the new reread can leave the election's own live ephemeral lock behind and prevent takeover. Please address the ownership-cleanup issue noted inline. Validation: the existing
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. …ds the lock again A cycle that took the lock while a deletion of the lock was notified reads the lock again before it leads. The deletion may be of an older lock, so the lock may still be the election's, but asyncClose() released the lock only when the election led: closed during that read, the election left its lock behind, and the other participants followed the closed election until its session ended. The election now holds the lock provisionally from that write until a cycle settles the election, and asyncClose() releases it in that state too, with the same checks as when it leads: it deletes the lock if the election's session created it, conditionally on its version.
codelipenghui
approved these changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code Review approval for commit 8985e6e. Summary:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
ascentstream-bot
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
…y read or write it (apache#27321) (cherry picked from commit c153f4b)
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
…y read or write it (apache#27321) (cherry picked from commit c153f4b)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabelsProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |