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 84C876EC58; Wed, 26 May 2021 21:46:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 84C876EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622054783; bh=6+QEs8uksQJF4sm9hy1Dl0Cn4kJk9W+F6oppT/fPMqs=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=MZuMM1EIPmqEjj698Fm6yITgzFftPuqaF4ejrqbqZxaWUpfW0Y8rVg+YM3yJnLG4v BLIBM0E0vEYCBIKAMKkt5PkLfW7ZFV+ASShzUp2B7KRt0R2r64knKmCFarbnd4bEZM qrMKLsaRlH3VvXaB0qbFTrMhck+ivwWnS8clgw+A= Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [94.100.177.109]) (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 415636EC58 for ; Wed, 26 May 2021 21:46:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 415636EC58 Received: by smtp49.i.mail.ru with esmtpa (envelope-from ) id 1llyXt-0005nd-IK; Wed, 26 May 2021 21:46:21 +0300 To: Serge Petrenko , Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org References: <8011f87bb9b5e1f53f5bee3124f3a8e9dbe1917c.1621935783.git.sergepetrenko@tarantool.org> Message-ID: <3552b10e-370d-ddbd-11ed-8c3d5310e651@tarantool.org> Date: Wed, 26 May 2021 20:46:20 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9157EECD0FDB90B9A3C7FC6B53229AFE7CC4D706690F5628300894C459B0CD1B9D907FB2AC77AAB0E5C2F9913175CAC9509BDA8693C08D2623AAAE87D35EC1BE5 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B264C8851FD8E810EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063776672C316918EFDB8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D87895CA46382A67D236697B45C669D3AC117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC974A882099E279BDA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18E5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEF8AB6B2BE221812676E601842F6C81A12EF20D2F80756B5F7E9C4E3C761E06A776E601842F6C81A127C277FBC8AE2E8B7CAC66D8BE5E0CF13AA81AA40904B5D9DBF02ECDB25306B2201CA6A4E26CD07C3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735F43AACC0BCEB2632C4224003CC83647689D4C264860C145E X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24209795067102C07E8F7B195E1C97831E2A0B4C71D4F85F79BFD3320250DC888 X-C1DE0DAB: 0D63561A33F958A54DA88D5C75B2B5E0EED25E93F6C813E339DDF65CE623504CD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75E3127721F5A72C97410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A5BF8FA0BD61F99488A7605E5F728DE5FCA6604C586C84ACAB8989B7B43F625E99BB0951A2D4A4481D7E09C32AA3244C632E704960695CB8C9CDEBEB6BEACCED55E75C8D0ED9F6EEFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojiWl9RlzdedlfbkBKHWWyig== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110331DBC727A7CB781766C950344874AF968D90C4C532F6FD707784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" >>> @@ -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? > > I agree this solution is not perfect. > > An alternative would be to do the following: > 1) Check that the limbo owner hasn't changed > 2) Check that the last entry has positive lsn (e.g. it's not a new entry which >     wasn't yet written to WAL). And that this lsn is equal to the lsn of our entry. > > But what if our entry was confirmed and destroyed during wal_sync()? We can't compare > other entries lsn with this ones. As decided in the chat, you can use txn->id. It is unique until restart and should help to detect if the last transaction has changed.