[JAVA-4887] GridFS doesn't support multi-document transactions Created: 16/Feb/23  Updated: 27/Oct/23  Resolved: 21/Feb/23

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Blocker - P1
Reporter: Greg Stewart Assignee: Ashni Mehta
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to JAVA-4890 Multidocument transaction support in ... Backlog
related to DRIVERS-559 GridFS with multi-document transactio... Backlog
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   

Summary

The MongoDb Java driver appears to not support multi-document transactions;

```

            _            // _this.getFileObjectService() is my db service that uses a regular collection
            _            _newId = this.getFileObjectService().add(clientSession, fileObject, interactingEntity);
            __            
            GridFSUploadOptions ops = this.getUploadOps(metadata);
            String filename = newId.toHexString() + "." + FilenameUtils.getExtension(metadata.getOrigName());
            __            
            fileObject.setFileName(filename);
            this.getFileObjectService().update(clientSession, fileObject);
            __            

//Throws: Command failed with error 263 (OperationNotSupportedInTransaction): 'Cannot run 'listIndexes' in a multi-document transaction.'
            bucket.uploadFromStream(clientSession, filename, is, ops);

```

As I am running CRUD operations on regular collections and Gridfs buckets, this error occurs.

It feels like a hard requirement to preserve an all-or-nothing approach to data processing in case of errors. For me to not have this fixed means I would have to accept potential inconsistencies in my database.

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

`4.8.2`, what is provided in current Quarkus versions

How to Reproduce

See above; modifying data in a regular collection and then in a gridfs bucket.

 

_Determined this was a bug after seeing such posts as https://www.mongodb.com/community/forums/t/gridfs-does-not-support-multi-document-transactions/105984_



 Comments   
Comment by Greg Stewart [ 21/Feb/23 ]

Thanks Ashni! Much appreciated!

Comment by Ashni Mehta [ 21/Feb/23 ]

Hey Greg, appreciate you reaching out on this one.

GridFS does not currently support multidocument transactions. You can find more on this topic here: https://www.mongodb.com/docs/manual/core/gridfs/. I chatted with the team and currently, the GridFS spec may require some additional configuration parameters to support multidocument transactions.

I've opened a feature request to capture this work, and I've linked it to this ticket as well. Please upvote that ticket and let me know if there are any specifics about your use case that you think might impact prioritization of that feature request.

Generated at Thu Feb 08 09:03:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.