Skip to content

Commit 7547755

Browse files
committed
CDRIVER-3741 CursorNotFound err is resumable
1 parent c063ff1 commit 7547755

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

src/libmongoc/src/mongoc/mongoc-change-stream.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ _is_resumable_error (mongoc_change_stream_t *stream, const bson_t *reply)
4747
return true;
4848
}
4949

50+
if (error.code == MONGOC_SERVER_ERR_CURSOR_NOT_FOUND) {
51+
return true;
52+
}
53+
5054
if (stream->max_wire_version >= WIRE_VERSION_4_4) {
5155
return mongoc_error_has_label (reply, "ResumableChangeStreamError");
5256
}

src/libmongoc/src/mongoc/mongoc-error-private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ typedef enum {
3333
typedef enum {
3434
MONGOC_SERVER_ERR_HOSTUNREACHABLE = 6,
3535
MONGOC_SERVER_ERR_HOSTNOTFOUND = 7,
36+
MONGOC_SERVER_ERR_CURSOR_NOT_FOUND = 43,
3637
MONGOC_SERVER_ERR_STALESHARDVERSION = 63,
3738
MONGOC_SERVER_ERR_NETWORKTIMEOUT = 89,
3839
MONGOC_SERVER_ERR_SHUTDOWNINPROGRESS = 91,

src/libmongoc/tests/json/change_streams/change-streams-resume-whitelist.json

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,102 @@
16481648
}
16491649
]
16501650
}
1651+
},
1652+
{
1653+
"description": "change stream resumes after CursorNotFound",
1654+
"minServerVersion": "4.2",
1655+
"failPoint": {
1656+
"configureFailPoint": "failCommand",
1657+
"mode": {
1658+
"times": 1
1659+
},
1660+
"data": {
1661+
"failCommands": [
1662+
"getMore"
1663+
],
1664+
"errorCode": 43,
1665+
"closeConnection": false
1666+
}
1667+
},
1668+
"target": "collection",
1669+
"topology": [
1670+
"replicaset",
1671+
"sharded"
1672+
],
1673+
"changeStreamPipeline": [],
1674+
"changeStreamOptions": {},
1675+
"operations": [
1676+
{
1677+
"database": "change-stream-tests",
1678+
"collection": "test",
1679+
"name": "insertOne",
1680+
"arguments": {
1681+
"document": {
1682+
"x": 1
1683+
}
1684+
}
1685+
}
1686+
],
1687+
"expectations": [
1688+
{
1689+
"command_started_event": {
1690+
"command": {
1691+
"aggregate": "test",
1692+
"cursor": {},
1693+
"pipeline": [
1694+
{
1695+
"$changeStream": {}
1696+
}
1697+
]
1698+
},
1699+
"command_name": "aggregate",
1700+
"database_name": "change-stream-tests"
1701+
}
1702+
},
1703+
{
1704+
"command_started_event": {
1705+
"command": {
1706+
"getMore": 42,
1707+
"collection": "test"
1708+
},
1709+
"command_name": "getMore",
1710+
"database_name": "change-stream-tests"
1711+
}
1712+
},
1713+
{
1714+
"command_started_event": {
1715+
"command": {
1716+
"aggregate": "test",
1717+
"cursor": {},
1718+
"pipeline": [
1719+
{
1720+
"$changeStream": {}
1721+
}
1722+
]
1723+
},
1724+
"command_name": "aggregate",
1725+
"database_name": "change-stream-tests"
1726+
}
1727+
}
1728+
],
1729+
"result": {
1730+
"success": [
1731+
{
1732+
"_id": "42",
1733+
"documentKey": "42",
1734+
"operationType": "insert",
1735+
"ns": {
1736+
"db": "change-stream-tests",
1737+
"coll": "test"
1738+
},
1739+
"fullDocument": {
1740+
"x": {
1741+
"$numberInt": "1"
1742+
}
1743+
}
1744+
}
1745+
]
1746+
}
16511747
}
16521748
]
16531749
}

0 commit comments

Comments
 (0)