From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 46D716FC8F; Tue, 23 Mar 2021 15:43:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 46D716FC8F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616503420; bh=TdIMRfaVk41ChY2oT+18GXvo0k+f3+GQXQk0i4G1i5M=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=npyUPC+E5jPywB1mflsgDt29Wm/DLOMF0R+9XqVJOAGvcWTEFjwjLQ+bXvh4U43I/ uUzZSQ5qyrIze7LLdsCKU4CXF5PHaEnWp4/6B2qagnl1MHIEmtK8AVKsf9s23X1OGp RY4+rNzKZwo+d+hJZ4UKcGX/5LhDE0VIdHl2cAXY= Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 8D37A6FC8F for ; Tue, 23 Mar 2021 15:43:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8D37A6FC8F Received: by mail-lj1-f177.google.com with SMTP id u20so25375785lja.13 for ; Tue, 23 Mar 2021 05:43:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=DPWckmz2VuxiBMgiTygi96ravrJNJBm0jylJSuoSIKs=; b=YVCuScsDanY1PGd4AphwvR+ULl6+1/GQIdiDOFuq2+/2lzoeeRiSsRIblX6F0u2+fJ jERk6zkh1sP0JcwSbzjQFvDdr6/PVGzx9bJv0dxjzBWryxHqrjOrMXj7rsnqRERR9ypf 98QVp9H60hN47gYHZuMIfPdzHwWs9TiGSJZU6RgnkNU4wZq9wlQbzZFBIiebTKgpSzbv /77hd0u9MebIjtZh5G/ov/x1pmK7sF7YrCXcZmkliqVQLQOFJJpXuZwPl4oX1DZwR040 R3tgYM1G8d0M7xIYnseePB9oFJSZs7nZ66zGLd5zSs8343kYUWwRtK836D2mEgggbxrH j6LA== X-Gm-Message-State: AOAM532YtKboCTqFHoC/C6FlV75Hi+LMH74iAlQAcAt+K74qijclheh+ 3P2HM18xL2Ix+G/WI7Pp4l2nQfpxROU= X-Google-Smtp-Source: ABdhPJxHyrGHGdaFOT3qMEtpCfg806pGLgUtOk3SjUMGsyPbl3lh1wqcKHypcWwOeYUeZWr8yEwE4w== X-Received: by 2002:a2e:730a:: with SMTP id o10mr3092705ljc.186.1616503419048; Tue, 23 Mar 2021 05:43:39 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id w1sm2317424ljw.14.2021.03.23.05.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 05:43:37 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id D532356017D; Tue, 23 Mar 2021 15:43:36 +0300 (MSK) Date: Tue, 23 Mar 2021 15:43:36 +0300 To: Vladislav Shpilevoy Message-ID: References: <20210320131521.1249747-1-gorcunov@gmail.com> <20210320131521.1249747-2-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.5 (2021-01-21) Subject: Re: [Tarantool-patches] [PATCH v2 1/3] gc/xlog: delay xlog cleanup until relays are subscribed X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Mons Anderson , tml Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Tue, Mar 23, 2021 at 02:25:26PM +0300, Cyrill Gorcunov wrote: > On Tue, Mar 23, 2021 at 10:28:46AM +0300, Cyrill Gorcunov wrote: > > > > > > > > Also you should use 'replication_anon' global variable instead > > > of the config, which might be not installed at this moment yet. > > > > What would happen if one setup both 'wal_cleanup_delay' and > > 'replication_anon' in config at once. Which C's replication_anon > > value I will be reading? The C's replication_anon is set after > > the cfg procedure complete, so since I operate on values obrained > > from Lua level I need to use cfg_geti("replication_anon") because > > at this moment only Lua level is consistent and replication_anon > > may have a value from previous box.cfg call. Here is a diff, take a look please. --- diff --git a/src/box/box.cc b/src/box/box.cc index b9fd7af00..81e001680 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -774,23 +774,13 @@ box_check_wal_queue_max_size(void) static double box_check_wal_cleanup_delay(void) { - double value = cfg_geti("wal_cleanup_delay"); + double value = cfg_getd("wal_cleanup_delay"); if (value < 0) { diag_set(ClientError, ER_CFG, "wal_cleanup_delay", "the value must be >= 0"); return -1; } - /* - * Anonymous replicas do not require - * delay the cleanup procedure since they - * are read only. - */ - if (cfg_geti("replication_anon") != 0) { - if (value != 0) - value = 0; - } - return value; } @@ -1496,6 +1486,13 @@ box_set_wal_cleanup_delay(void) double delay = box_check_wal_cleanup_delay(); if (delay < 0) return -1; + /* + * Anonymous replicas do not require + * delay the cleanup procedure since they + * are read only. + */ + if (replication_anon) + delay = 0; gc_set_wal_cleanup_delay(delay); return 0; } diff --git a/src/box/gc.c b/src/box/gc.c index 5418fd31d..e1d7a1187 100644 --- a/src/box/gc.c +++ b/src/box/gc.c @@ -46,7 +46,6 @@ #include #include -#include "cfg.h" #include "diag.h" #include "errcode.h" #include "fiber.h" @@ -253,10 +252,13 @@ gc_cleanup_fiber_f(va_list ap) * separate cycle to minimize branching on stage 2. */ if (gc.is_paused) { - ev_tstamp timeout = gc.wal_cleanup_delay; + double start_time = fiber_clock(); while (!fiber_is_cancelled()) { - ev_tstamp clock_start = fiber_clock(); - if (fiber_yield_timeout(timeout)) { + double deadline = start_time + gc.wal_cleanup_delay; + double timeout = gc.wal_cleanup_delay; + + if (fiber_clock() >= deadline || + fiber_yield_timeout(timeout)) { say_info("wal/engine cleanup is resumed " "due to timeout expiration"); gc.is_paused = false; @@ -270,17 +272,6 @@ gc_cleanup_fiber_f(va_list ap) */ if (!gc.is_paused) break; - - ev_tstamp elapsed = fiber_clock() - clock_start; - timeout = gc.wal_cleanup_delay - elapsed; - if (timeout <= 0) { - say_info("wal/engine cleanup is resumed " - "due to reconfigured timeout " - "expiration"); - gc.is_paused = false; - gc.delay_ref = 0; - break; - } } } diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua index 5ed8c12f0..44bb95ed1 100644 --- a/src/box/lua/load_cfg.lua +++ b/src/box/lua/load_cfg.lua @@ -352,6 +352,8 @@ local dynamic_cfg_order = { -- the new one. This should be fixed when box.cfg is able to -- apply some parameters together and atomically. replication_anon = 250, + -- Cleanup delay should be ignored if replication_anon is set. + wal_cleanup_delay = 260, election_mode = 300, election_timeout = 320, } @@ -384,7 +386,6 @@ local dynamic_cfg_skip_at_load = { replication_skip_conflict = true, replication_anon = true, wal_dir_rescan_delay = true, - wal_cleanup_delay = true, custom_proc_title = true, force_recovery = true, instance_uuid = true,