Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: tml <tarantool-patches@dev.tarantool.org>
Subject: [Tarantool-patches] [PATCH 16/17] box: use _xc helpers of recovery code
Date: Tue, 28 Apr 2020 19:11:36 +0300	[thread overview]
Message-ID: <20200428161137.20536-17-gorcunov@gmail.com> (raw)
In-Reply-To: <20200428161137.20536-1-gorcunov@gmail.com>

To shrink code a bit.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 src/box/box.cc | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/src/box/box.cc b/src/box/box.cc
index 01ef3318f..802aa27a2 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -2221,11 +2221,9 @@ local_recovery(const struct tt_uuid *instance_uuid,
 	wal_stream_create(&wal_stream);
 
 	struct recovery *recovery;
-	recovery = recovery_new(cfg_gets("wal_dir"),
-				cfg_geti("force_recovery"),
-				checkpoint_vclock);
-	if (recovery == NULL)
-		diag_raise();
+	recovery = recovery_new_xc(cfg_gets("wal_dir"),
+				   cfg_geti("force_recovery"),
+				   checkpoint_vclock);
 
 	/*
 	 * Make sure we report the actual recovery position
@@ -2243,8 +2241,7 @@ local_recovery(const struct tt_uuid *instance_uuid,
 	 * so we must reflect this in replicaset vclock to
 	 * not attempt to apply these rows twice.
 	 */
-	if (recovery_scan(recovery, &replicaset.vclock, &gc.vclock) != 0)
-		diag_raise();
+	recovery_scan_xc(recovery, &replicaset.vclock, &gc.vclock);
 	say_info("instance vclock %s", vclock_to_string(&replicaset.vclock));
 
 	if (wal_dir_lock >= 0) {
@@ -2285,8 +2282,7 @@ local_recovery(const struct tt_uuid *instance_uuid,
 	memtx_engine_recover_snapshot_xc(memtx, checkpoint_vclock);
 
 	engine_begin_final_recovery_xc();
-	if (recover_remaining_wals(recovery, &wal_stream.base, NULL, false) != 0)
-		diag_raise();
+	recover_remaining_wals_xc(recovery, &wal_stream.base, NULL, false);
 	engine_end_recovery_xc();
 	/*
 	 * Leave hot standby mode, if any, only after
@@ -2295,22 +2291,19 @@ local_recovery(const struct tt_uuid *instance_uuid,
 	if (wal_dir_lock < 0) {
 		title("hot_standby");
 		say_info("Entering hot standby mode");
-		if (recovery_follow_local(recovery, &wal_stream.base, "hot_standby",
-					  cfg_getd("wal_dir_rescan_delay")) != 0)
-			diag_raise();
+		recovery_follow_local_xc(recovery, &wal_stream.base, "hot_standby",
+					 cfg_getd("wal_dir_rescan_delay"));
 		while (true) {
 			if (path_lock(cfg_gets("wal_dir"), &wal_dir_lock)) {
-				recovery_stop_local(recovery);
+				recovery_stop_local_xc(recovery);
 				diag_raise();
 			}
 			if (wal_dir_lock >= 0)
 				break;
 			fiber_sleep(0.1);
 		}
-		if (recovery_stop_local(recovery))
-		    diag_raise();
-		if (recover_remaining_wals(recovery, &wal_stream.base, NULL, true) != 0)
-			diag_raise();
+		recovery_stop_local_xc(recovery);
+		recover_remaining_wals_xc(recovery, &wal_stream.base, NULL, true);
 		/*
 		 * Advance replica set vclock to reflect records
 		 * applied in hot standby mode.
@@ -2320,8 +2313,7 @@ local_recovery(const struct tt_uuid *instance_uuid,
 		box_sync_replication(false);
 	}
 
-	if (recovery_finalize(recovery) != 0)
-		diag_raise();
+	recovery_finalize_xc(recovery);
 
 	/*
 	 * We must enable WAL before finalizing engine recovery,
-- 
2.20.1

  parent reply	other threads:[~2020-04-28 16:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 16:11 [Tarantool-patches] [PATCH 00/17] recovery: move from cxx to c code Cyrill Gorcunov
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 01/17] recovery: do not call recovery_stop_local inside recovery_delete Cyrill Gorcunov
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 02/17] recovery: convert WalSubscription class to structure Cyrill Gorcunov
2020-05-03 18:42   ` Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 03/17] recovery: recovery_close_log -- don't throw exception Cyrill Gorcunov
2020-05-03 18:43   ` Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 04/17] recovery: recovery_open_log " Cyrill Gorcunov
2020-05-03 18:43   ` Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 05/17] recovery: recover_xlog " Cyrill Gorcunov
2020-05-03 18:44   ` Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 06/17] recovery: recover_remaining_wals " Cyrill Gorcunov
2020-05-03 18:44   ` Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 07/17] recovery: hot_standby_f " Cyrill Gorcunov
2020-05-03 18:45   ` Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 08/17] recovery: recovery_follow_local " Cyrill Gorcunov
2020-05-03 18:46   ` Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 09/17] recovery: recovery_new " Cyrill Gorcunov
2020-05-03 18:47   ` Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 10/17] recovery: recovery_scan " Cyrill Gorcunov
2020-05-03 18:47   ` Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 11/17] recovery: recovery_finalize " Cyrill Gorcunov
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 12/17] recovery: recovery_stop_local " Cyrill Gorcunov
2020-05-03 18:47   ` Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 13/17] recovery: cxx to c transition Cyrill Gorcunov
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 14/17] recovery: drop redundant type_XlogGapError Cyrill Gorcunov
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 15/17] recovery: provide throwable wrappers Cyrill Gorcunov
2020-04-28 16:11 ` Cyrill Gorcunov [this message]
2020-05-03 18:47   ` [Tarantool-patches] [PATCH 16/17] box: use _xc helpers of recovery code Vladislav Shpilevoy
2020-04-28 16:11 ` [Tarantool-patches] [PATCH 17/17] relay: use _xc recovery helpers Cyrill Gorcunov
2020-04-28 16:24 ` [Tarantool-patches] [PATCH 01/17] recovery: do not call recovery_stop_local inside recovery_delete Cyrill Gorcunov

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=20200428161137.20536-17-gorcunov@gmail.com \
    --to=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 16/17] box: use _xc helpers of recovery code' \
    /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