From e2911d68e487dcb4ff40a5f94fa2713c8b3426c3 Mon Sep 17 00:00:00 2001 From: Dmitry Ivanov <ivadmi5@gmail.com> Date: Fri, 13 Sep 2024 23:48:53 +0300 Subject: [PATCH] feat: auto set box.cfg{checkpoint_enabled=false} on split-brain Split-brain detector might be triggered by complicated online cluster upgrades (e.g. "the quorum promote patch"), so we don't want to write inconsistent state to disk. If there's no inconsistent snapshot, the problem may go away once we restart the node with a newer version of Tarantool. NO_DOC=internal NO_TEST=internal NO_CHANGELOG=internal --- src/box/txn_limbo.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index 29bc3e3ada..41d90fd0d5 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -34,6 +34,7 @@ #include "iproto_constants.h" #include "journal.h" #include "box.h" +#include "gc.h" #include "raft.h" #include "tt_static.h" #include "session.h" @@ -1696,10 +1697,12 @@ int txn_limbo_req_prepare(struct txn_limbo *limbo, const struct synchro_request *req) { + struct error *e; + assert(latch_is_locked(&limbo->promote_latch)); if (txn_limbo_filter_generic(limbo, req) < 0) - return -1; + goto error; /* * Guard against new transactions appearing during WAL write. It is @@ -1717,7 +1720,7 @@ txn_limbo_req_prepare(struct txn_limbo *limbo, limbo->is_in_rollback = true; if (txn_limbo_filter_request(limbo, req) < 0) { limbo->is_in_rollback = false; - return -1; + goto error; } /* Prepare for request execution and fine-grained filtering. */ switch (req->type) { @@ -1727,6 +1730,16 @@ txn_limbo_req_prepare(struct txn_limbo *limbo, break; } return 0; + +error: + e = diag_last_error(diag_get()); + if (e->code == ER_SPLIT_BRAIN) { + say_warn("Disabling snapshots due to Split-Brain. " + "Use box.cfg{checkpoint_enabled = true} " + "to restore the default behavior."); + gc_set_checkpoint_enabled(false); + } + return -1; } void -- GitLab