@@ -3290,9 +3290,9 @@ void Rdb_snapshot_notifier::SnapshotCreated(
3290
3290
std::multiset<Rdb_transaction *> Rdb_transaction::s_tx_list;
3291
3291
mysql_mutex_t Rdb_transaction::s_tx_list_mutex;
3292
3292
3293
- static Rdb_transaction *& get_tx_from_thd (THD *const thd) {
3294
- return * reinterpret_cast <Rdb_transaction * *>(
3295
- my_core::thd_ha_data (thd, rocksdb_hton));
3293
+ static Rdb_transaction *get_tx_from_thd (THD *const thd) {
3294
+ return reinterpret_cast <Rdb_transaction *>(
3295
+ my_core::thd_get_ha_data (thd, rocksdb_hton));
3296
3296
}
3297
3297
3298
3298
namespace {
@@ -3339,7 +3339,7 @@ class Rdb_perf_context_guard {
3339
3339
*/
3340
3340
3341
3341
static Rdb_transaction *get_or_create_tx (THD *const thd) {
3342
- Rdb_transaction *& tx = get_tx_from_thd (thd);
3342
+ Rdb_transaction *tx = get_tx_from_thd (thd);
3343
3343
// TODO: this is called too many times.. O(#rows)
3344
3344
if (tx == nullptr ) {
3345
3345
bool rpl_skip_tx_api= false ; // MARIAROCKS_NOT_YET.
@@ -3354,6 +3354,7 @@ static Rdb_transaction *get_or_create_tx(THD *const thd) {
3354
3354
}
3355
3355
tx->set_params (THDVAR (thd, lock_wait_timeout), THDVAR (thd, max_row_locks));
3356
3356
tx->start_tx ();
3357
+ my_core::thd_set_ha_data (thd, rocksdb_hton, tx);
3357
3358
} else {
3358
3359
tx->set_params (THDVAR (thd, lock_wait_timeout), THDVAR (thd, max_row_locks));
3359
3360
if (!tx->is_tx_started ()) {
@@ -3365,7 +3366,7 @@ static Rdb_transaction *get_or_create_tx(THD *const thd) {
3365
3366
}
3366
3367
3367
3368
static int rocksdb_close_connection (handlerton *const hton, THD *const thd) {
3368
- Rdb_transaction *& tx = get_tx_from_thd (thd);
3369
+ Rdb_transaction *tx = get_tx_from_thd (thd);
3369
3370
if (tx != nullptr ) {
3370
3371
int rc = tx->finish_bulk_load (false );
3371
3372
if (rc != 0 ) {
@@ -3376,7 +3377,6 @@ static int rocksdb_close_connection(handlerton *const hton, THD *const thd) {
3376
3377
}
3377
3378
3378
3379
delete tx;
3379
- tx = nullptr ;
3380
3380
}
3381
3381
return HA_EXIT_SUCCESS;
3382
3382
}
@@ -3444,7 +3444,7 @@ static int rocksdb_prepare(handlerton* hton, THD* thd, bool prepare_tx)
3444
3444
{
3445
3445
bool async=false ; // This is "ASYNC_COMMIT" feature which is only present in webscalesql
3446
3446
3447
- Rdb_transaction *& tx = get_tx_from_thd (thd);
3447
+ Rdb_transaction *tx = get_tx_from_thd (thd);
3448
3448
if (!tx->can_prepare ()) {
3449
3449
return HA_EXIT_FAILURE;
3450
3450
}
@@ -3695,7 +3695,7 @@ static void rocksdb_commit_ordered(handlerton *hton, THD* thd, bool all)
3695
3695
// Same assert as InnoDB has
3696
3696
DBUG_ASSERT (all || (!thd_test_options (thd, OPTION_NOT_AUTOCOMMIT |
3697
3697
OPTION_BEGIN)));
3698
- Rdb_transaction *& tx = get_tx_from_thd (thd);
3698
+ Rdb_transaction *tx = get_tx_from_thd (thd);
3699
3699
if (!tx->is_two_phase ()) {
3700
3700
/*
3701
3701
ordered_commit is supposedly slower as it is done sequentially
@@ -3727,7 +3727,7 @@ static int rocksdb_commit(handlerton* hton, THD* thd, bool commit_tx)
3727
3727
rocksdb::StopWatchNano timer (rocksdb::Env::Default (), true );
3728
3728
3729
3729
/* note: h->external_lock(F_UNLCK) is called after this function is called) */
3730
- Rdb_transaction *& tx = get_tx_from_thd (thd);
3730
+ Rdb_transaction *tx = get_tx_from_thd (thd);
3731
3731
3732
3732
/* this will trigger saving of perf_context information */
3733
3733
Rdb_perf_context_guard guard (tx, rocksdb_perf_context_level (thd));
@@ -3800,7 +3800,7 @@ static int rocksdb_commit(handlerton* hton, THD* thd, bool commit_tx)
3800
3800
3801
3801
static int rocksdb_rollback (handlerton *const hton, THD *const thd,
3802
3802
bool rollback_tx) {
3803
- Rdb_transaction *& tx = get_tx_from_thd (thd);
3803
+ Rdb_transaction *tx = get_tx_from_thd (thd);
3804
3804
Rdb_perf_context_guard guard (tx, rocksdb_perf_context_level (thd));
3805
3805
3806
3806
if (tx != nullptr ) {
@@ -4607,7 +4607,7 @@ static int rocksdb_savepoint(handlerton *const hton, THD *const thd,
4607
4607
4608
4608
static int rocksdb_rollback_to_savepoint (handlerton *const hton, THD *const thd,
4609
4609
void *const savepoint) {
4610
- Rdb_transaction *& tx = get_tx_from_thd (thd);
4610
+ Rdb_transaction *tx = get_tx_from_thd (thd);
4611
4611
return tx->rollback_to_savepoint (savepoint);
4612
4612
}
4613
4613
@@ -5346,49 +5346,6 @@ static int rocksdb_done_func(void *const p) {
5346
5346
error = 1 ;
5347
5347
}
5348
5348
5349
- /*
5350
- MariaDB: When the plugin is unloaded with UNINSTALL SONAME command, some
5351
- connections may still have Rdb_transaction objects.
5352
-
5353
- These objects are not genuine transactions (as SQL layer makes sure that
5354
- a plugin that is being unloaded has no open tables), they are empty
5355
- Rdb_transaction objects that were left there to save on object
5356
- creation/deletion.
5357
-
5358
- Go through the list and delete them.
5359
- */
5360
- {
5361
- class Rdb_trx_deleter : public Rdb_tx_list_walker {
5362
- public:
5363
- std::set<Rdb_transaction*> rdb_trxs;
5364
-
5365
- void process_tran (const Rdb_transaction *const tx) override {
5366
- /*
5367
- Check if the transaction is really empty. We only check
5368
- non-WriteBatch-based transactions, because there is no easy way to
5369
- check WriteBatch-based transactions.
5370
- */
5371
- if (!tx->is_writebatch_trx ()) {
5372
- const auto tx_impl = static_cast <const Rdb_transaction_impl *>(tx);
5373
- DBUG_ASSERT (tx_impl);
5374
- if (tx_impl->get_rdb_trx ())
5375
- DBUG_ASSERT (0 );
5376
- }
5377
- rdb_trxs.insert ((Rdb_transaction*)tx);
5378
- };
5379
- } deleter;
5380
-
5381
- Rdb_transaction::walk_tx_list (&deleter);
5382
-
5383
- for (std::set<Rdb_transaction*>::iterator it= deleter.rdb_trxs .begin ();
5384
- it != deleter.rdb_trxs .end ();
5385
- ++it)
5386
- {
5387
- // When a transaction is deleted, it removes itself from s_tx_list.
5388
- delete *it;
5389
- }
5390
- }
5391
-
5392
5349
/*
5393
5350
destructors for static objects can be called at _exit(),
5394
5351
but we want to free the memory at dlclose()
@@ -13831,7 +13788,7 @@ int rocksdb_check_bulk_load(
13831
13788
return 1 ;
13832
13789
}
13833
13790
13834
- Rdb_transaction *& tx = get_tx_from_thd (thd);
13791
+ Rdb_transaction *tx = get_tx_from_thd (thd);
13835
13792
if (tx != nullptr ) {
13836
13793
const int rc = tx->finish_bulk_load ();
13837
13794
if (rc != 0 ) {
0 commit comments