diff --git a/src/box/memtx_tx.c b/src/box/memtx_tx.c index 0e3aaae93b31c87794324e6d936c554e2b33edf7..db68396b09ce7c1bf4f57f961a0e2f27da39afe7 100644 --- a/src/box/memtx_tx.c +++ b/src/box/memtx_tx.c @@ -193,6 +193,8 @@ struct tx_manager struct rlist all_stories; /** Iterator that sequentially traverses all memtx_story objects. */ struct rlist *traverse_all_stories; + /** The list containing all transactions. */ + struct rlist all_txs; /** Accumulated number of GC steps that should be done. */ size_t must_do_gc_steps; }; @@ -234,6 +236,7 @@ memtx_tx_manager_init() cord_slab_cache(), sizeof(struct gap_item)); txm.point_holes_size = 0; rlist_create(&txm.all_stories); + rlist_create(&txm.all_txs); txm.traverse_all_stories = &txm.all_stories; txm.must_do_gc_steps = 0; } @@ -249,6 +252,12 @@ memtx_tx_manager_free() mempool_destroy(&txm.gap_item_mempoool); } +void +memtx_tx_register_tx(struct txn *tx) +{ + rlist_add_tail(&txm.all_txs, &tx->in_all_txs); +} + int memtx_tx_cause_conflict(struct txn *breaker, struct txn *victim) { diff --git a/src/box/memtx_tx.h b/src/box/memtx_tx.h index a0c800b54805236d4cec225d1d1b8e5ff82dd175..7dc145a8abd9cc500026598b453a15e844d496b7 100644 --- a/src/box/memtx_tx.h +++ b/src/box/memtx_tx.h @@ -161,6 +161,9 @@ struct memtx_tx_snapshot_cleaner { struct mh_snapshot_cleaner_t *ht; }; +void +memtx_tx_register_tx(struct txn *tx); + /** * Initialize memtx transaction manager. */ diff --git a/src/box/txn.c b/src/box/txn.c index 06d048870ecad1172cb6e729e866ff3f9627d4dc..c3e6a873cffea292621f0b4b918614086d3872ed 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -205,6 +205,7 @@ txn_new(void) rlist_create(&txn->conflict_list); rlist_create(&txn->conflicted_by_list); rlist_create(&txn->in_read_view_txs); + rlist_create(&txn->in_all_txs); return txn; } @@ -238,6 +239,7 @@ txn_free(struct txn *txn) assert(rlist_empty(&txn->conflicted_by_list)); rlist_del(&txn->in_read_view_txs); + rlist_del(&txn->in_all_txs); struct txn_stmt *stmt; stailq_foreach_entry(stmt, &txn->stmts, next) @@ -300,6 +302,7 @@ txn_begin(void) txn->engine_tx = NULL; txn->fk_deferred_count = 0; rlist_create(&txn->savepoints); + memtx_tx_register_tx(txn); txn->fiber = NULL; fiber_set_txn(fiber(), txn); /* fiber_on_yield is initialized by engine on demand */ diff --git a/src/box/txn.h b/src/box/txn.h index f111445671a791bd4b5325e6a555d93af8d00a1b..6f6ab94b7f6ba119fe3a538a30ac6366c0da2b45 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -422,6 +422,8 @@ struct txn { struct rlist point_holes_list; /** List of gap reads. @sa struct gap_item. */ struct rlist gap_list; + /** Link in tx_manager::all_txs. */ + struct rlist in_all_txs; }; static inline bool