Skip to content

Commit

Permalink
add a comment about why reset
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Feb 28, 2024
1 parent c82da1f commit 4d76873
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/storage/libmdbx-rs/src/txn_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,15 @@ mod read_transactions {
(
txn_ptr,
duration,
// Abort the transaction
// Abort the transaction.
//
// We use `mdbx_txn_reset` instead of `mdbx_txn_abort` here to
// prevent MDBX from reusing the pointer of the aborted
// tranasction for new read-only transactions. This is
// important because we store the pointer in the `active` list
// and we don't want to accidentally abort a new transaction.
//
// See https://erthink.github.io/libmdbx/group__c__transactions.html#gae9f34737fe60b0ba538d5a09b6a25c8d for more info.
mdbx_result(unsafe { ffi::mdbx_txn_reset(txn_ptr) }),
)
});
Expand Down

0 comments on commit 4d76873

Please sign in to comment.