What is the difference between mongoDB endSession and abortTransaction?

Viewed 13

endSession marks the session as expired and abortTransaction aborts the transaction.

Do I need to call endSession after abortTransaction? If it sufficient just to call endSession to abort the transaction?

1 Answers

AbortTransaction aborts the transaction but does not expire the transaction.

EndSession marks the transaction as expired.

After aborting the transaction, it can be used again as it is not marked expired.

Do I need to call endSession after abortTransaction?
Yes, if a session needs to be marked as expired.


Is it sufficient just to call endSession to abort the transaction?
This will expire the session so all updates won't be committed.
Related