Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry "Exception: not primary" when writing #43

Merged
merged 12 commits into from
Sep 10, 2023
Merged

Retry "Exception: not primary" when writing #43

merged 12 commits into from
Sep 10, 2023

Conversation

thekid
Copy link
Member

@thekid thekid commented Sep 10, 2023

The clientside cluster view may become outdated, causing us to erroneously write to non-primary nodes. This is how this can occur (see #42 (comment)):

Event Client view Server side situation
Client: Before (n/a) {Primary: A, Secondary: [B, C]}
Client: Connect {Primary: A, Secondary: [B, C]} {Primary: A, Secondary: [B, C]}
Remote: Primary change {Primary: A, Secondary: [B, C]} {Primary: B, Secondary: [A, C]}
Client: Write {Primary: A, Secondary: [B, C]} {Primary: B, Secondary: [A, C]}

The client has an inconsistent view of the server side situation and uses node A for writing which it believes to be the primary, while in reality it's changed its role to a secondary.

If we encounter an error indicating this condition, we now refresh the cluster view, then retry the write once.

@thekid thekid merged commit 940854b into master Sep 10, 2023
18 checks passed
@thekid thekid deleted the fix/not-primary branch September 10, 2023 17:54
@thekid
Copy link
Member Author

thekid commented Sep 10, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant