Skip to content

fix(NODE-3712,NODE-4546): electionId should be ordered before setVersion #3174

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
merged 7 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
sync: spec tests, has failures
  • Loading branch information
nbbeeken committed Sep 28, 2022
commit 6bf41970b9bef6207e7443b3b10e80032b08951e
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"
}
}
}
]
}
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: 1
maxElectionId:
$oid: "000000000000000000000002"
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,19 @@
"outcome": {
"servers": {
"a:27017": {
"type": "RSPrimary",
"setName": "rs",
"setVersion": 1,
"electionId": null
},
"b:27017": {
"type": "Unknown",
"setName": null,
"setVersion": null,
"electionId": null
},
"b:27017": {
"type": "RSPrimary",
"setName": "rs",
"setVersion": 1,
"electionId": {
"$oid": "000000000000000000000002"
}
},
"c:27017": {
"type": "Unknown",
"setName": null,
Expand Down Expand Up @@ -174,16 +177,19 @@
"outcome": {
"servers": {
"a:27017": {
"type": "RSPrimary",
"setName": "rs",
"setVersion": 1,
"electionId": null
},
"b:27017": {
"type": "Unknown",
"setName": null,
"setVersion": null,
"electionId": null
},
"b:27017": {
"type": "RSPrimary",
"setName": "rs",
"setVersion": 1,
"electionId": {
"$oid": "000000000000000000000002"
}
},
"c:27017": {
"type": "Unknown",
"setName": null,
Expand Down
30 changes: 16 additions & 14 deletions test/spec/server-discovery-and-monitoring/rs/null_election_id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ phases: [
}
},

# A still claims to be primary, no electionId, we have to trust it.
# A still claims to be primary, no electionId, we don't trust it.
{
responses: [
["a:27017", {
Expand All @@ -104,17 +104,19 @@ phases: [
],
outcome: {
servers: {
# A ignored for missing electionId
"a:27017": {
type: "RSPrimary",
setName: "rs",
setVersion: 1,
electionId:
},
"b:27017": {
type: "Unknown",
setName: ,
setVersion: ,
electionId:
},
"b:27017": {
type: "RSPrimary",
setName: "rs",
setVersion: 1,
electionId: { "$oid": "000000000000000000000002" }
},
"c:27017": {
type: "Unknown",
setName: ,
Expand Down Expand Up @@ -147,18 +149,18 @@ phases: [
],
outcome: {
servers: {
# Still primary.
"a:27017": {
type: "RSPrimary",
setName: "rs",
setVersion: 1,
electionId:
},
"b:27017": {
type: "Unknown",
setName: ,
setVersion: ,
electionId:
},
"b:27017": {
type: "RSPrimary",
setName: "rs",
setVersion: 1,
electionId: { "$oid": "000000000000000000000002" }
},
"c:27017": {
type: "Unknown",
setName: ,
Expand Down
Loading