-
Notifications
You must be signed in to change notification settings - Fork 246
DRIVERS-1954: SDAM should give priority to electionId over setVersion when updating topology #1122
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
Merged
nbbeeken
merged 14 commits into
master
from
DRIVERS-1954/electionId-priority-over-setVersion
Mar 7, 2022
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2f645cd
DRIVERS-1954: SDAM should give priority to electionId over setVersion…
nbbeeken ce41552
update comment, add electionId
nbbeeken 6f60d4e
test: add set version can rollback test
nbbeeken ca93b16
fix: pseudo code for updating tuple
nbbeeken aeed121
update pseudo code
nbbeeken 0b3170a
correct code block
nbbeeken 36ab34b
fix one singular character that has the power to make all this code i…
nbbeeken d124a80
fix
nbbeeken 577c497
fix tests & code
nbbeeken 389c7d5
rm todo
nbbeeken 171b630
simplify ternaries
nbbeeken 62587e2
rm tmp variables, update test comment
nbbeeken 7431b3b
Add less/greater/equal setVersion tests
nbbeeken 5e179aa
simplify the if stmt
nbbeeken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
source/server-discovery-and-monitoring/tests/rs/electionId_setVersion.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| { | ||
| "description": "ElectionId is considered higher precedence than setVersion", | ||
| "uri": "mongodb://a/?replicaSet=rs", | ||
| "phases": [ | ||
| { | ||
| "responses": [ | ||
| [ | ||
| "a:27017", | ||
| { | ||
| "ok": 1, | ||
| "helloOk": true, | ||
| "isWritablePrimary": true, | ||
| "hosts": [ | ||
| "a:27017", | ||
| "b:27017" | ||
| ], | ||
| "setName": "rs", | ||
| "setVersion": 1, | ||
| "electionId": { | ||
| "$oid": "000000000000000000000001" | ||
| }, | ||
| "minWireVersion": 0, | ||
| "maxWireVersion": 6 | ||
| } | ||
| ], | ||
| [ | ||
| "b:27017", | ||
| { | ||
| "ok": 1, | ||
| "helloOk": true, | ||
| "isWritablePrimary": true, | ||
| "hosts": [ | ||
| "a:27017", | ||
| "b:27017" | ||
| ], | ||
| "setName": "rs", | ||
| "setVersion": 2, | ||
| "electionId": { | ||
| "$oid": "000000000000000000000001" | ||
| }, | ||
| "minWireVersion": 0, | ||
| "maxWireVersion": 6 | ||
| } | ||
| ], | ||
| [ | ||
| "a:27017", | ||
| { | ||
| "ok": 1, | ||
| "helloOk": true, | ||
| "isWritablePrimary": true, | ||
| "hosts": [ | ||
| "a:27017", | ||
| "b:27017" | ||
| ], | ||
| "setName": "rs", | ||
| "setVersion": 1, | ||
| "electionId": { | ||
| "$oid": "000000000000000000000002" | ||
| }, | ||
| "minWireVersion": 0, | ||
| "maxWireVersion": 6 | ||
| } | ||
| ] | ||
| ], | ||
| "outcome": { | ||
| "servers": { | ||
| "a:27017": { | ||
| "type": "RSPrimary", | ||
| "setName": "rs", | ||
| "setVersion": 1, | ||
| "electionId": { | ||
| "$oid": "000000000000000000000002" | ||
| } | ||
| }, | ||
| "b:27017": { | ||
| "type": "Unknown", | ||
| "setName": null, | ||
| "setVersion": null, | ||
| "electionId": null | ||
| } | ||
| }, | ||
| "topologyType": "ReplicaSetWithPrimary", | ||
| "logicalSessionTimeoutMinutes": null, | ||
| "setName": "rs", | ||
| "maxSetVersion": 2, | ||
| "maxElectionId": { | ||
| "$oid": "000000000000000000000002" | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } |
62 changes: 62 additions & 0 deletions
62
source/server-discovery-and-monitoring/tests/rs/electionId_setVersion.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| description: ElectionId is considered higher precedence than setVersion | ||
| uri: "mongodb://a/?replicaSet=rs" | ||
| phases: | ||
| - responses: | ||
| - - "a:27017" | ||
| - ok: 1 | ||
| helloOk: true | ||
| isWritablePrimary: true | ||
| hosts: | ||
| - "a:27017" | ||
| - "b:27017" | ||
| setName: rs | ||
| setVersion: 1 | ||
| electionId: | ||
| $oid: "000000000000000000000001" | ||
| minWireVersion: 0 | ||
| maxWireVersion: 6 | ||
| - - "b:27017" | ||
| - ok: 1 | ||
| helloOk: true | ||
| isWritablePrimary: true | ||
| hosts: | ||
| - "a:27017" | ||
| - "b:27017" | ||
| setName: rs | ||
| setVersion: 2 # Even though "B" reports the newer setVersion, "A" will report the newer electionId which should allow it to remain the primary | ||
| electionId: | ||
| $oid: "000000000000000000000001" | ||
| minWireVersion: 0 | ||
| maxWireVersion: 6 | ||
| - - "a:27017" | ||
| - ok: 1 | ||
| helloOk: true | ||
| isWritablePrimary: true | ||
| hosts: | ||
| - "a:27017" | ||
| - "b:27017" | ||
| setName: rs | ||
| setVersion: 1 | ||
| electionId: | ||
| $oid: "000000000000000000000002" | ||
| minWireVersion: 0 | ||
| maxWireVersion: 6 | ||
| outcome: | ||
| servers: | ||
| "a:27017": | ||
| type: RSPrimary | ||
| setName: rs | ||
| setVersion: 1 | ||
| electionId: | ||
| $oid: "000000000000000000000002" | ||
| "b:27017": | ||
| type: Unknown | ||
| setName: null | ||
| setVersion: null | ||
| electionId: null | ||
| topologyType: ReplicaSetWithPrimary | ||
| logicalSessionTimeoutMinutes: null | ||
| setName: rs | ||
| maxSetVersion: 2 | ||
| maxElectionId: | ||
| $oid: "000000000000000000000002" |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.