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 D89B86EC58; Wed, 26 May 2021 09:14:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D89B86EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622009669; bh=U3C7IjXcvcpVoewH+tVRHEMv7odmyJ5P6fqI3q/BP1w=; 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=OtA9xeHDMJn9Q6zL87pNArnZhU2Ze2yUReZq7R9t608Uy0tHnAKql7bBjAGEYbmDR qLehB5/fWWGF0F06DXTLA4BxUBLRUPfmM91AGoKEozvM1WVKBlv78pzjnuGhH7xLxI pRe4JnOBAYWaOi2wdKyXskbs/1MFgcaqZn6GeAks= Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 365676EC58 for ; Wed, 26 May 2021 09:14:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 365676EC58 Received: by mail-lf1-f48.google.com with SMTP id w33so777130lfu.7 for ; Tue, 25 May 2021 23:14:28 -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=ZzOSkVjBuMnXgUeW9qHSihrSG+XvcEzkFxJx06S+FMw=; b=mD4ZEKNGfhekYxVczFCfykwvxK9y0+8ysFoybOOJB0QcpsUyMtx9izD4d+sWT0LffX t1p+pghqgjUqejhWUrZ/0Ivxhl4fzAUkjePxChtPHiVXK0JmUQyx5SIcwWlEO9KfcAaF zPspL0bnVaKRKz6VKEZVZKlqObAO6KNosS1U/DNhwr1cj/RQ8dO3c+csD2SpE+5wUI/w FdMbxuV+vNUxLbOzq74zt5O5fM6lL3qSta8bFghynkf4JnF8K/e1I7pthNWkyBy51B40 Jwox0nQFgAIPBdCBzDuLg6emY4XaRJhA1zRhmortP1Wqg0xBNW1sPIbITxofXbFoSErd +3pg== X-Gm-Message-State: AOAM530RKr/q2JjBQMFnaO02+38IXhnzM9Tk4ZaOkk2CBOLsIzgR7fno amid1hbufoDmelrFY2Y+YMdiHur3PtE= X-Google-Smtp-Source: ABdhPJxSUK5jXLG2Lq934YUEBNg25Ul3Dr3eGqitYzBkCS3FzjkgbVw0dmxtRclVBLlyv21P7sOQHg== X-Received: by 2002:ac2:430f:: with SMTP id l15mr381891lfh.297.1622009666983; Tue, 25 May 2021 23:14:26 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id z23sm1931158lfq.241.2021.05.25.23.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 23:14:25 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 0345B5A003F; Wed, 26 May 2021 09:14:24 +0300 (MSK) Date: Wed, 26 May 2021 09:14:24 +0300 To: Serge Petrenko Cc: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org Message-ID: References: <8011f87bb9b5e1f53f5bee3124f3a8e9dbe1917c.1621935783.git.sergepetrenko@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8011f87bb9b5e1f53f5bee3124f3a8e9dbe1917c.1621935783.git.sergepetrenko@tarantool.org> User-Agent: Mutt/2.0.7 (2021-05-04) Subject: Re: [Tarantool-patches] [PATCH v2 2/2] box: fix an assertion failure in box.ctl.promote() 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 Tue, May 25, 2021 at 01:39:29PM +0300, Serge Petrenko wrote: > box.ctl.promote() used to assume that the last synchronous entry is > already written to WAL by the time it's called. This is not the case > when promote is executed on the limbo owner. The last synchronous entry > might still be en route to WAL. Typo "en" -> "in". > @@ -1618,14 +1618,29 @@ box_promote(void) > txn_limbo.owner_id); > return -1; > } > + if (txn_limbo_is_empty(&txn_limbo)) { > + wait_lsn = txn_limbo.confirmed_lsn; > + goto promote; > + } > } > > - /* > - * promote() is a no-op on the limbo owner, so all the rows > - * in the limbo must've come through the applier meaning they already > - * have an lsn assigned, even if their WAL write hasn't finished yet. > - */ > - wait_lsn = txn_limbo_last_synchro_entry(&txn_limbo)->lsn; > + struct txn_limbo_entry *last_entry; > + last_entry = txn_limbo_last_synchro_entry(&txn_limbo); > + /* Wait for the last entries WAL write. */ > + if (last_entry->lsn < 0) { > + if (wal_sync(NULL) < 0) > + return -1; > + if (txn_limbo_is_empty(&txn_limbo)) { > + wait_lsn = txn_limbo.confirmed_lsn; > + goto promote; > + } > + if (last_entry != txn_limbo_last_synchro_entry(&txn_limbo)) { This is a bit dangerous. We cache a pointer and then go to fiber_yield, which switches context, at this moment the pointer become dangling one and we simply can't be sure if it _were_ reused. IOW, Serge are we 100% sure that the same pointer with same address but with new data won't appear here as last entry in limbo? > + diag_set(ClientError, ER_QUORUM_WAIT, quorum, > + "new synchronous transactions appeared"); > + return -1; > + } > + } > + wait_lsn = last_entry->lsn; > assert(wait_lsn > 0);