[Tarantool-patches] [PATCH 1/3] txn: rename txn_complete_async to txn_on_journal_write
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sat Oct 31 21:01:40 MSK 2020
The function is called only by the journal when write is finished.
Besides, it may not complete the transaction. In case of
synchronous replication it is not enough for completion. It means,
it can't have 'complete' in its name.
Also the function is never used out of txn.c, so it is removed
from txn.h and is now static.
The patch is a preparation for not spaming "too long WAL write" on
synchronous transactions, because it is simply misleading.
Part of #5139
---
src/box/txn.c | 7 ++++---
src/box/txn.h | 6 ------
src/box/txn_limbo.c | 29 ++++++++++++++++++++++-------
3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/src/box/txn.c b/src/box/txn.c
index eb725aaa9..8aedcc9e4 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -580,8 +580,9 @@ txn_complete(struct txn *txn)
}
}
-void
-txn_complete_async(struct journal_entry *entry)
+/** Callback invoked when the transaction's journal write is finished. */
+static void
+txn_on_journal_write(struct journal_entry *entry)
{
struct txn *txn = entry->complete_data;
/*
@@ -614,7 +615,7 @@ txn_journal_entry_new(struct txn *txn)
/* Save space for an additional NOP row just in case. */
req = journal_entry_new(txn->n_new_rows + txn->n_applier_rows + 1,
- &txn->region, txn_complete_async, txn);
+ &txn->region, txn_on_journal_write, txn);
if (req == NULL)
return NULL;
diff --git a/src/box/txn.h b/src/box/txn.h
index a51bdf8e6..ffe240867 100644
--- a/src/box/txn.h
+++ b/src/box/txn.h
@@ -441,12 +441,6 @@ txn_commit(struct txn *txn);
void
txn_rollback(struct txn *txn);
-/**
- * Complete asynchronous transaction.
- */
-void
-txn_complete_async(struct journal_entry *entry);
-
/**
* Submit a transaction to the journal.
* @pre txn == in_txn()
diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c
index 908a17fcc..06a3d30c3 100644
--- a/src/box/txn_limbo.c
+++ b/src/box/txn_limbo.c
@@ -373,10 +373,17 @@ txn_limbo_read_confirm(struct txn_limbo *limbo, int64_t lsn)
txn_clear_flag(e->txn, TXN_WAIT_SYNC);
txn_clear_flag(e->txn, TXN_WAIT_ACK);
/*
- * If txn_complete_async() was already called,
- * finish tx processing. Otherwise just clear the
- * "WAIT_ACK" flag. Tx procesing will finish once
- * the tx is written to WAL.
+ * If already written to WAL by now, finish tx processing.
+ * Otherwise just clear the sync flags. Tx procesing will finish
+ * automatically once the tx is written to WAL.
+ *
+ * XXX: Normally at this point all transactions covered by this
+ * CONFIRM should be in WAL already, but there is a bug, that
+ * replica always processes received synchro requests *before*
+ * writing them to WAL. So it can happen, that a CONFIRM is
+ * 'read', but the transaction is not written yet. Should be
+ * fixed when the replica will behave properly, and then this
+ * branch won't exist.
*/
if (e->txn->signature >= 0)
txn_complete(e->txn);
@@ -424,9 +431,17 @@ txn_limbo_read_rollback(struct txn_limbo *limbo, int64_t lsn)
txn_complete(e->txn);
} else {
/*
- * Rollback the transaction, but don't
- * free it yet. txn_complete_async() will
- * free it.
+ * Rollback the transaction, but don't free it yet. It
+ * will be freed after its WAL write is completed.
+ *
+ * XXX: Normally at this point all transactions covered
+ * by this ROLLBACK should be in WAL already, but there
+ * is a bug, that replica always processes received
+ * synchro requests *before* writing them to WAL. So it
+ * can happen, that a ROLLBACK is 'read', but the
+ * transaction is not written yet. Should be fixed when
+ * the replica will behave properly, and then this
+ * branch won't exist.
*/
e->txn->signature = TXN_SIGNATURE_SYNC_ROLLBACK;
struct fiber *fiber = e->txn->fiber;
--
2.21.1 (Apple Git-122.3)
More information about the Tarantool-patches
mailing list