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 AEBB56E200; Fri, 18 Jun 2021 13:31:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AEBB56E200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1624012314; bh=jLhnD7fwsW6mO8ARC5IIg+CiK7N6+5XNjWIfe/qrWTo=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=BJlYEAbV3aVWhjY11TjUIl+saR84p7wkm6YsW/O5pd4Q6ovhsj8iZktklUPIElqac Z4C/O9YsCg2FjpyymjLNbVXorEVx1Iufj/E7JtE6niV5zyu76F3bSZaI6O66BASBec xlyVMQfHGcxkXc+FN9NnrvSUSiWKK/P6of0DM0qw= Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 65A766E200 for ; Fri, 18 Jun 2021 13:31:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 65A766E200 Received: by mail-lj1-f176.google.com with SMTP id g13so3000075ljj.10 for ; Fri, 18 Jun 2021 03:31:53 -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=MPaaY6rj1PfjkpfND3unlRph41hvH1VtTDNROSDxTcM=; b=J2ctQYAB+V0xgk7CeQOC64KJnPWlVmR+PH7G7j2q+Bb+YCjIhgHUYOdOn2zVTyEHqL uAPQ0u5pgVnuq95rHPKUlIyeL8B6kPKYf+zRxNeJDsgypB6PYWOJfD1EosUu6aU2NHU2 erRXXPhsKVURCKxlwuC8AVq4xTaqfbXB2oIjXCxHfLliMQqiHFKdnGKx3UFVD8UCl+T0 mLhJiYci9tTcEtJaSnjXh25lrx0fX9f+VKcyLysRdXnowU9iJqH7DWnO+8Z8+9viGtzi PqXbiPZrXSQqVCYUGzphc4B75QQcx6fHCQP61z5cL9ID5ttepMgJyf5dHU/k74L2cNr/ 9EkQ== X-Gm-Message-State: AOAM533o6u3VZ8Wdh/dQHOwpOQV2EZe3WNQ2DL1tglc49p3vxZtW82kx FJlXT0QDfd7lOJjo6WqxFXheLPn4A+s= X-Google-Smtp-Source: ABdhPJx7nl+eA62mfYvHbPHOGEiwPA4u3zQnnT4/3KzYcMNI77sgqf0j8h9WraA581sxqkeLUEmzaA== X-Received: by 2002:a2e:9999:: with SMTP id w25mr8916141lji.469.1624012312166; Fri, 18 Jun 2021 03:31:52 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id 29sm461237lfr.131.2021.06.18.03.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 03:31:50 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id B797D5A002A; Fri, 18 Jun 2021 13:31:49 +0300 (MSK) Date: Fri, 18 Jun 2021 13:31:49 +0300 To: Serge Petrenko Cc: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.7 (2021-05-04) Subject: Re: [Tarantool-patches] [PATCH v2 2/8] txn_limbo: fix promote term filtering 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Fri, Jun 18, 2021 at 12:07:36AM +0300, Serge Petrenko wrote: > txn_limbo_process() used to filter out promote requests whose term was > equal to the greatest term seen. This wasn't correct for PROMOTE entries > with term 1. > > Such entries appear after box.ctl.promote() is issued on an instance > with disabled elections. Every PROMOTE entry from such an instance has > term 1, but should still be applied. Fix this in the patch. > > Also, when an outdated PROMOTE entry with term smaller than already > applied from some replica arrived, it wasn't filtered at all. Such a > situation shouldn't be possible, but fix it as well. > > Part-of #6034 > --- > src/box/txn_limbo.c | 22 +++++++++++++--------- > 1 file changed, 13 insertions(+), 9 deletions(-) > > diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c > index 51dc2a186..a5d1df00c 100644 > --- a/src/box/txn_limbo.c > +++ b/src/box/txn_limbo.c > @@ -665,17 +665,21 @@ txn_limbo_process(struct txn_limbo *limbo, const struct synchro_request *req) > { > uint64_t term = req->term; > uint32_t origin = req->origin_id; > - if (txn_limbo_replica_term(limbo, origin) < term) { > + if (txn_limbo_replica_term(limbo, origin) < term) > vclock_follow(&limbo->promote_term_map, origin, term); > - if (term > limbo->promote_greatest_term) { > - limbo->promote_greatest_term = term; > - } else if (req->type == IPROTO_PROMOTE) { > - /* > - * PROMOTE for outdated term. Ignore. > - */ > - return; > - } > + > + if (term > limbo->promote_greatest_term) { > + limbo->promote_greatest_term = term; > + } else if (req->type == IPROTO_PROMOTE && > + limbo->promote_greatest_term > 1) { > + /* PROMOTE for outdated term. Ignore. */ > + say_info("RAFT: ignoring PROMOTE request from instance " > + "id %"PRIu32" for term %"PRIu64". Greatest term seen " > + "before (%"PRIu64") is bigger.", origin, term, > + limbo->promote_greatest_term); > + return; > } Serge, here is a moment I don't understand. The promote_term_map and promote_greatest_term both are zero initially, then we start accepting requests from the net and previously we've been updating promote_term_map and promote_greatest_term in same context, iow promote_term_map is filtering incoming traffic and update promote_greatest_term with max from promote_term_map, thus we can denote it as if (term > promote_term_map[i]) { promote_term_map[i] = term; promote_greatest_term = max(promote_greatest_term, term); } thus promote_greatest_term always = max({promote_term_map[i]}), so I don't understart why say 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) limbo->promote_greatest_term = term; } if (iproto_type_is_promote_request(req->type) && limbo->promote_greatest_term > 1) { /* PROMOTE for outdated term. Ignore. */ say_info("RAFT: ignoring %s request from instance " "id %"PRIu32" for term %"PRIu64". Greatest term seen " "before (%"PRIu64") is bigger.", iproto_type_name(req->type), origin, term, limbo->promote_greatest_term); return; } won't do the trick? Do I miss something obvious here?