From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 38BE842EF5C for ; Tue, 23 Jun 2020 01:56:51 +0300 (MSK) From: Vladislav Shpilevoy Date: Tue, 23 Jun 2020 00:56:49 +0200 Message-Id: <23700741fb309ed1afd98939e1bc9a2fe5b6ea88.1592866585.git.v.shpilevoy@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/1] applier: send heartbeat not only on commit, but on any write List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org Concept of 'commit' becomes not 100% matching WAL write event, when synchro replication comes. And yet applier relied on commit event when sent periodic hearbeats to tell the master the replica's new vclock. The patch makes applier send heartbeats on any write event. Even if it was not commit. For example, when a sync transaction's data was written, and the replica needs to tell the master ACK using the heartbeat. Closes #5100 --- Branch: http://github.com/tarantool/tarantool/tree/gh-4842-sync-replication Issue: https://github.com/tarantool/tarantool/issues/5100 src/box/applier.cc | 12 +++++++++--- src/box/txn_limbo.c | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/box/applier.cc b/src/box/applier.cc index ab9a5ac54..37bf25ffc 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -841,7 +841,7 @@ applier_txn_commit_cb(struct trigger *trigger, void *event) * Return 0 for success or -1 in case of an error. */ static int -applier_apply_tx(struct stailq *rows) +applier_apply_tx(struct stailq *rows, struct fiber *writer) { struct xrow_header *first_row = &stailq_first_entry(rows, struct applier_tx_row, next)->row; @@ -933,7 +933,13 @@ applier_apply_tx(struct stailq *rows) trigger_create(on_commit, applier_txn_commit_cb, NULL, NULL); txn_on_commit(txn, on_commit); - + /* + * Wake the fiber when the transaction finishes writing to + * disk. In case of async transaction it is the same as + * commit event. In case of sync it happens after the data + * is written to WAL. + */ + txn->fiber = writer; if (txn_commit_async(txn) < 0) goto fail; @@ -1131,7 +1137,7 @@ applier_subscribe(struct applier *applier) if (stailq_first_entry(&rows, struct applier_tx_row, next)->row.lsn == 0) fiber_cond_signal(&applier->writer_cond); - else if (applier_apply_tx(&rows) != 0) + else if (applier_apply_tx(&rows, applier->writer) != 0) diag_raise(); if (ibuf_used(ibuf) == 0) diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index 8c05fbb0e..58eeabf2b 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -233,7 +233,6 @@ txn_limbo_read_confirm(struct txn_limbo *limbo, int64_t lsn) rlist_foreach_entry_safe(e, &limbo->queue, in_queue, tmp) { if (e->lsn > lsn) break; - assert(e->txn->fiber == NULL); e->is_commit = true; txn_limbo_remove(limbo, e); txn_clear_flag(e->txn, TXN_WAIT_ACK); -- 2.21.1 (Apple Git-122.3)