Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH] replication: update replica gc state on subscribe
@ 2019-03-13 13:13 Vladimir Davydov
  2019-03-13 13:38 ` Vladimir Davydov
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Davydov @ 2019-03-13 13:13 UTC (permalink / raw)
  To: tarantool-patches

We advance replica->gc state only when an xlog file is fully recovered,
see recovery_close_log and relay_on_close_log_f. It may turn out that an
xlog file is fully recovered, but isn't closed properly by relay (i.e.
recovery_close_log isn't called), because the replica closes connection
for some reason (e.g. timeout). If this happens, the old xlog file
won't be removed when the replica reconnects, because we don't advance
replica->gc state on reconnect, so the useless xlog file won't be
removed until the next xlog file is relayed. This results in occasional
replication/gc.test.lua failures. Fix this by updating replica->gc on
reconnect with the current replica vclock.

Closes #4034
---
https://github.com/tarantool/tarantool/issues/4034
https://github.com/tarantool/tarantool/commits/dv/gh-4034-replication-update-gc-state-on-subscribe

 src/box/relay.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/box/relay.cc b/src/box/relay.cc
index 90fced24..945c01a5 100644
--- a/src/box/relay.cc
+++ b/src/box/relay.cc
@@ -637,13 +637,16 @@ relay_subscribe(struct replica *replica, int fd, uint64_t sync,
 	/*
 	 * Register the replica with the garbage collector
 	 * unless it has already been registered by initial
-	 * join.
+	 * join or subscribe. Otherwise update the consumer
+	 * state with the current replica vclock.
 	 */
 	if (replica->gc == NULL) {
 		replica->gc = gc_consumer_register(replica_clock, "replica %s",
 						   tt_uuid_str(&replica->uuid));
 		if (replica->gc == NULL)
 			diag_raise();
+	} else {
+		gc_consumer_advance(replica->gc, replica_clock);
 	}
 
 	relay_start(relay, fd, sync, relay_send_row);
-- 
2.11.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] replication: update replica gc state on subscribe
  2019-03-13 13:13 [PATCH] replication: update replica gc state on subscribe Vladimir Davydov
@ 2019-03-13 13:38 ` Vladimir Davydov
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Davydov @ 2019-03-13 13:38 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Alexander V. Tikhonov

On Wed, Mar 13, 2019 at 04:13:45PM +0300, Vladimir Davydov wrote:
> We advance replica->gc state only when an xlog file is fully recovered,
> see recovery_close_log and relay_on_close_log_f. It may turn out that an
> xlog file is fully recovered, but isn't closed properly by relay (i.e.
> recovery_close_log isn't called), because the replica closes connection
> for some reason (e.g. timeout). If this happens, the old xlog file
> won't be removed when the replica reconnects, because we don't advance
> replica->gc state on reconnect, so the useless xlog file won't be
> removed until the next xlog file is relayed. This results in occasional
> replication/gc.test.lua failures. Fix this by updating replica->gc on
> reconnect with the current replica vclock.
> 
> Closes #4034
> ---
> https://github.com/tarantool/tarantool/issues/4034
> https://github.com/tarantool/tarantool/commits/dv/gh-4034-replication-update-gc-state-on-subscribe
> 
>  src/box/relay.cc | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Alexander Tikhonov confirms that this patch fixes the test failure.
Pushed to 2.1.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-13 13:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13 13:13 [PATCH] replication: update replica gc state on subscribe Vladimir Davydov
2019-03-13 13:38 ` Vladimir Davydov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox