Skip to content

Commit 0d695d5

Browse files
CSHARP-2912: Clarify behavior when 'me' field doesn't match any values in 'hosts' array
1 parent 32b085a commit 0d695d5

File tree

3 files changed

+153
-2
lines changed

3 files changed

+153
-2
lines changed

src/MongoDB.Driver.Core/Core/Clusters/MultiServerCluster.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,10 @@ private ClusterDescription ProcessReplicaSetChange(ClusterDescription clusterDes
358358
clusterDescription = EnsureServers(clusterDescription, args.NewServerDescription, newServers);
359359

360360
if (args.NewServerDescription.CanonicalEndPoint != null &&
361-
!EndPointHelper.Equals(args.NewServerDescription.CanonicalEndPoint, args.NewServerDescription.EndPoint))
361+
!EndPointHelper.Equals(args.NewServerDescription.CanonicalEndPoint, args.NewServerDescription.EndPoint) &&
362+
args.NewServerDescription.Type != ServerType.ReplicaSetPrimary)
362363
{
363-
return RemoveServer(clusterDescription, args.NewServerDescription.EndPoint, "CanonicalEndPoint is different than seed list EndPoint.");
364+
return RemoveServer(clusterDescription, args.NewServerDescription.EndPoint, "CanonicalEndPoint is different than seed list EndPoint and server is not Primary.");
364365
}
365366

366367
if (args.NewServerDescription.Type == ServerType.ReplicaSetPrimary)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"description": "Primary mismatched me is not removed",
3+
"uri": "mongodb://localhost:27017,localhost:27018/?replicaSet=rs",
4+
"phases": [
5+
{
6+
"responses": [
7+
[
8+
"localhost:27017",
9+
{
10+
"ok": 1,
11+
"hosts": [
12+
"localhost:27017",
13+
"localhost:27018"
14+
],
15+
"ismaster": true,
16+
"setName": "rs",
17+
"primary": "localhost:27017",
18+
"me": "a:27017",
19+
"minWireVersion": 0,
20+
"maxWireVersion": 7
21+
}
22+
]
23+
],
24+
"outcome": {
25+
"servers": {
26+
"localhost:27017": {
27+
"type": "RSPrimary",
28+
"setName": "rs"
29+
},
30+
"localhost:27018": {
31+
"type": "Unknown",
32+
"setName": null
33+
}
34+
},
35+
"topologyType": "ReplicaSetWithPrimary",
36+
"logicalSessionTimeoutMinutes": null,
37+
"setName": "rs"
38+
}
39+
},
40+
{
41+
"responses": [
42+
[
43+
"localhost:27018",
44+
{
45+
"ok": 1,
46+
"hosts": [
47+
"localhost:27017",
48+
"localhost:27018"
49+
],
50+
"ismaster": false,
51+
"secondary": true,
52+
"setName": "rs",
53+
"primary": "localhost:27017",
54+
"me": "localhost:27018",
55+
"minWireVersion": 0,
56+
"maxWireVersion": 7
57+
}
58+
]
59+
],
60+
"outcome": {
61+
"servers": {
62+
"localhost:27017": {
63+
"type": "RSPrimary",
64+
"setName": "rs"
65+
},
66+
"localhost:27018": {
67+
"type": "RSSecondary",
68+
"setName": "rs"
69+
}
70+
},
71+
"topologyType": "ReplicaSetWithPrimary",
72+
"logicalSessionTimeoutMinutes": null,
73+
"setName": "rs"
74+
}
75+
}
76+
]
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
description: Primary mismatched me is not removed
2+
uri: mongodb://localhost:27017,localhost:27018/?replicaSet=rs
3+
4+
phases: [
5+
{
6+
responses: [
7+
["localhost:27017", {
8+
ok: 1,
9+
hosts: [
10+
"localhost:27017",
11+
"localhost:27018"
12+
],
13+
ismaster: true,
14+
setName: "rs",
15+
primary: "localhost:27017",
16+
# me does not match the primary responder's address, but the server
17+
# is still added because we don't me mismatch check the primary and all
18+
# servers from a primary ismaster are added to the working server set
19+
me: "a:27017",
20+
minWireVersion: 0,
21+
maxWireVersion: 7
22+
}]
23+
],
24+
outcome: {
25+
servers: {
26+
"localhost:27017": {
27+
type: "RSPrimary",
28+
setName: "rs"
29+
},
30+
"localhost:27018": {
31+
type: "Unknown",
32+
setName: null
33+
}
34+
},
35+
topologyType: "ReplicaSetWithPrimary",
36+
logicalSessionTimeoutMinutes: null,
37+
setName: "rs"
38+
}
39+
},
40+
{
41+
responses: [
42+
["localhost:27018", {
43+
ok: 1,
44+
hosts: [
45+
"localhost:27017",
46+
"localhost:27018"
47+
],
48+
ismaster: false,
49+
secondary: true,
50+
setName: "rs",
51+
primary: "localhost:27017",
52+
me: "localhost:27018",
53+
minWireVersion: 0,
54+
maxWireVersion: 7
55+
}]
56+
],
57+
outcome: {
58+
servers: {
59+
"localhost:27017": {
60+
type: "RSPrimary",
61+
setName: "rs"
62+
},
63+
"localhost:27018": {
64+
type: "RSSecondary",
65+
setName: "rs"
66+
}
67+
},
68+
topologyType: "ReplicaSetWithPrimary",
69+
logicalSessionTimeoutMinutes: null,
70+
setName: "rs"
71+
}
72+
}
73+
]

0 commit comments

Comments
 (0)