Can resume tokens obtained from one target be reused against another target?
For context in our application, we are :
- Opening a change stream against a database and processing some data.
- Saving the resume token.
- Using that resume token to open a stream against a collection c.
We’ve found that in some cases, step 3 fails due to resume token not being found (even though I have confirmed it exists in the oplog and the oplog has not been rotated out).
Are resume tokens only valid for the exact target that they were opened against? In step 3, we find that the error message is something along the lines of :
2024-01-22 06:58:12 source > com.mongodb.MongoCommandException: Command failed with error 280 (ChangeStreamFatalError): 'PlanExecutor error during aggregation :: caused by :: cannot resume stream; the resume token was not found. {_data: "8265ADFE700000007F2B022C0100296E5A10045E66C3ACFD4C48E08BD30480813E5BA9463C5F6964003C31663635643139643965633161316164373663636534306632653165633033313538353036316232386632616533383031393861633262616562623665643130000004"}' on server <redacted>. The full response is {"errorLabels": ["NonResumableChangeStreamError"], "ok": 0.0, "errmsg": "PlanExecutor error during aggregation :: caused by :: cannot resume stream; the resume token was not found. {_data: \"8265ADFE700000007F2B022C0100296E5A10045E66C3ACFD4C48E08BD30480813E5BA9463C5F6964003C31663635643139643965633161316164373663636534306632653165633033313538353036316232386632616533383031393861633262616562623665643130000004\"}", "code": 280, "codeName": "ChangeStreamFatalError", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1705906692, "i": 101}}, "signature": {"hash": {"$binary": {"base64": "ndqg8AuXTezNDLswc92L2j/7bb8=", "subType": "00"}}, "keyId": 7270901963045208066}}, "operationTime": {"$timestamp": {"t": 1705906692, "i": 101}}}
What I noticed is that the failing resume token is actually associated with another collection d in the oplog. Can anyone explain how resume tokens behave in these situations?