[CSHARP-4801] Accessing ChangeStreamDocument.FullDocumentBeforeChange throw if pre-image was already expired Created: 21/Sep/23  Updated: 28/Oct/23  Resolved: 26/Sep/23

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 2.22.0

Type: Bug Priority: Unknown
Reporter: Oleksandr Poliakov Assignee: Oleksandr Poliakov
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Backwards Compatibility: Fully Compatible
Documentation Changes: Not Needed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

Try to access FullDocumentBeforeChange property of change stream change document throws "Unable to cast object of type 'MongoDB.Bson.BsonNull' to type 'MongoDB.Bson.BsonDocument" exception if pre-image for the change was already expired by the cluster.

Steps to reproduce:

1. Set 10 seconds pre-images expiration period:

use admin
db.runCommand({
  setClusterParameter: { changeStreamOptions: { preAndPostImages: { expireAfterSeconds: 10 } } }
}) 

2. Store some resume token.

3. Make some changes into the collection (including document deletion).

4. Wait for some time to let cluster expire the pre-images.

5. Run change stream and try to access FullDocumentBeforeChange for the deleted document.



 Comments   
Comment by Githook User [ 26/Sep/23 ]

Author:

{'name': 'Oleksandr Poliakov', 'email': '31327136+sanych-sun@users.noreply.github.com', 'username': 'sanych-sun'}

Message: CSHARP-4801: Accessing ChangeStreamDocument.FullDocumentBeforeChange throw if pre-image was already expired (#1183)
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/6e6179f5f1ce3b4060749fcc79439e2f9ed54da5

Generated at Wed Feb 07 21:49:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.