From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 1/2] Revert "replication: update replica gc state on subscribe" Date: Tue, 9 Apr 2019 20:07:10 +0300 Message-Id: <24d1ce5202869981a2182ff1c7947d7d4914bb5b.1554829366.git.vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: This reverts commit b5b4809cf2e6d48230eb9e4301eac188b080e0f4. The commit reverted by this patch made relay advance the consumer associated with a replica right on subscribe. This is wrong, because the current implementation of the garbage collector operates on vclock signatures so that if a replica reconnects with a greater signature than it had when it last disconnected (e.g. due to replica local changes or changes pulled from other members of the cluster), the garbage collector may delete WAL files still needed by the replica, breaking replication. There are two ways to fix this problem. The first and the most difficult way is to teach the garbage collector to work with vclocks, i.e. rather than simply sorting all consumers by signature and using the smallest signature for garbage collection, maintain a vclock each component of which is the minimum among corresponding components of all registered consumers. The second (easy) way is to advance a consumer only if its acknowledged vclock is greater than or equal to the vclock of a WAL fed to it. This way the garbage collector still works with vclock signatures and it's a responsibility of the caller (i.e. relay) to ensure that consumers are advanced correctly. I took on the second way for now, because I couldn't figure out an efficient way to implement the first. This implies reverting the above mentioned commit and reopening #4034 - sporadic replication/gc.test.lua failure - which will have to be fixed some other way. See the next patch for the rest of the fix and the test. Needed for #4106 --- https://github.com/tarantool/tarantool/issues/4034 https://github.com/tarantool/tarantool/issues/4106 https://github.com/tarantool/tarantool/commits/dv/gh-4106-replica-gc-fix src/box/relay.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/box/relay.cc b/src/box/relay.cc index 45cd780a..29570323 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -643,16 +643,13 @@ 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 or subscribe. Otherwise update the consumer - * state with the current replica vclock. + * join. */ 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