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 C25D06FC8F; Thu, 25 Mar 2021 14:25:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C25D06FC8F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616671526; bh=vkCeIkhwA8czZ7wOR3Xf7GWcp5yvGYm74MFtN5VVlro=; 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=WnKNIs+oBrQtB6tBZ1RKPy7LWBAPxYhZSJhhNZidEOeGaaiYTENyB7JpA0skW6lY1 TQUMsX9kkOcv0LBe34zwjURGIxSrgJyCoEaIeQCbkX/1ETAYjYsXAlgcTi3Q/sIssJ /R0bn3+6qoeZN5GeHkixjl4UecZBtf7n44fqV4/Y= Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 9525C6FC8F for ; Thu, 25 Mar 2021 14:25:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9525C6FC8F Received: by mail-lf1-f51.google.com with SMTP id b14so1955962lfv.8 for ; Thu, 25 Mar 2021 04:25:25 -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=sHxJez8cgoNxcsH/SwkjKVLznVBEFlhKW8Htn4ba8IU=; b=bAp8LIAy5Do4V+7pyYc+T360w/3wDeq6oFBOxO5E7x5Zf6JHGYysIYDCUC6l5QQb7Z AWrQixRy/PXXLVoY5jTaNuvhbln+DlwetEwaXiu7oSPGEDuWUPsd5qpNyrwFtqodtKEi bY/C4CxKmY5PvoT8M2lYlsl08N22cMDd2zHunOPg1aewXa2Pa1Q1jDC5b6W1zULK4pqU oWCh0cUs14Ha+cPBGip2ZvF4cbW13ap9gAtLLev1roThpVsap8NfD4B1dsfMdGBzIg4H /hZoO9maRAQnGYi1hYE+apxmgMNX01Mx9TG/xsCQy5PnM63BR89GAQt/BJFxpRYZqezg 8kRA== X-Gm-Message-State: AOAM532PXavYfDD/dL6N1nMM5y142DFFXZzvXND/IozPt6wnWdM08PVn bT6Qcp4AT1VjWaKA9RvE8jghUz1E5oH6qg== X-Google-Smtp-Source: ABdhPJzIDNU76AM7v55JiSS0xr9oOiqdg5/9uMlWCmklSiS1kIULPuQXd05yojIefqZBohT0gr5Q6g== X-Received: by 2002:ac2:46d6:: with SMTP id p22mr4520028lfo.625.1616671524451; Thu, 25 Mar 2021 04:25:24 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id m21sm713928ljp.79.2021.03.25.04.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 04:25:23 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id B9C5156017D; Thu, 25 Mar 2021 14:25:22 +0300 (MSK) Date: Thu, 25 Mar 2021 14:25:22 +0300 To: Vladislav Shpilevoy Message-ID: References: <20210324163759.1900553-1-gorcunov@gmail.com> <20210324163759.1900553-2-gorcunov@gmail.com> <8faa2e1e-c198-832d-d527-1acf2280720d@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8faa2e1e-c198-832d-d527-1acf2280720d@tarantool.org> User-Agent: Mutt/2.0.5 (2021-01-21) Subject: Re: [Tarantool-patches] [PATCH v4 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: tml Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Wed, Mar 24, 2021 at 11:10:11PM +0100, Vladislav Shpilevoy wrote: > > + if (gc.is_paused) { > > + double start_time = fiber_clock(); > > + while (!fiber_is_cancelled()) { > > + double deadline = start_time + gc.wal_cleanup_delay; > > + double timeout = gc.wal_cleanup_delay; > > 2. You didn't fix it really. Just that now the timeout is taken > fresh from the config still making it possible to go beyond the > deadline. > > The fact that fiber_clock() < deadline does not mean that > fiber_clock() + timeout is also < deadline. You need to calculate > the timeout properly and try to cover it with a test. Here is an update on top. I see a few red tests on our github actions but still trying to figure out what is happening, since I've been passing the tests on my local instance --- diff --git a/src/box/box.cc b/src/box/box.cc index a269f7357..ab298d223 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -774,10 +774,18 @@ box_check_wal_queue_max_size(void) static double box_check_wal_cleanup_delay(void) { + const double MAX_TIMEOUT = TIMEOUT_INFINITY; + const double MIN_TIMEOUT = 0.001; + double value = cfg_getd("wal_cleanup_delay"); - if (value < 0) { + if (value < 0 || (value != 0 && value < MIN_TIMEOUT) || + value > MAX_TIMEOUT) { + char message[64]; + snprintf(message, sizeof(message), + "the value must be 0 or in range [%g; %g]", + MIN_TIMEOUT, TIMEOUT_INFINITY); diag_set(ClientError, ER_CFG, "wal_cleanup_delay", - "the value must be >= 0"); + message); return -1; } @@ -1488,8 +1496,8 @@ box_set_wal_cleanup_delay(void) return -1; /* * Anonymous replicas do not require - * delay the cleanup procedure since they - * are read only. + * delay since they can't be a source + * of replication. */ if (replication_anon) delay = 0; diff --git a/src/box/gc.c b/src/box/gc.c index 8dbcbcede..10f899923 100644 --- a/src/box/gc.c +++ b/src/box/gc.c @@ -251,12 +251,9 @@ gc_cleanup_fiber_f(va_list ap) */ if (gc.is_paused) { double start_time = fiber_clock(); + double timeout = gc.wal_cleanup_delay; while (!fiber_is_cancelled()) { - double deadline = start_time + gc.wal_cleanup_delay; - double timeout = gc.wal_cleanup_delay; - - if (fiber_clock() >= deadline || - fiber_yield_timeout(timeout)) { + if (fiber_yield_timeout(timeout)) { say_info("wal/engine cleanup is resumed " "due to timeout expiration"); gc.is_paused = false; @@ -272,6 +269,19 @@ gc_cleanup_fiber_f(va_list ap) say_info("wal/engine cleanup is resumed"); break; } + + /* + * Woken up to update the timeout. + */ + double elapsed = fiber_clock() - start_time; + if (elapsed >= gc.wal_cleanup_delay) { + say_info("wal/engine cleanup is resumed " + "due to timeout manual update"); + gc.is_paused = false; + gc.delay_ref = 0; + break; + } + timeout = gc.wal_cleanup_delay - elapsed; } }