forked from mongodb/mongo-python-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PYTHON-2970 Prioritize electionId over setVersion for stale primary c…
…heck (mongodb#845)
- Loading branch information
1 parent
d1f46e0
commit 1bc3182
Showing
4 changed files
with
409 additions
and
0 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
test/discovery_and_monitoring/rs/electionId_precedence_setVersion.json
This file contains 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": 1, | ||
"maxElectionId": { | ||
"$oid": "000000000000000000000002" | ||
} | ||
} | ||
} | ||
] | ||
} |
149 changes: 149 additions & 0 deletions
149
test/discovery_and_monitoring/rs/set_version_can_rollback.json
This file contains 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,149 @@ | ||
{ | ||
"description": "Set version rolls back after new primary with higher election Id", | ||
"uri": "mongodb://a/?replicaSet=rs", | ||
"phases": [ | ||
{ | ||
"responses": [ | ||
[ | ||
"a:27017", | ||
{ | ||
"ok": 1, | ||
"hello": true, | ||
"isWritablePrimary": true, | ||
"hosts": [ | ||
"a:27017", | ||
"b:27017" | ||
], | ||
"setName": "rs", | ||
"setVersion": 2, | ||
"electionId": { | ||
"$oid": "000000000000000000000001" | ||
}, | ||
"minWireVersion": 0, | ||
"maxWireVersion": 6 | ||
} | ||
] | ||
], | ||
"outcome": { | ||
"servers": { | ||
"a:27017": { | ||
"type": "RSPrimary", | ||
"setName": "rs", | ||
"setVersion": 2, | ||
"electionId": { | ||
"$oid": "000000000000000000000001" | ||
} | ||
}, | ||
"b:27017": { | ||
"type": "Unknown", | ||
"setName": null, | ||
"electionId": null | ||
} | ||
}, | ||
"topologyType": "ReplicaSetWithPrimary", | ||
"logicalSessionTimeoutMinutes": null, | ||
"setName": "rs", | ||
"maxSetVersion": 2, | ||
"maxElectionId": { | ||
"$oid": "000000000000000000000001" | ||
} | ||
} | ||
}, | ||
{ | ||
"_comment": "Response from new primary with newer election Id", | ||
"responses": [ | ||
[ | ||
"b:27017", | ||
{ | ||
"ok": 1, | ||
"hello": true, | ||
"isWritablePrimary": true, | ||
"hosts": [ | ||
"a:27017", | ||
"b:27017" | ||
], | ||
"setName": "rs", | ||
"setVersion": 1, | ||
"electionId": { | ||
"$oid": "000000000000000000000002" | ||
}, | ||
"minWireVersion": 0, | ||
"maxWireVersion": 6 | ||
} | ||
] | ||
], | ||
"outcome": { | ||
"servers": { | ||
"a:27017": { | ||
"type": "Unknown", | ||
"setName": null, | ||
"electionId": null | ||
}, | ||
"b:27017": { | ||
"type": "RSPrimary", | ||
"setName": "rs", | ||
"setVersion": 1, | ||
"electionId": { | ||
"$oid": "000000000000000000000002" | ||
} | ||
} | ||
}, | ||
"topologyType": "ReplicaSetWithPrimary", | ||
"logicalSessionTimeoutMinutes": null, | ||
"setName": "rs", | ||
"maxSetVersion": 1, | ||
"maxElectionId": { | ||
"$oid": "000000000000000000000002" | ||
} | ||
} | ||
}, | ||
{ | ||
"_comment": "Response from stale primary", | ||
"responses": [ | ||
[ | ||
"a:27017", | ||
{ | ||
"ok": 1, | ||
"hello": true, | ||
"isWritablePrimary": true, | ||
"hosts": [ | ||
"a:27017", | ||
"b:27017" | ||
], | ||
"setName": "rs", | ||
"setVersion": 2, | ||
"electionId": { | ||
"$oid": "000000000000000000000001" | ||
}, | ||
"minWireVersion": 0, | ||
"maxWireVersion": 6 | ||
} | ||
] | ||
], | ||
"outcome": { | ||
"servers": { | ||
"a:27017": { | ||
"type": "Unknown", | ||
"setName": null, | ||
"electionId": null | ||
}, | ||
"b:27017": { | ||
"type": "RSPrimary", | ||
"setName": "rs", | ||
"setVersion": 1, | ||
"electionId": { | ||
"$oid": "000000000000000000000002" | ||
} | ||
} | ||
}, | ||
"topologyType": "ReplicaSetWithPrimary", | ||
"logicalSessionTimeoutMinutes": null, | ||
"setName": "rs", | ||
"maxSetVersion": 1, | ||
"maxElectionId": { | ||
"$oid": "000000000000000000000002" | ||
} | ||
} | ||
} | ||
] | ||
} |
84 changes: 84 additions & 0 deletions
84
test/discovery_and_monitoring/rs/setversion_equal_max_without_electionid.json
This file contains 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,84 @@ | ||
{ | ||
"description": "setVersion version that is equal is treated the same as greater than if there is no electionId", | ||
"uri": "mongodb://a/?replicaSet=rs", | ||
"phases": [ | ||
{ | ||
"responses": [ | ||
[ | ||
"a:27017", | ||
{ | ||
"ok": 1, | ||
"helloOk": true, | ||
"isWritablePrimary": true, | ||
"hosts": [ | ||
"a:27017", | ||
"b:27017" | ||
], | ||
"setName": "rs", | ||
"setVersion": 1, | ||
"minWireVersion": 0, | ||
"maxWireVersion": 6 | ||
} | ||
] | ||
], | ||
"outcome": { | ||
"servers": { | ||
"a:27017": { | ||
"type": "RSPrimary", | ||
"setName": "rs", | ||
"setVersion": 1, | ||
"electionId": null | ||
}, | ||
"b:27017": { | ||
"type": "Unknown", | ||
"setName": null, | ||
"electionId": null | ||
} | ||
}, | ||
"topologyType": "ReplicaSetWithPrimary", | ||
"logicalSessionTimeoutMinutes": null, | ||
"setName": "rs", | ||
"maxSetVersion": 1 | ||
} | ||
}, | ||
{ | ||
"responses": [ | ||
[ | ||
"b:27017", | ||
{ | ||
"ok": 1, | ||
"helloOk": true, | ||
"isWritablePrimary": true, | ||
"hosts": [ | ||
"a:27017", | ||
"b:27017" | ||
], | ||
"setName": "rs", | ||
"setVersion": 1, | ||
"minWireVersion": 0, | ||
"maxWireVersion": 6 | ||
} | ||
] | ||
], | ||
"outcome": { | ||
"servers": { | ||
"a:27017": { | ||
"type": "Unknown", | ||
"setName": null, | ||
"electionId": null | ||
}, | ||
"b:27017": { | ||
"type": "RSPrimary", | ||
"setName": "rs", | ||
"setVersion": 1, | ||
"electionId": null | ||
} | ||
}, | ||
"topologyType": "ReplicaSetWithPrimary", | ||
"logicalSessionTimeoutMinutes": null, | ||
"setName": "rs", | ||
"maxSetVersion": 1 | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.