-
Notifications
You must be signed in to change notification settings - Fork 713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Rdb_transaction_impl::get_trx safe to call from other threads #1512
Make Rdb_transaction_impl::get_trx safe to call from other threads #1512
Conversation
@luqun has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
could you add a MTR for this if possible? |
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:
|
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. |
@luqun, ready for review again |
@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. |
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.