Skip to content

Commit acfd7a3

Browse files
GODRIVER-2524 SDAM should prioritize electionId over setVersion only on >=6.0 servers (#1090)
1 parent 25122e1 commit acfd7a3

24 files changed

+2032
-109
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"description": "ElectionId is considered higher precedence than setVersion",
3+
"uri": "mongodb://a/?replicaSet=rs",
4+
"phases": [
5+
{
6+
"responses": [
7+
[
8+
"a:27017",
9+
{
10+
"ok": 1,
11+
"helloOk": true,
12+
"isWritablePrimary": true,
13+
"hosts": [
14+
"a:27017",
15+
"b:27017"
16+
],
17+
"setName": "rs",
18+
"setVersion": 1,
19+
"electionId": {
20+
"$oid": "000000000000000000000001"
21+
},
22+
"minWireVersion": 0,
23+
"maxWireVersion": 17
24+
}
25+
],
26+
[
27+
"b:27017",
28+
{
29+
"ok": 1,
30+
"helloOk": true,
31+
"isWritablePrimary": true,
32+
"hosts": [
33+
"a:27017",
34+
"b:27017"
35+
],
36+
"setName": "rs",
37+
"setVersion": 2,
38+
"electionId": {
39+
"$oid": "000000000000000000000001"
40+
},
41+
"minWireVersion": 0,
42+
"maxWireVersion": 17
43+
}
44+
],
45+
[
46+
"a:27017",
47+
{
48+
"ok": 1,
49+
"helloOk": true,
50+
"isWritablePrimary": true,
51+
"hosts": [
52+
"a:27017",
53+
"b:27017"
54+
],
55+
"setName": "rs",
56+
"setVersion": 1,
57+
"electionId": {
58+
"$oid": "000000000000000000000002"
59+
},
60+
"minWireVersion": 0,
61+
"maxWireVersion": 17
62+
}
63+
]
64+
],
65+
"outcome": {
66+
"servers": {
67+
"a:27017": {
68+
"type": "RSPrimary",
69+
"setName": "rs",
70+
"setVersion": 1,
71+
"electionId": {
72+
"$oid": "000000000000000000000002"
73+
}
74+
},
75+
"b:27017": {
76+
"type": "Unknown",
77+
"setName": null,
78+
"setVersion": null,
79+
"electionId": null
80+
}
81+
},
82+
"topologyType": "ReplicaSetWithPrimary",
83+
"logicalSessionTimeoutMinutes": null,
84+
"setName": "rs",
85+
"maxSetVersion": 1,
86+
"maxElectionId": {
87+
"$oid": "000000000000000000000002"
88+
}
89+
}
90+
}
91+
]
92+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
description: ElectionId is considered higher precedence than setVersion
2+
uri: "mongodb://a/?replicaSet=rs"
3+
phases:
4+
- responses:
5+
- - "a:27017"
6+
- ok: 1
7+
helloOk: true
8+
isWritablePrimary: true
9+
hosts:
10+
- "a:27017"
11+
- "b:27017"
12+
setName: rs
13+
setVersion: 1
14+
electionId:
15+
$oid: "000000000000000000000001"
16+
minWireVersion: 0
17+
maxWireVersion: 17
18+
- - "b:27017"
19+
- ok: 1
20+
helloOk: true
21+
isWritablePrimary: true
22+
hosts:
23+
- "a:27017"
24+
- "b:27017"
25+
setName: rs
26+
setVersion: 2 # Even though "B" reports the newer setVersion, "A" will report the newer electionId which should allow it to remain the primary
27+
electionId:
28+
$oid: "000000000000000000000001"
29+
minWireVersion: 0
30+
maxWireVersion: 17
31+
- - "a:27017"
32+
- ok: 1
33+
helloOk: true
34+
isWritablePrimary: true
35+
hosts:
36+
- "a:27017"
37+
- "b:27017"
38+
setName: rs
39+
setVersion: 1
40+
electionId:
41+
$oid: "000000000000000000000002"
42+
minWireVersion: 0
43+
maxWireVersion: 17
44+
outcome:
45+
servers:
46+
"a:27017":
47+
type: RSPrimary
48+
setName: rs
49+
setVersion: 1
50+
electionId:
51+
$oid: "000000000000000000000002"
52+
"b:27017":
53+
type: Unknown
54+
setName: null
55+
setVersion: null
56+
electionId: null
57+
topologyType: ReplicaSetWithPrimary
58+
logicalSessionTimeoutMinutes: null
59+
setName: rs
60+
maxSetVersion: 1
61+
maxElectionId:
62+
$oid: "000000000000000000000002"
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
{
2+
"description": "Pre 6.0 Primaries with and without electionIds",
3+
"uri": "mongodb://a/?replicaSet=rs",
4+
"phases": [
5+
{
6+
"responses": [
7+
[
8+
"a:27017",
9+
{
10+
"ok": 1,
11+
"helloOk": true,
12+
"isWritablePrimary": true,
13+
"hosts": [
14+
"a:27017",
15+
"b:27017",
16+
"c:27017"
17+
],
18+
"setVersion": 1,
19+
"setName": "rs",
20+
"minWireVersion": 0,
21+
"maxWireVersion": 6
22+
}
23+
]
24+
],
25+
"outcome": {
26+
"servers": {
27+
"a:27017": {
28+
"type": "RSPrimary",
29+
"setName": "rs",
30+
"setVersion": 1,
31+
"electionId": null
32+
},
33+
"b:27017": {
34+
"type": "Unknown",
35+
"setName": null,
36+
"electionId": null
37+
},
38+
"c:27017": {
39+
"type": "Unknown",
40+
"setName": null,
41+
"electionId": null
42+
}
43+
},
44+
"topologyType": "ReplicaSetWithPrimary",
45+
"logicalSessionTimeoutMinutes": null,
46+
"setName": "rs",
47+
"maxSetVersion": 1
48+
}
49+
},
50+
{
51+
"responses": [
52+
[
53+
"b:27017",
54+
{
55+
"ok": 1,
56+
"helloOk": true,
57+
"isWritablePrimary": true,
58+
"hosts": [
59+
"a:27017",
60+
"b:27017",
61+
"c:27017"
62+
],
63+
"setName": "rs",
64+
"setVersion": 1,
65+
"electionId": {
66+
"$oid": "000000000000000000000002"
67+
},
68+
"minWireVersion": 0,
69+
"maxWireVersion": 6
70+
}
71+
]
72+
],
73+
"outcome": {
74+
"servers": {
75+
"a:27017": {
76+
"type": "Unknown",
77+
"setName": null,
78+
"electionId": null
79+
},
80+
"b:27017": {
81+
"type": "RSPrimary",
82+
"setName": "rs",
83+
"setVersion": 1,
84+
"electionId": {
85+
"$oid": "000000000000000000000002"
86+
}
87+
},
88+
"c:27017": {
89+
"type": "Unknown",
90+
"setName": null,
91+
"electionId": null
92+
}
93+
},
94+
"topologyType": "ReplicaSetWithPrimary",
95+
"logicalSessionTimeoutMinutes": null,
96+
"setName": "rs",
97+
"maxSetVersion": 1,
98+
"maxElectionId": {
99+
"$oid": "000000000000000000000002"
100+
}
101+
}
102+
},
103+
{
104+
"responses": [
105+
[
106+
"a:27017",
107+
{
108+
"ok": 1,
109+
"helloOk": true,
110+
"isWritablePrimary": true,
111+
"hosts": [
112+
"a:27017",
113+
"b:27017",
114+
"c:27017"
115+
],
116+
"setVersion": 1,
117+
"setName": "rs",
118+
"minWireVersion": 0,
119+
"maxWireVersion": 6
120+
}
121+
]
122+
],
123+
"outcome": {
124+
"servers": {
125+
"a:27017": {
126+
"type": "RSPrimary",
127+
"setName": "rs",
128+
"setVersion": 1,
129+
"electionId": null
130+
},
131+
"b:27017": {
132+
"type": "Unknown",
133+
"setName": null,
134+
"electionId": null
135+
},
136+
"c:27017": {
137+
"type": "Unknown",
138+
"setName": null,
139+
"electionId": null
140+
}
141+
},
142+
"topologyType": "ReplicaSetWithPrimary",
143+
"logicalSessionTimeoutMinutes": null,
144+
"setName": "rs",
145+
"maxSetVersion": 1,
146+
"maxElectionId": {
147+
"$oid": "000000000000000000000002"
148+
}
149+
}
150+
},
151+
{
152+
"responses": [
153+
[
154+
"c:27017",
155+
{
156+
"ok": 1,
157+
"helloOk": true,
158+
"isWritablePrimary": true,
159+
"hosts": [
160+
"a:27017",
161+
"b:27017",
162+
"c:27017"
163+
],
164+
"setName": "rs",
165+
"setVersion": 1,
166+
"electionId": {
167+
"$oid": "000000000000000000000001"
168+
},
169+
"minWireVersion": 0,
170+
"maxWireVersion": 6
171+
}
172+
]
173+
],
174+
"outcome": {
175+
"servers": {
176+
"a:27017": {
177+
"type": "RSPrimary",
178+
"setName": "rs",
179+
"setVersion": 1,
180+
"electionId": null
181+
},
182+
"b:27017": {
183+
"type": "Unknown",
184+
"setName": null,
185+
"electionId": null
186+
},
187+
"c:27017": {
188+
"type": "Unknown",
189+
"setName": null,
190+
"electionId": null
191+
}
192+
},
193+
"topologyType": "ReplicaSetWithPrimary",
194+
"logicalSessionTimeoutMinutes": null,
195+
"setName": "rs",
196+
"maxSetVersion": 1,
197+
"maxElectionId": {
198+
"$oid": "000000000000000000000002"
199+
}
200+
}
201+
}
202+
]
203+
}

0 commit comments

Comments
 (0)