@@ -4329,6 +4329,26 @@ box_process_fetch_snapshot(struct iostream *io,
4329
4329
coio_write_xrow (io, &row);
4330
4330
}
4331
4331
4332
+ /* *
4333
+ * Replica vclock is used in gc state and recovery initialization - need to
4334
+ * replace the remote 0-th component with the own one. This doesn't break
4335
+ * recovery: it finds the WAL with a vclock strictly less than replia clock in
4336
+ * all components except the 0th one.
4337
+ *
4338
+ * Note, that it would be bad to set 0-th component to a smaller value (like
4339
+ * zero) - it would unnecessarily require additional WALs, which may have
4340
+ * already been deleted.
4341
+ *
4342
+ * Speaking of gc, remote instances' local vclock components are not used by
4343
+ * consumers at all.
4344
+ */
4345
+ static void
4346
+ box_localize_vclock (const struct vclock *remote, struct vclock *local)
4347
+ {
4348
+ vclock_copy (local, remote);
4349
+ vclock_reset (local, 0 , vclock_get (&replicaset.vclock , 0 ));
4350
+ }
4351
+
4332
4352
void
4333
4353
box_process_register (struct iostream *io, const struct xrow_header *header)
4334
4354
{
@@ -4385,10 +4405,10 @@ box_process_register(struct iostream *io, const struct xrow_header *header)
4385
4405
" wal_mode = 'none'" );
4386
4406
}
4387
4407
4388
- /* @sa box_process_subscribe(). */
4389
- vclock_reset (&req.vclock , 0 , vclock_get (&replicaset. vclock , 0 ) );
4408
+ struct vclock start_vclock;
4409
+ box_localize_vclock (&req.vclock , &start_vclock );
4390
4410
struct gc_consumer *gc = gc_consumer_register (
4391
- &req. vclock , " replica %s" , tt_uuid_str (&req.instance_uuid ));
4411
+ &start_vclock , " replica %s" , tt_uuid_str (&req.instance_uuid ));
4392
4412
if (gc == NULL )
4393
4413
diag_raise ();
4394
4414
auto gc_guard = make_scoped_guard ([&] { gc_consumer_unregister (gc); });
@@ -4405,13 +4425,12 @@ box_process_register(struct iostream *io, const struct xrow_header *header)
4405
4425
/* Remember master's vclock after the last request */
4406
4426
struct vclock stop_vclock;
4407
4427
vclock_copy (&stop_vclock, &replicaset.vclock );
4408
-
4409
4428
/*
4410
- * Feed replica with WALs in range
4411
- * (req.vclock, stop_vclock) so that it gets its
4412
- * registration.
4429
+ * Feed replica with WALs up to the REGISTER itself so that it gets own
4430
+ * registration entry.
4413
4431
*/
4414
- relay_final_join (replica, io, header->sync , &req.vclock , &stop_vclock);
4432
+ relay_final_join (replica, io, header->sync , &start_vclock,
4433
+ &stop_vclock);
4415
4434
say_info (" final data sent." );
4416
4435
4417
4436
RegionGuard region_guard (&fiber ()->gc );
@@ -4692,6 +4711,8 @@ box_process_subscribe(struct iostream *io, const struct xrow_header *header)
4692
4711
tnt_raise (ClientError, ER_UNSUPPORTED, " Replication" ,
4693
4712
" wal_mode = 'none'" );
4694
4713
}
4714
+ struct vclock start_vclock;
4715
+ box_localize_vclock (&req.vclock , &start_vclock);
4695
4716
/*
4696
4717
* Send a response to SUBSCRIBE request, tell
4697
4718
* the replica how many rows we have in stock for it,
@@ -4743,23 +4764,6 @@ box_process_subscribe(struct iostream *io, const struct xrow_header *header)
4743
4764
coio_write_xrow (io, &row);
4744
4765
sent_raft_term = req.term ;
4745
4766
}
4746
- /*
4747
- * Replica vclock is used in gc state and recovery
4748
- * initialization, so we need to replace the remote 0-th
4749
- * component with our own one. This doesn't break
4750
- * recovery: it finds the WAL with a vclock strictly less
4751
- * than replia clock in all components except the 0th one.
4752
- * This leads to finding the correct WAL, if it exists,
4753
- * since we do not need to recover local rows (the ones,
4754
- * that contribute to the 0-th vclock component).
4755
- * Note, that it would be bad to set 0-th vclock component
4756
- * to a smaller value, since it would unnecessarily
4757
- * require additional WALs, which may have already been
4758
- * deleted.
4759
- * Speaking of gc, remote instances' local vclock
4760
- * components are not used by consumers at all.
4761
- */
4762
- vclock_reset (&req.vclock , 0 , vclock_get (&replicaset.vclock , 0 ));
4763
4767
/*
4764
4768
* Process SUBSCRIBE request via replication relay
4765
4769
* Send current recovery vector clock as a marker
@@ -4772,7 +4776,7 @@ box_process_subscribe(struct iostream *io, const struct xrow_header *header)
4772
4776
* a stall in updates (in this case replica may hang
4773
4777
* indefinitely).
4774
4778
*/
4775
- relay_subscribe (replica, io, header->sync , &req. vclock ,
4779
+ relay_subscribe (replica, io, header->sync , &start_vclock ,
4776
4780
req.version_id , req.id_filter , sent_raft_term);
4777
4781
}
4778
4782
0 commit comments