[Tarantool-patches] [PATCH 09/13] txn: assert after WAL write that txn is not done

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sat Jun 12 00:56:17 MSK 2021


In the journal write trigger the transaction assumed it might be
already rolled back and completed, hence does not need to do
anything except free itself.

But it can't happen. The only imaginable reason why a transaction
might be rolled back before it completed its WAL write is a
ROLLBACK entry issued after the transaction.

But ROLLBACK applies its effects only after it is written. Hence
only after all the other pending txns are written too. Therefore
it is not possible for a transaction to get ROLLBACK before it
finishes its own WAL write.

Probably it was possible in the time when applier used to execute
ROLLBACK before writing it to WAL. But that was fixed in
b259e9306f717883026520c975f2610c9fbc7d43 ("applier: process
synchro rows after WAL write"). Can't happen now.

This became easier to realize when not finished transaction
signature got its own value TXN_SIGNATURE_UNKNOWN.
---
 src/box/txn.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/src/box/txn.c b/src/box/txn.c
index c9c2e93ff..1c1eb15bc 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -532,15 +532,7 @@ static void
 txn_on_journal_write(struct journal_entry *entry)
 {
 	struct txn *txn = entry->complete_data;
-	/*
-	 * txn_limbo has already rolled the tx back, so we just
-	 * have to free it.
-	 */
-	if (txn->signature != TXN_SIGNATURE_UNKNOWN) {
-		assert(txn->signature < 0);
-		txn_free(txn);
-		return;
-	}
+	assert(txn->signature == TXN_SIGNATURE_UNKNOWN);
 	txn->signature = entry->res;
 	/*
 	 * Some commit/rollback triggers require for in_txn fiber
-- 
2.24.3 (Apple Git-128)



More information about the Tarantool-patches mailing list