From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (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 5C8F442EF5D for ; Fri, 19 Jun 2020 21:00:39 +0300 (MSK) From: Serge Petrenko Date: Fri, 19 Jun 2020 21:00:15 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2/2] replication: support ROLLBACK and CONFIRM during recovery List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: v.shpilevoy@tarantool.org, sergos@tarantool.org, gorcunov@tarantool.org, lvasiliev@tarantool.org Cc: tarantool-patches@dev.tarantool.org Follow-up #4847 Follow-up #4848 --- src/box/box.cc | 20 ++++++++++++++++++-- src/box/txn_limbo.c | 6 ++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index f80d6f8e6..f4c22b340 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -374,9 +374,25 @@ static void apply_wal_row(struct xstream *stream, struct xrow_header *row) { struct request request; - // TODO: process confirmation during recovery. - if (iproto_type_is_synchro_request(row->type)) + if (iproto_type_is_synchro_request(row->type)) { + uint32_t replica_id; + int64_t lsn; + switch(row->type) { + case IPROTO_CONFIRM: + if (xrow_decode_confirm(row, &replica_id, &lsn) < 0) + diag_raise(); + assert(txn_limbo.instance_id == replica_id); + txn_limbo_read_confirm(&txn_limbo, lsn); + break; + case IPROTO_ROLLBACK: + if (xrow_decode_rollback(row, &replica_id, &lsn) < 0) + diag_raise(); + assert(txn_limbo.instance_id == replica_id); + txn_limbo_read_rollback(&txn_limbo, lsn); + break; + } return; + } xrow_decode_dml_xc(row, &request, dml_request_key_map(row->type)); if (request.type != IPROTO_NOP) { struct space *space = space_cache_find_xc(request.space_id); diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index 1e1fa1aaf..ed19d4ec5 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -228,8 +228,7 @@ txn_limbo_write_confirm(struct txn_limbo *limbo, void txn_limbo_read_confirm(struct txn_limbo *limbo, int64_t lsn) { - assert(limbo->instance_id != REPLICA_ID_NIL && - limbo->instance_id != instance_id); + assert(limbo->instance_id != REPLICA_ID_NIL); struct txn_limbo_entry *e, *tmp; rlist_foreach_entry_safe(e, &limbo->queue, in_queue, tmp) { if (e->lsn > lsn) @@ -262,8 +261,7 @@ txn_limbo_write_rollback(struct txn_limbo *limbo, void txn_limbo_read_rollback(struct txn_limbo *limbo, int64_t lsn) { - assert(limbo->instance_id != REPLICA_ID_NIL && - limbo->instance_id != instance_id); + assert(limbo->instance_id != REPLICA_ID_NIL); struct txn_limbo_entry *e, *tmp; rlist_foreach_entry_safe_reverse(e, &limbo->queue, in_queue, tmp) { if (e->lsn <= lsn) -- 2.24.3 (Apple Git-128)