From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp16.mail.ru (smtp16.mail.ru [94.100.176.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 8DC54445320 for ; Tue, 21 Jul 2020 00:13:11 +0300 (MSK) References: <9a78892071bb44779f3bc21788b86b8c53a8ace5.1593899478.git.sergepetrenko@tarantool.org> <71f0e22e-b622-22c7-812d-d118d31cb2bc@tarantool.org> From: Vladislav Shpilevoy Message-ID: <0db23a8c-1507-d61e-7826-fabb3fd46515@tarantool.org> Date: Mon, 20 Jul 2020 23:13:09 +0200 MIME-Version: 1.0 In-Reply-To: <71f0e22e-b622-22c7-812d-d118d31cb2bc@tarantool.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [Tarantool-patches] [PATCH 2/2] box: introduce a cfg handle to become syncro leader List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Leonid Vasiliev , Serge Petrenko , gorcunov@gmail.com, sergos@tarantool.org Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for the review! >> diff --git a/src/box/box.cc b/src/box/box.cc >> index ca24b98ca..087710383 100644 >> --- a/src/box/box.cc >> +++ b/src/box/box.cc >> @@ -78,6 +78,7 @@ >>   #include "sequence.h" >>   #include "sql_stmt_cache.h" >>   #include "msgpack.h" >> +#include "trivia/util.h" >>     static char status[64] = "unknown"; >>   @@ -945,6 +946,84 @@ box_set_replication_anon(void) >>     } >>   +void >> +box_set_replication_synchro_leader(void) >> +{ >> +    bool is_leader = cfg_geti("replication_synchro_leader"); >> +    /* >> +     * For now no actions required when an instance stops >> +     * being a leader. We should probably wait until txn_limbo >> +     * becomes empty. >> +     */ >> +    if (!is_leader) >> +        return; >> +    uint32_t former_leader_id = txn_limbo.instance_id; >> +    if (former_leader_id == REPLICA_ID_NIL || >> +        former_leader_id == instance_id) { >> +        return; >> +    } >> + >> +    /* Wait until pending confirmations/rollbacks reach us. */ >> +    double timeout = 2 * txn_limbo_confirm_timeout(&txn_limbo); >> +    double start_tm = fiber_time(); >> +    while (!txn_limbo_is_empty(&txn_limbo)) { >> +        if (fiber_time() - start_tm > timeout) > > From the d988d7fb92fe1dda4b64218fb06813e93eb56ed1 commit comment: > " > ...use fiber_clock() instead of fiber_time() for timeouts > > fiber_time() reports real time, which shouldn't be used for calculating > timeouts as it is affected by system time changes. Add fiber_clock() > based on ev_monotonic_now(), export it to Lua, and use it instead. > ". Indeed. I've sent a patch fixing it.