Skip to content

Don't inspect error messages for "not master" or "node is recovering" #745

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 3 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/libmongoc/src/mongoc/mongoc-error-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ typedef enum {
MONGOC_SERVER_ERR_INTERRUPTEDDUETOREPLSTATECHANGE = 11602,
MONGOC_SERVER_ERR_STALECONFIG = 13388,
MONGOC_SERVER_ERR_NOTMASTERNOSLAVEOK = 13435,
MONGOC_SERVER_ERR_NOTMASTERORSECONDARY = 13436
MONGOC_SERVER_ERR_NOTMASTERORSECONDARY = 13436,
MONGOC_SERVER_ERR_LEGACYNOTPRIMARY = 10058
} mongoc_server_err_t;

mongoc_read_err_type_t
Expand Down
11 changes: 9 additions & 2 deletions src/libmongoc/src/mongoc/mongoc-error.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,13 @@ _mongoc_error_is_not_master (bson_error_t *error)
switch (error->code) {
case MONGOC_SERVER_ERR_NOTMASTER:
case MONGOC_SERVER_ERR_NOTMASTERNOSLAVEOK:
case MONGOC_SERVER_ERR_LEGACYNOTPRIMARY:
return true;
default:
/* All errors where no code was found are marked as MONGOC_ERROR_QUERY_FAILURE */
case MONGOC_ERROR_QUERY_FAILURE:
return NULL != strstr (error->message, "not master");
default:
return false;
}
}

