-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Transactions
-
Storage Engines
-
2
-
2024-08-06 - Withholding Tax
Since a very old commit we've had this code in the __wt_txn_id_alloc function:
id = __wt_atomic_addv64(&txn_global->current, 1) - 1;
The comment above the code reads:
so we want post-increment semantics. Our atomic add primitive does pre-increment, so adjust the result here.
It seems like at the time the fetch_add primitive did not exist in WiredTiger. Which means we can simplify this line of code to:
id = __wt_atomic_fetch_addv64(&txn_global->current, 1);
This will return the value pre-increment, and be the correct way of doing what the code aims to atomically.
Scope:
- Replace both occurrences with fetch_add.
- Run stress testing on the change.