You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first example shown uses a single commitTransaction call being used.
This pattern would fail transactions when there are transient errors, such as network errors or write conflicts.
The correct usage is shown in https://docs.mongodb.com/manual/core/transactions/ (click on node.js for node examples) and involves using the withTransaction driver helper to retry operations automatically upon transient errors.
The correct pattern is shown halfway down the page but should be the default pattern used by most applications and should thus be the first example shown.
The first, and most prominent, example should utilize the withTransaction helper.
The documentation should explicitly state that manually calling commitTransaction as in the first currrently shown example is generally incorrect and should only be used in very few cases when manual transaction control is desired.
Do you want to request a feature or report a bug?
Report a bug.
What is the current behavior?
The documentation at https://mongoosejs.com/docs/transactions.html suggests wrong usage of transactions.
The first example shown uses a single
commitTransaction
call being used.This pattern would fail transactions when there are transient errors, such as network errors or write conflicts.
The correct usage is shown in https://docs.mongodb.com/manual/core/transactions/ (click on node.js for node examples) and involves using the
withTransaction
driver helper to retry operations automatically upon transient errors.The correct pattern is shown halfway down the page but should be the default pattern used by most applications and should thus be the first example shown.
Users are mistakenly applying the first shown pattern incorrectly. See, for example, https://stackoverflow.com/questions/63541192/how-can-i-test-mongoose-session-transactions-error-mongooseerror-connection-1#comment117662935_63541192.
What is the expected behavior?
The first, and most prominent, example should utilize the
withTransaction
helper.The documentation should explicitly state that manually calling
commitTransaction
as in the first currrently shown example is generally incorrect and should only be used in very few cases when manual transaction control is desired.See, e.g., for reference: https://docs.mongodb.com/ruby-driver/master/tutorials/ruby-driver-transactions/
The text was updated successfully, but these errors were encountered: