Skip to content

adds an optional tidesdb_pessimistic_locking sysvar (off by default) …#92

Merged
guycipher merged 1 commit intomasterfrom
370minor
Mar 14, 2026
Merged

adds an optional tidesdb_pessimistic_locking sysvar (off by default) …#92
guycipher merged 1 commit intomasterfrom
370minor

Conversation

@guycipher
Copy link
Member

…that introduces plugin-level striped mutex row locks for high-contention workloads like tpc-c. when disabled, tidesdb uses its native optimistic mvcc semantics with write-write conflict detection at commit time — ideal for low-contention oltp, analytics, and write-heavy workloads. when enabled, row locks are acquired in index_read_map() for exact pk lookups and in update_row()/delete_row() for scan-based mutations, held until commit or rollback. isolation is downgraded to read_committed since row locks already serialize access, avoiding redundant snapshot conflict checks. the stripe array uses xxh3_64bits() from tidesdb's bundled xxhash.h for faster hashing and better distribution on short pk keys, replacing the earlier fnv-1a approach. stripe count is configurable via a new read-only sysvar tidesdb_row_lock_stripes (default 1024, range 64–65536), dynamically allocated at plugin init and freed at deinit. locks are tracked per-transaction in tidesdb_trx_t and released in commit, rollback, and connection close. mtr tests confirm correctness under concurrent updates, two concurrent updates correctly produced d_next_o_id = 3004 and four concurrent updates produced d_next_o_id = 5005; also lastly updated read me

…that introduces plugin-level striped mutex row locks for high-contention workloads like tpc-c. when disabled, tidesdb uses its native optimistic mvcc semantics with write-write conflict detection at commit time — ideal for low-contention oltp, analytics, and write-heavy workloads. when enabled, row locks are acquired in index_read_map() for exact pk lookups and in update_row()/delete_row() for scan-based mutations, held until commit or rollback. isolation is downgraded to read_committed since row locks already serialize access, avoiding redundant snapshot conflict checks. the stripe array uses xxh3_64bits() from tidesdb's bundled xxhash.h for faster hashing and better distribution on short pk keys, replacing the earlier fnv-1a approach. stripe count is configurable via a new read-only sysvar tidesdb_row_lock_stripes (default 1024, range 64–65536), dynamically allocated at plugin init and freed at deinit. locks are tracked per-transaction in tidesdb_trx_t and released in commit, rollback, and connection close. mtr tests confirm correctness under concurrent updates, two concurrent updates correctly produced d_next_o_id = 3004 and four concurrent updates produced d_next_o_id = 5005; also lastly updated read me
@guycipher guycipher self-assigned this Mar 14, 2026
@guycipher guycipher merged commit d6ac582 into master Mar 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant