Skip to content

Conversation

@laurynas-biveinis
Copy link
Contributor

No description provided.

…ference

This is a second batch of cleanups from the repeatable read snapshot work.

- Make rdb_get_rocksdb_db return reference instead of pointer, update callers
  and callees. Inline this function in ha_rocksdb_proto.h, move rdb declaration
  there to support inlining in detail namespace as documentation that it should
  not be accessed directly. Update ha_rocksdb.cc itself to use
  rdb_get_rocksdb_db instead of rdb. Remove many redudant rdb != nullptr checks
  and asserts.
- Introduce rdb_snapshot_unique_ptr with a custom deleter and a factory function
  get_rdb_snapshot to manager global RocksDB snapshots
- Make Rdb_explicit_snapshot create the snapshot itself, by calling
  get_rdb_snapshot, instead of receiving one through parameters, simplify its
  signature.
- Replace rocksdb::ManagedSnapshot uses with rdb_snapshot_unique_ptr ones.
- Remove rarely-used explicit transaction snapshot assignment code from
  acquire_snapshot and move it to the few callers where it may happen.
  Add new method Rdb_transaction::has_explicit_or_read_only_snapshot to support
  this.
- For Rdb_transaction, make m_insert_count, m_update_count, m_delete_count,
  m_auto_incr_map, & m_rollback_only fields private instead of protected. Move
  their reset at the end of committed or rolledback transactions to on_finish
  method in the base class. Remove redundant m_writes_at_last_savepoint reset in
  set_initial_savepoint.
- Add several asserts.
Make MyRocks isolation behavior closer to that of InnoDB:
- All data-writing SQL statements, and read statements under READ COMMITTED
  isolation level take a RocksDB snapshot at the beginning of the statement, and
  release it at the end.
- Data-reading SQL statements under REPEATABLE READ share a RocksDB snapshot
  which is acquired on a first such statement and released at the end of a
  transaction.

The above causes other user-visible changes:
- rocksdb_skip_snapshot_validation system variable becomes a no-op. This
  variable should be removed at a later time.
- SHOW ENGINE ROCKSDB STATUS output is extended with RR read snapshot
  information.

Implementation details:
- Introduce new possible value for Rdb_transaction::statement_snapshot_type:
  snapshot_type::RR, set iff performing a read under RR.
- Introduce Rdb_transaction::end_stmt method, to be called at the end of each
  MyRocks-involving SQL statement in a transaction, and virtual method
  release_stmt_snapshot with implementation for both regular and WB
  transactions.
- Unify existing code to restore an older RocksDB snapshot if a statement
  failed, as well as the code to release snapshots at the end of RC statements.
@laurynas-biveinis
Copy link
Contributor Author

Creating a draft PR because it contains a prerequisite commits, which is PR'ed separately. Will be rebased after the prerequisite is merged

@laurynas-biveinis laurynas-biveinis deleted the rr-snapshot branch May 15, 2025 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants