[CSHARP-2146] System.IO.EndOfStreamException when iterating change stream cursor Created: 11/Jan/18 Updated: 04/Apr/23 Resolved: 25/Jun/20 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Connectivity, Read Operations |
| Affects Version/s: | 2.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Andrii Litvinov | Assignee: | Wan Bachtiar |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||
| Description |
|
I got following exception when tried to resume watching changes in collection with new change stream feature in MongoDB 3.6. This error happened on 2 out of 6 collections I watched. It started occurring after 6-12 hours and it worked normally before. To resolve it I needed to restart watching for the events without resume token which is unfortunate because it can cause loss of information in my system. System.IO.EndOfStreamException: Attempted to read past the end of the stream. |
| Comments |
| Comment by Rachelle Palmer [ 25/Jun/20 ] | |
|
Hi there, thank you for reaching out to MongoDB. As this sounds more like a support issue, I wanted to give you some resources to get this question answered more quickly:
Thank you! | |
| Comment by Andrii Litvinov [ 17/Apr/19 ] | |
|
Hi Wan, Thank you for the comment. Replica set didn't fail over during the issue. The symptoms were that I started collection.watch and after some hours (days?) I got the exception that I posted in the description. After this exception my service tried to restart watching but then the error that you suggested happened (Command aggregate failed: The resume token UUID does not exist. Has the collection been dropped?). Could be that the service was watching for the collection for a long time and no changes happened to the collection for a time longer than the oplog window. I saw this exception multiple times during the testing of the service in staging environment, but I cannot provide steps to reproduce. Only thing that I can tell that the collections were not often modified and service was meant to be running without restart for extended period, like always. >Change Streams is built on top of oplog. If the last operation seen has fallen off the oplog, tailing oplog is essentially skipping some operations as well. i.e. similar to just calling Watch() without token. Cheers, | |
| Comment by Wan Bachtiar [ 11/Apr/19 ] | |
Hi, If you call Collection.Watch() (both in v2.5 and v2.7) with a resume token that no longer exists in the oplog, you should be getting MongoCommandException with the following message, in MongoDB v3.6:
Are you able to consistently reproduce the error ? If so, would you be able to provide:
Also, please test against MongoDB C# driver v2.7+
Change Streams is built on top of oplog. If the last operation seen has fallen off the oplog, tailing oplog is essentially skipping some operations as well. i.e. similar to just calling Watch() without token.
The patch in Regards, | |
| Comment by Andrii Litvinov [ 29/Jan/19 ] | |
|
Hey Ian thank you getting back to me. It seems that issue happened when there were no operations in oplog for the token I supplied. Means I couldn't successfully resume the change stream and might miss new events. That's why I decided to change implementation of my service to oplog tailing instead of change stream. So I cannot confirm that the issue if fixed for me. Based on the description of
Just to be sure, after the fix, some different error will be thrown, right? | |
| Comment by Ian Whalen (Inactive) [ 28/Jan/19 ] | |
|
Andrii Litvinov could you please test against 2.7.3? Given that you were seeing this under 2.5, we believe we have fixed this issue since (see |