Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: v.shpilevoy@tarantool.org, gorcunov@gmail.com
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH 2/3] txn_limbo: move lsn assignment to journal completion callback
Date: Thu, 20 May 2021 12:02:35 +0300	[thread overview]
Message-ID: <45cf1226095c865bc77274805260d42915913140.1621501007.git.sergepetrenko@tarantool.org> (raw)
In-Reply-To: <cover.1621501007.git.sergepetrenko@tarantool.org>

Previously local lsn assignment for txn_limbo entries was done right in
txn_commit() body after the WAL write.

In order to make the entries lsn available to on_wal_write triggers, which are
called from the journal completion callback, assign it right in the
callback before the triggers are called.

Note, ACKing the entry is not moved to journal completion callback, since
it may trigger writing CONFIRM, which cannot be done from the sched fiber
(which executes the journal callback).

Prerequisite #6032
---
 src/box/txn.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/box/txn.c b/src/box/txn.c
index 1fa3e4367..dea824d78 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -545,6 +545,16 @@ txn_on_journal_write(struct journal_entry *entry)
 		txn_complete_fail(txn);
 		goto finish;
 	}
+
+	if (txn_has_flag(txn, TXN_WAIT_ACK) && txn->limbo_entry->lsn == -1) {
+		int64_t lsn = entry->rows[entry->n_rows - 1]->lsn;
+		/*
+		 * Must be a local entry since its lsn wasn't known prior to
+		 * the WAL write.
+		 */
+		txn_limbo_assign_local_lsn(&txn_limbo, txn->limbo_entry, lsn);
+	}
+
 	double stop_tm = ev_monotonic_now(loop());
 	double delta = stop_tm - txn->start_tm;
 	if (delta > too_long_threshold) {
@@ -906,13 +916,6 @@ txn_commit(struct txn *txn)
 	if (is_sync) {
 		if (txn_has_flag(txn, TXN_WAIT_ACK)) {
 			int64_t lsn = req->rows[req->n_rows - 1]->lsn;
-			/*
-			 * Use local LSN assignment. Because
-			 * blocking commit is used by local
-			 * transactions only.
-			 */
-			txn_limbo_assign_local_lsn(&txn_limbo, txn->limbo_entry,
-						   lsn);
 			/* Local WAL write is a first 'ACK'. */
 			txn_limbo_ack(&txn_limbo, txn_limbo.owner_id, lsn);
 		}
-- 
2.30.1 (Apple Git-130)


  parent reply	other threads:[~2021-05-20  9:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20  9:02 [Tarantool-patches] [PATCH 0/3] fix assertion failure in box.ctl.promote() Serge Petrenko via Tarantool-patches
2021-05-20  9:02 ` [Tarantool-patches] [PATCH 1/3] box: make txn reference the limbo entry Serge Petrenko via Tarantool-patches
2021-05-20  9:02 ` Serge Petrenko via Tarantool-patches [this message]
2021-05-20  9:02 ` [Tarantool-patches] [PATCH 3/3] box: fix an assertion failure in box.ctl.promote() Serge Petrenko via Tarantool-patches
2021-05-23 12:18   ` Vladislav Shpilevoy via Tarantool-patches
2021-05-25 10:39     ` Serge Petrenko via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45cf1226095c865bc77274805260d42915913140.1621501007.git.sergepetrenko@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 2/3] txn_limbo: move lsn assignment to journal completion callback' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox