From 4191bb2d1ecafeebb8cfc07b4e3920f22f87e481 Mon Sep 17 00:00:00 2001 From: Alex Gaetano Padula Date: Fri, 13 Mar 2026 23:35:21 -0400 Subject: [PATCH] =?UTF-8?q?adds=20an=20optional=20tidesdb=5Fpessimistic=5F?= =?UTF-8?q?locking=20sysvar=20(off=20by=20default)=20that=20introduces=20p?= =?UTF-8?q?lugin-level=20striped=20mutex=20row=20locks=20for=20high-conten?= =?UTF-8?q?tion=20workloads=20like=20tpc-c.=20when=20disabled,=20tidesdb?= =?UTF-8?q?=20uses=20its=20native=20optimistic=20mvcc=20semantics=20with?= =?UTF-8?q?=20write-write=20conflict=20detection=20at=20commit=20time=20?= =?UTF-8?q?=E2=80=94=20ideal=20for=20low-contention=20oltp,=20analytics,?= =?UTF-8?q?=20and=20write-heavy=20workloads.=20when=20enabled,=20row=20loc?= =?UTF-8?q?ks=20are=20acquired=20in=20index=5Fread=5Fmap()=20for=20exact?= =?UTF-8?q?=20pk=20lookups=20and=20in=20update=5Frow()/delete=5Frow()=20fo?= =?UTF-8?q?r=20scan-based=20mutations,=20held=20until=20commit=20or=20roll?= =?UTF-8?q?back.=20isolation=20is=20downgraded=20to=20read=5Fcommitted=20s?= =?UTF-8?q?ince=20row=20locks=20already=20serialize=20access,=20avoiding?= =?UTF-8?q?=20redundant=20snapshot=20conflict=20checks.=20the=20stripe=20a?= =?UTF-8?q?rray=20uses=20xxh3=5F64bits()=20from=20tidesdb's=20bundled=20xx?= =?UTF-8?q?hash.h=20for=20faster=20hashing=20and=20better=20distribution?= =?UTF-8?q?=20on=20short=20pk=20keys,=20replacing=20the=20earlier=20fnv-1a?= =?UTF-8?q?=20approach.=20stripe=20count=20is=20configurable=20via=20a=20n?= =?UTF-8?q?ew=20read-only=20sysvar=20tidesdb=5Frow=5Flock=5Fstripes=20(def?= =?UTF-8?q?ault=201024,=20range=2064=E2=80=9365536),=20dynamically=20alloc?= =?UTF-8?q?ated=20at=20plugin=20init=20and=20freed=20at=20deinit.=20locks?= =?UTF-8?q?=20are=20tracked=20per-transaction=20in=20tidesdb=5Ftrx=5Ft=20a?= =?UTF-8?q?nd=20released=20in=20commit,=20rollback,=20and=20connection=20c?= =?UTF-8?q?lose.=20mtr=20tests=20confirm=20correctness=20under=20concurren?= =?UTF-8?q?t=20updates,=20two=20concurrent=20updates=20correctly=20produce?= =?UTF-8?q?d=20d=5Fnext=5Fo=5Fid=20=3D=203004=20and=20four=20concurrent=20?= =?UTF-8?q?updates=20produced=20d=5Fnext=5Fo=5Fid=20=3D=205005;=20also=20l?= =?UTF-8?q?astly=20updated=20read=20me?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README | 96 +++++++--- .../tidesdb/r/tidesdb_tpcc_contention.result | 108 ++++++++++++ .../tidesdb/t/tidesdb_tpcc_contention.opt | 1 + .../tidesdb/t/tidesdb_tpcc_contention.test | 164 ++++++++++++++++++ tidesdb/ha_tidesdb.cc | 138 ++++++++++++++- tidesdb/ha_tidesdb.h | 12 ++ 6 files changed, 489 insertions(+), 30 deletions(-) create mode 100644 mysql-test/suite/tidesdb/r/tidesdb_tpcc_contention.result create mode 100644 mysql-test/suite/tidesdb/t/tidesdb_tpcc_contention.opt create mode 100644 mysql-test/suite/tidesdb/t/tidesdb_tpcc_contention.test diff --git a/README b/README index c054f1d..4255271 100644 --- a/README +++ b/README @@ -66,7 +66,7 @@ LINUX (Ubuntu/Debian) 3. Clone MariaDB and copy TidesDB storage engine: - git clone --depth 1 --branch 12.1 https://github.com/MariaDB/server.git mariadb-server + git clone --depth 1 --branch mariadb-12.2.2 https://github.com/MariaDB/server.git mariadb-server cd mariadb-server git submodule update --init --recursive cp -r /path/to/tidesql/tidesdb storage/ @@ -105,7 +105,7 @@ MACOS 3. Clone MariaDB and copy TidesDB storage engine: - git clone --depth 1 --branch 12.1 https://github.com/MariaDB/server.git mariadb-server + git clone --depth 1 --branch mariadb-12.2.2 https://github.com/MariaDB/server.git mariadb-server cd mariadb-server git submodule update --init --recursive cp -r /path/to/tidesql/tidesdb storage/ @@ -171,7 +171,7 @@ WINDOWS 4. Clone MariaDB and copy TidesDB storage engine: - git clone --depth 1 --branch 12.1 https://github.com/MariaDB/server.git mariadb-server + git clone --depth 1 --branch mariadb-12.2.2 https://github.com/MariaDB/server.git mariadb-server cd mariadb-server git submodule update --init --recursive xcopy /E /I path\to\tidesql\tidesdb storage\tidesdb @@ -210,17 +210,24 @@ Core: - MVCC transactions with per-table isolation (autocommit uses READ_COMMITTED; multi-statement transactions use the table's configured level) - SQL savepoints (SAVEPOINT / ROLLBACK TO / RELEASE SAVEPOINT) +- START TRANSACTION WITH CONSISTENT SNAPSHOT - Lock-free concurrency (no THR_LOCK, TidesDB handles isolation internally) +- Optional pessimistic row locking (tidesdb_pessimistic_locking=ON) for + workloads that depend on SELECT ... FOR UPDATE serialization (e.g. TPC-C) - LSM-tree storage with optional B+tree SSTable format - Compression (NONE, LZ4, LZ4_FAST, ZSTD, Snappy) - Bloom filters for fast key lookups - Block cache for frequently accessed data - Primary key (single and composite) and secondary index support - Index Condition Pushdown (ICP) for secondary index scans +- REPLACE INTO and INSERT ... ON DUPLICATE KEY UPDATE - AUTO_INCREMENT with O(1) atomic counter (no iterator per INSERT) - TTL (time-to-live) per-row and per-table expiration - Virtual/generated columns - Online backup (SET GLOBAL tidesdb_backup_dir = '/path') +- Hard-link checkpoint (SET GLOBAL tidesdb_checkpoint_dir = '/path') +- OPTIMIZE TABLE (synchronous purge + compact via tidesdb_purge_cf) +- SHOW ENGINE TIDESDB STATUS (DB stats, memory, cache, conflict info) - Partitioning (RANGE, LIST, HASH, KEY) - Data-at-rest encryption (MariaDB encryption plugin integration) - Online DDL (instant metadata, inplace add/drop index, copy for columns) @@ -239,7 +246,7 @@ TidesDB stores its data as a sibling of the MariaDB data directory: SYSTEM VARIABLES (SET GLOBAL tidesdb_...) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -All are read-only (set at startup) unless noted otherwise. +Read-only (set at startup): flush_threads Background flush threads (default: 4) compaction_threads Background compaction threads (default: 4) @@ -247,8 +254,29 @@ All are read-only (set at startup) unless noted otherwise. block_cache_size Global block cache in bytes (default: 256MB) max_open_sstables Max cached SSTable files (default: 256) max_memory_usage Global memory limit in bytes; 0 = auto (default: 0) - backup_dir [dynamic] Set to a path to trigger online backup - debug_trace [dynamic] Per-operation trace logging (default: OFF) + data_home_dir Override TidesDB data directory (default: auto) + log_to_file Write logs to file vs stderr (default: ON) + log_truncation_at Log file truncation size (default: 24MB; 0 = off) + row_lock_stripes Striped mutexes for pessimistic locking (default: 1024) + +Dynamic (SET GLOBAL at runtime): + + backup_dir Set to a path to trigger online backup + checkpoint_dir Set to a path to trigger hard-link checkpoint + print_all_conflicts Log all TDB_ERR_CONFLICT events (default: OFF) + pessimistic_locking Enable plugin-level row locks for UPDATE/DELETE + (default: OFF). Serializes concurrent writes to + the same PK like InnoDB's row locks. Enable for + TPC-C or workloads needing FOR UPDATE semantics. + +Session (SET SESSION tidesdb_...): + + ttl Per-session TTL override in seconds (default: 0) + skip_unique_check Skip PK/unique checks on INSERT (default: OFF) + default_compression Default compression for new tables + default_write_buffer_size Default write buffer for new tables (32MB) + default_sync_mode Default sync mode for new tables (FULL) + (and other default_* variables for all table options) Logging: TidesDB writes to /LOG by default with automatic truncation at 24 MB. Set log_level to WARN or higher in production to @@ -258,9 +286,9 @@ reduce log volume. TABLE OPTIONS (CREATE TABLE ... ENGINE=TidesDB