Expand All @@ -287,9 +291,12 @@ _mongoc_error_is_recovering (bson_error_t *error)
case MONGOC_SERVER_ERR_PRIMARYSTEPPEDDOWN:
case MONGOC_SERVER_ERR_SHUTDOWNINPROGRESS:
return true;
default:
/* All errors where no code was found are marked as MONGOC_ERROR_QUERY_FAILURE */
case MONGOC_ERROR_QUERY_FAILURE:
return NULL != strstr (error->message, "not master or secondary") ||
NULL != strstr (error->message, "node is recovering");
default:
return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"description": "Non-stale topologyVersion greater LegacyNotPrimary error",
"uri": "mongodb://a/?replicaSet=rs",
"phases": [
{
"description": "Primary A is discovered",
"responses": [
[
"a:27017",
{
"ok": 1,
"ismaster": true,
"hosts": [
"a:27017"
],
"setName": "rs",
"minWireVersion": 0,
"maxWireVersion": 9,
"topologyVersion": {
"processId": {
"$oid": "000000000000000000000001"
},
"counter": {
"$numberLong": "1"
}
}
}
]
],
"outcome": {
"servers": {
"a:27017": {
"type": "RSPrimary",
"setName": "rs",
"topologyVersion": {
"processId": {
"$oid": "000000000000000000000001"
},
"counter": {
"$numberLong": "1"
}
},
"pool": {
"generation": 0
}
}
},
"topologyType": "ReplicaSetWithPrimary",
"logicalSessionTimeoutMinutes": null,
"setName": "rs"
}
},
{
"description": "Non-stale topologyVersion greater LegacyNotPrimary error marks server Unknown",
"applicationErrors": [
{
"address": "a:27017",
"when": "afterHandshakeCompletes",
"maxWireVersion": 9,
"type": "command",
"response": {
"ok": 0,
"errmsg": "LegacyNotPrimary",
"code": 10058,
"topologyVersion": {
"processId": {
"$oid": "000000000000000000000001"
},
"counter": {
"$numberLong": "2"
}
}
}
}
],
"outcome": {
"servers": {
"a:27017": {
"type": "Unknown",
"topologyVersion": {
"processId": {
"$oid": "000000000000000000000001"
},
"counter": {
"$numberLong": "2"
}
},
"pool": {
"generation": 0
}
}
},
"topologyType": "ReplicaSetNoPrimary",
"logicalSessionTimeoutMinutes": null,
"setName": "rs"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"description": "Non-stale topologyVersion missing LegacyNotPrimary error",
"uri": "mongodb://a/?replicaSet=rs",
"phases": [
{
"description": "Primary A is discovered",
"responses": [
[
"a:27017",
{
"ok": 1,
"ismaster": true,
"hosts": [
"a:27017"
],
"setName": "rs",
"minWireVersion": 0,
"maxWireVersion": 9,
"topologyVersion": {
"processId": {
"$oid": "000000000000000000000001"
},
"counter": {
"$numberLong": "1"
}
}
}
]
],
"outcome": {
"servers": {
"a:27017": {
"type": "RSPrimary",
"setName": "rs",
"topologyVersion": {
"processId": {
"$oid": "000000000000000000000001"
},
"counter": {
"$numberLong": "1"
}
},
"pool": {
"generation": 0
}
}
},
"topologyType": "ReplicaSetWithPrimary",
"logicalSessionTimeoutMinutes": null,
"setName": "rs"
}
},
{
"description": "Non-stale topologyVersion missing LegacyNotPrimary error marks server Unknown",
"applicationErrors": [
{
"address": "a:27017",
"when": "afterHandshakeCompletes",
"maxWireVersion": 9,
"type": "command",
"response": {
"ok": 0,
"errmsg": "LegacyNotPrimary",
"code": 10058
}
}
],
"outcome": {
"servers": {
"a:27017": {
"type": "Unknown",
"topologyVersion": null,
"pool": {
"generation": 0
}
}
},
"topologyType": "ReplicaSetNoPrimary",
"logicalSessionTimeoutMinutes": null,
"setName": "rs"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"description": "Non-stale topologyVersion proccessId changed LegacyNotPrimary error",
"uri": "mongodb://a/?replicaSet=rs",
"phases": [
{
"description": "Primary A is discovered",
"responses": [
[
"a:27017",
{
"ok": 1,
"ismaster": true,
"hosts": [
"a:27017"
],
"setName": "rs",
"minWireVersion": 0,
"maxWireVersion": 9,
"topologyVersion": {
"processId": {
"$oid": "000000000000000000000001"
},
"counter": {
"$numberLong": "1"
}
}
}
]
],
"outcome": {
"servers": {
"a:27017": {
"type": "RSPrimary",
"setName": "rs",
"topologyVersion": {
"processId": {
"$oid": "000000000000000000000001"
},
"counter": {
"$numberLong": "1"
}
},
"pool": {
"generation": 0
}
}
},
"topologyType": "ReplicaSetWithPrimary",
"logicalSessionTimeoutMinutes": null,
"setName": "rs"
}
},
{
"description": "Non-stale topologyVersion proccessId changed LegacyNotPrimary error marks server Unknown",
"applicationErrors": [
{
"address": "a:27017",
"when": "afterHandshakeCompletes",
"maxWireVersion": 9,
"type": "command",
"response": {
"ok": 0,
"errmsg": "LegacyNotPrimary",
"code": 10058,
"topologyVersion": {
"processId": {
"$oid": "000000000000000000000002"
},
"counter": {
"$numberLong": "1"
}
}
}
}
],
"outcome": {
"servers": {
"a:27017": {
"type": "Unknown",
"topologyVersion": {
"processId": {
"$oid": "000000000000000000000002"
},
"counter": {
"$numberLong": "1"
}
},
"pool": {
"generation": 0
}
}
},
"topologyType": "ReplicaSetNoPrimary",
"logicalSessionTimeoutMinutes": null,
"setName": "rs"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"description": "Post-4.2 LegacyNotPrimary error",
"uri": "mongodb://a/?replicaSet=rs",
"phases": [
{
"description": "Primary A is discovered",
"responses": [
[
"a:27017",
{
"ok": 1,
"ismaster": true,
"hosts": [
"a:27017"
],
"setName": "rs",
"minWireVersion": 0,
"maxWireVersion": 8
}
]
],
"outcome": {
"servers": {
"a:27017": {
"type": "RSPrimary",
"setName": "rs",
"topologyVersion": null,
"pool": {
"generation": 0
}
}
},
"topologyType": "ReplicaSetWithPrimary",
"logicalSessionTimeoutMinutes": null,
"setName": "rs"
}
},
{
"description": "Post-4.2 LegacyNotPrimary error marks server Unknown",
"applicationErrors": [
{
"address": "a:27017",
"when": "afterHandshakeCompletes",
"maxWireVersion": 8,
"type": "command",
"response": {
"ok": 0,
"errmsg": "LegacyNotPrimary",
"code": 10058
}
}
],
"outcome": {
"servers": {
"a:27017": {
"type": "Unknown",
"topologyVersion": null,
"pool": {
"generation": 0
}
}
},
"topologyType": "ReplicaSetNoPrimary",
"logicalSessionTimeoutMinutes": null,
"setName": "rs"
}
}
]
}
Loading