Skip to content

Commit

Permalink
replication: update replica gc state on subscribe
Browse files Browse the repository at this point in the history
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
  • Loading branch information
locker committed Mar 13, 2019
1 parent 19fb728 commit b5b4809
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/box/relay.cc
Expand Up @@ -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);
Expand Down

0 comments on commit b5b4809

Please sign in to comment.