This repository was archived by the owner on Mar 1, 2026. It is now read-only.
Make Rdb_transaction_impl::get_trx safe to call from other threads#1512
Closed
laurynas-biveinis wants to merge 1 commit into
Closed
Make Rdb_transaction_impl::get_trx safe to call from other threads#1512laurynas-biveinis wants to merge 1 commit into
laurynas-biveinis wants to merge 1 commit into
Conversation
|
@luqun has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
|
could you add a MTR for this if possible? |
Contributor
Author
|
Patch: diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index 0727fc66a87..b091e141292 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -5407,6 +5407,9 @@ class Rdb_transaction_impl : public Rdb_transaction {
assert(get_statement_snapshot_type() == snapshot_type::NONE);
assert_snapshot_invariants();
assert(m_rocksdb_reuse_tx[TABLE_TYPE::USER_TABLE] == nullptr);
+
+ DEBUG_SYNC(m_thd, "myrocks_release_tx");
+
auto tx = std::move(m_rocksdb_tx[TABLE_TYPE::USER_TABLE]);
if (rocksdb_write_batch_mem_free_threshold > 0 &&
wb_size > rocksdb_write_batch_mem_free_threshold) {
@@ -7740,6 +7743,9 @@ class Rdb_trx_info_aggregator : public Rdb_tx_list_walker {
const int is_replication = (thd->rli_slave != nullptr);
uint32_t waiting_cf_id;
std::string waiting_key;
+
+ DEBUG_SYNC(current_thd, "myrocks_in_rocksdb_trx_with_trx");
+
rdb_trx->GetWaitingTxns(&waiting_cf_id, &waiting_key),
m_trx_info->push_back(
Test: Output: |
Contributor
Author
|
The testcase does not port directly to the fix branch because one of the debug sync points ends up in the fixing mutex critical section |
- Introduce Rdb_transaction_impl::m_rdb_tx_mutex to protect writes to m_rocksdb_tx[USER_TABLE] from the query thread and reads from other threads. - To protect query thread writes, add critical sections to begin_rdb_tx and release_tx methods. - Make get_rdb_trx lock this mutex before returning the RocksDB transaction pointer and introduce unlock_rdb_trx method to unlock this mutex. - Call the above methods in Rdb_trx_info_aggregator::process_tran. Move unrelated code out of this critical section.
99fe429 to
94d794f
Compare
|
@laurynas-biveinis has updated the pull request. You must reimport the pull request before landing. |
Contributor
Author
|
@luqun, ready for review again |
luqun
reviewed
Jan 27, 2025
|
@luqun has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
This pull request has been merged in c6e4b9f. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
m_rocksdb_tx[USER_TABLE] from the query thread and reads from other threads.
release_tx methods.
pointer and introduce unlock_rdb_trx method to unlock this mutex.
unrelated code out of this critical section.