From 4ec51b4bc605d022e95dbf1aab7c0e3aa649c688 Mon Sep 17 00:00:00 2001 From: Serge Petrenko <sergepetrenko@tarantool.org> Date: Wed, 31 Jan 2024 14:38:42 +0300 Subject: [PATCH] recovery: move lsn comparison after the replica_id assertion It doesn't make sense to assert that replica_id is correct in a row after using that replica id to make some decisions based on it. Let's switch the order of operations: first assert that replica_id is correct, then compare row lsn with the already recovered one. In-scope-of #9491 NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring --- src/box/recovery.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/box/recovery.cc b/src/box/recovery.cc index 1322a53ab1..5d7d6b04a3 100644 --- a/src/box/recovery.cc +++ b/src/box/recovery.cc @@ -268,9 +268,6 @@ recover_xlog(struct recovery *r, struct xstream *stream, if (stop_vclock != NULL && r->vclock.signature >= stop_vclock->signature) return; - int64_t current_lsn = vclock_get(&r->vclock, row.replica_id); - if (row.lsn <= current_lsn) - continue; /* already applied, skip */ /* * All rows in xlog files have an assigned replica @@ -278,6 +275,9 @@ recover_xlog(struct recovery *r, struct xstream *stream, * are signed with a zero replica id. */ assert(row.replica_id != 0 || row.group_id == GROUP_LOCAL); + int64_t current_lsn = vclock_get(&r->vclock, row.replica_id); + if (row.lsn <= current_lsn) + continue; /* already applied, skip */ /* * We can promote the vclock either before or * after xstream_write(): it only makes any impact -- GitLab