Driver Examples
Parent: MongoDB Transactions · Published reference · snapshot 2026-10-15
↓ Facts as markdownall context files
Depth-first rabbithole dossier for Driver Examples; source-anchored research pack.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
How it works
- [high] When using drivers, each operation in a transaction must pass the session to each operation, and drivers must ensure the application can access the ClientSession within the callback to associate operations with the transaction. Sources: https://www.mongodb.com/docs/manual/core/transactions-in-applications.md, https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/transactions-convenient-api.md [source]
- [low] The Node.js driver does not support running parallel operations within a single transaction, and using sessions in parallel, such as via Promise.all(), usually leads to server errors. Sources: https://www.mongodb.com/docs/drivers/node/current/crud/transactions.md [source]
Problems, failure modes and limitations
- [low] Drivers must document that the withTransaction callback may be invoked multiple times, once per retry attempt, and must warn about the risk of side effects from using a non-idempotent callback. Sources: https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/transactions-convenient-api.md [source]
- [low] Drivers must document that the withTransaction callback must not silently handle command errors without allowing them to propagate, as catching errors like DuplicateKeyError prevents the driver from aborting the transaction, leading to a commit attempt that fails with a NoSuchTransaction error and causes an infinite retry loop. Sources: https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/transactions-convenient-api.md [source]
- [low] The driver throws an error if you provide a session from one MongoClient instance to a different client instance. Sources: https://www.mongodb.com/docs/drivers/node/current/crud/transactions.md [source]
Comparisons and alternatives
- [low] For the Scala driver, users should refer to the Core API usage example instead of the standard driver examples. Sources: https://www.mongodb.com/docs/manual/core/transactions-in-applications.md [source]
Facts and statements
- [low] You can pass a TransactionOptions instance to the startTransaction() and withTransaction() methods to configure driver behavior, where specified options override values set on the MongoClient instance, while unspecified settings are inherited from the MongoClient. Sources: https://www.mongodb.com/docs/drivers/node/current/crud/transactions.md [source]
- [low] The C, Java, and Ruby drivers will provide reference implementations for the withTransaction method, which is introduced on the ClientSession object to allow application logic to be executed within a transaction. (verified as of 2026-10-14) Sources: https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/transactions-convenient-api.md [source]
- [low] The withTransaction method is capable of retrying either the commit operation or the entire transaction as needed to better ensure successful completion, addressing the complexity of reliably committing transactions in the face of errors introduced with MongoDB 4.0 drivers. (verified as of 2026-10-14) Sources: https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/transactions-convenient-api.md [source]
- [high] To avoid infinite looping errors, ensure that the callback passed to the withTransaction() method catches any errors that it raises, and drivers should recommend using the Core Transaction API if users want to handle errors in a custom way. Sources: https://www.mongodb.com/docs/drivers/node/current/crud/transactions.md, https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/transactions-convenient-api.md [source]
Related concepts
- Driver — is a part of Driver Examples
- Examples — is a part of Driver Examples
Children
- No children recorded.