Skip to content

Commit 8ececbb

Browse files
committed
Don't remove a mongos on disconnect.
1 parent 3291307 commit 8ececbb

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

pymongo/topology_description.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def updated_topology_description(topology_description, server_description):
166166
topology_type = _SERVER_TYPE_TO_TOPOLOGY_TYPE[server_type]
167167

168168
if topology_type == TOPOLOGY_TYPE.Sharded:
169-
if server_type != SERVER_TYPE.Mongos:
169+
if server_type not in (SERVER_TYPE.Mongos, SERVER_TYPE.Unknown):
170170
sds.pop(address)
171171

172172
elif topology_type == TOPOLOGY_TYPE.ReplicaSetNoPrimary:
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"description": "Mongos disconnect",
3+
"phases": [
4+
{
5+
"outcome": {
6+
"servers": {
7+
"a:27017": {
8+
"setName": null,
9+
"type": "Mongos"
10+
},
11+
"b:27017": {
12+
"setName": null,
13+
"type": "Mongos"
14+
}
15+
},
16+
"setName": null,
17+
"topologyType": "Sharded"
18+
},
19+
"responses": [
20+
[
21+
"a:27017",
22+
{
23+
"ismaster": true,
24+
"msg": "isdbgrid",
25+
"ok": 1
26+
}
27+
],
28+
[
29+
"b:27017",
30+
{
31+
"ismaster": true,
32+
"msg": "isdbgrid",
33+
"ok": 1
34+
}
35+
]
36+
]
37+
},
38+
{
39+
"outcome": {
40+
"servers": {
41+
"a:27017": {
42+
"setName": null,
43+
"type": "Unknown"
44+
},
45+
"b:27017": {
46+
"setName": null,
47+
"type": "Mongos"
48+
}
49+
},
50+
"setName": null,
51+
"topologyType": "Sharded"
52+
},
53+
"responses": [
54+
[
55+
"a:27017",
56+
{}
57+
]
58+
]
59+
},
60+
{
61+
"outcome": {
62+
"servers": {
63+
"a:27017": {
64+
"setName": null,
65+
"type": "Mongos"
66+
},
67+
"b:27017": {
68+
"setName": null,
69+
"type": "Mongos"
70+
}
71+
},
72+
"setName": null,
73+
"topologyType": "Sharded"
74+
},
75+
"responses": [
76+
[
77+
"a:27017",
78+
{
79+
"ismaster": true,
80+
"msg": "isdbgrid",
81+
"ok": 1
82+
}
83+
]
84+
]
85+
}
86+
],
87+
"uri": "mongodb://a,b"
88+
}

0 commit comments

Comments
 (0)