[Tarantool-patches] [PATCH v4 07/12] raft: filter rows based on known peer terms
Serge Petrenko
sergepetrenko at tarantool.org
Tue Apr 20 23:29:50 MSK 2021
16.04.2021 19:25, Serge Petrenko пишет:
> Start writing the actual leader term together with the PROMOTE request
> and process terms in PROMOTE requests on receiver side.
>
> Make applier only apply synchronous transactions from the instance which
> has the greatest term as received in PROMOTE requests.
>
> Closes #5445
>
A couple of fixes on top:
Only apply PROMOTE when it's for a greater term than already received.
If promote tries to confirm entries for instance id other than
limbo->owner_id
rollback everything that's unconfirmed.
=========================================
diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c
index 14e87cd3d..5f72c891f 100644
--- a/src/box/txn_limbo.c
+++ b/src/box/txn_limbo.c
@@ -643,14 +643,21 @@ complete:
}
void
-txn_limbo_process(struct txn_limbo *limbo, const struct synchro_request
*req)
+txn_limbo_process(struct txn_limbo *limbo, struct synchro_request *req)
{
uint64_t term = req->term;
uint32_t origin = req->origin_id;
if (txn_limbo_replica_term(limbo, origin) < term) {
vclock_follow(&limbo->promote_term_map, origin, term);
- if (term > limbo->promote_greatest_term)
+ if (term > limbo->promote_greatest_term) {
limbo->promote_greatest_term = term;
+ } else if (req->type == IPROTO_PROMOTE) {
+ /*
+ * PROMOTE for an old term should be ignored.
+ * For CONFIRM and ROLLBACK term is unused.
+ */
+ return;
+ }
}
if (req->replica_id == REPLICA_ID_NIL) {
/*
@@ -665,7 +672,15 @@ txn_limbo_process(struct txn_limbo *limbo, const
struct synchro_request *req)
* data from an old leader, who has just started and
written
* confirm right on synchronous transaction recovery.
*/
- return;
+ if (req->type != IPROTO_PROMOTE) {
+ return;
+ } else {
+ /*
+ * A PROMOTE request for a foreign master - roll
back
+ * everyting in limbo.
+ */
+ req->lsn = 0;
+ }
}
switch (req->type) {
case IPROTO_CONFIRM:
diff --git a/src/box/txn_limbo.h b/src/box/txn_limbo.h
index e409ac657..a06fabccc 100644
--- a/src/box/txn_limbo.h
+++ b/src/box/txn_limbo.h
@@ -302,7 +302,7 @@ txn_limbo_wait_complete(struct txn_limbo *limbo,
struct txn_limbo_entry *entry);
/** Execute a synchronous replication request. */
void
-txn_limbo_process(struct txn_limbo *limbo, const struct synchro_request
*req);
+txn_limbo_process(struct txn_limbo *limbo, struct synchro_request *req);
/**
* Waiting for confirmation of all "sync" transactions
===========================================
--
Serge Petrenko
More information about the Tarantool-patches
mailing list