Tarantool development patches archive
 help / color / mirror / Atom feed
From: Ilya Kosarev <i.kosarev@tarantool.org>
To: tarantool-patches@dev.tarantool.org
Cc: v.shpilevoy@tarantool.org
Subject: [Tarantool-patches] [PATCH v3 2/4] replication: fix appliers pruning
Date: Mon, 25 Nov 2019 14:50:07 +0300	[thread overview]
Message-ID: <dc34ddbf6d14ab70811a5fbf4c562e79507fa393.1574681299.git.i.kosarev@tarantool.org> (raw)
In-Reply-To: <cover.1574681299.git.i.kosarev@tarantool.org>
In-Reply-To: <cover.1574681299.git.i.kosarev@tarantool.org>

During pruning of appliers some anon replicas might connect
from replicaset_follow called in another fiber. Therefore we need to
prune appliers of anon replicas first and, moreover, prune them one by
one instead of iterating them, as far as any of them might connect
while we are stopping the other one and it will break iteration.

Part of #4586
Closes #4643
---
 src/box/replication.cc | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/box/replication.cc b/src/box/replication.cc
index 509187cd3..f15e51f4d 100644
--- a/src/box/replication.cc
+++ b/src/box/replication.cc
@@ -516,23 +516,25 @@ replicaset_update(struct applier **appliers, int count)
 	 */
 
 	/* Prune old appliers */
-	replicaset_foreach(replica) {
-		if (replica->applier == NULL)
-			continue;
+	while (!rlist_empty(&replicaset.anon)) {
+		replica = rlist_first_entry(&replicaset.anon,
+					    typeof(*replica), in_anon);
 		applier = replica->applier;
 		replica_clear_applier(replica);
-		replica->applier_sync_state = APPLIER_DISCONNECTED;
+		rlist_del_entry(replica, in_anon);
+		replica_delete(replica);
 		applier_stop(applier);
 		applier_delete(applier);
 	}
-	rlist_foreach_entry_safe(replica, &replicaset.anon, in_anon, next) {
+	replicaset_foreach(replica) {
+		if (replica->applier == NULL)
+			continue;
 		applier = replica->applier;
 		replica_clear_applier(replica);
-		replica_delete(replica);
+		replica->applier_sync_state = APPLIER_DISCONNECTED;
 		applier_stop(applier);
 		applier_delete(applier);
 	}
-	rlist_create(&replicaset.anon);
 
 	/* Save new appliers */
 	replicaset.applier.total = count;
-- 
2.17.1

  parent reply	other threads:[~2019-11-25 11:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-25 11:50 [Tarantool-patches] [PATCH v3 0/4] fix box_set_replication issues & stabilize quorum test Ilya Kosarev
2019-11-25 11:50 ` [Tarantool-patches] [PATCH v3 1/4] test: update test-run Ilya Kosarev
2019-11-25 11:50 ` Ilya Kosarev [this message]
2019-11-25 11:50 ` [Tarantool-patches] [PATCH v3 3/4] replication: make anon replicas iteration safe Ilya Kosarev
2019-11-25 11:50 ` [Tarantool-patches] [PATCH v3 4/4] test: stabilize quorum test conditions Ilya Kosarev
2019-11-25 23:04 ` [Tarantool-patches] [PATCH v3 0/4] fix box_set_replication issues & stabilize quorum test Vladislav Shpilevoy
2019-12-02 11:47 ` Kirill Yukhin

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=dc34ddbf6d14ab70811a5fbf4c562e79507fa393.1574681299.git.i.kosarev@tarantool.org \
    --to=i.kosarev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v3 2/4] replication: fix appliers pruning' \
    /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