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 CF8DC6EC5D; Fri, 2 Apr 2021 01:24:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CF8DC6EC5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617315861; bh=vU0e9NJBLYhx2uEt5n06X9ehuZ0o9SpocHbw9CSvwnU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=AMih6KAJ7B4JTY8c/YttBLD0m4ghfUiJerQoYxvWezFuX/L/1YItnNuKgsmrZgTMH yKMn/ftF4H7b5ZhHPNIzWQP5D88PPharC7UKmm2Ad4yjz3RKXtQ2Ylm0ls89Icflsn GVEwEvPvUc4eBQSG+PEnCIivzEoI76F44YPgT5I0= Received: from smtp37.i.mail.ru (smtp37.i.mail.ru [94.100.177.97]) (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 E04056EC5E for ; Fri, 2 Apr 2021 01:23:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E04056EC5E Received: by smtp37.i.mail.ru with esmtpa (envelope-from ) id 1lS5j7-0003d7-V5; Fri, 02 Apr 2021 01:23:46 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org, korablev@tarantool.org Date: Fri, 2 Apr 2021 00:23:42 +0200 Message-Id: <39bfed3293d262592e646eb4ca6c60f5022eac26.1617315744.git.v.shpilevoy@tarantool.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9ED7173E37F4E32947A0146560F8BA709498CFB6209D8582A182A05F5380850401F8DC7DFB7CC9737C91F5DB7086D0A8C8F4CB24629F643E0DE5AA19B185F4B96 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE704BA85F3D5A9F85BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637389D8DDD54F43F7A8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C7B5A45DDF210A4CFEB908C3832244C523398C18A126FC9B2A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE746CC513BB44FBA1D9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3CCD831CA19E60C96117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CF40FAC5EC76AA758DBA3038C0950A5D36C8A9BA7A39EFB766EC990983EF5C0329BA3038C0950A5D36D5E8D9A59859A8B6505D71D783575ABE3AA81AA40904B5D9DBF02ECDB25306B2201CA6A4E26CD07C3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735F43AACC0BCEB2632C4224003CC83647689D4C264860C145E X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824AC8B6CDF511875BC4E8F7B195E1C978312B5887271788A049B139F1DD504E1C03 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7A503204626CAB286D086D530315DB7364CB5D8FFC0BF8D8D0B1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB63AF70AF8205D7DCDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34C1E32F4AD4B2486BC702F3A666A5F8B7E5F4BC2FF9F38AAB7BA737A0A623C90C2AC19A518D77882F1D7E09C32AA3244C2F1612E7D4F8F4659427BBE28226148905AB220A9D022EBC927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojiysexgWf334qE4vSl6HKEA== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110FD186DCADF05FF8BB5D7BE40CD7BF96103398DA765328D7F07784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH 1/3] vinyl: handle multi-statement recovery txns 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" During recovery and xlog replay vinyl skips the statements already stored in runs. Indeed, their re-insertion into the mems would lead to their second dump otherwise. But that results into an issue that the recovery transactions in vinyl don't have a write set - their tx->log is empty. On the other hand they still are added to the write set (xm->writers). Probably so as not to have too many checks "skip if in recovery" all over the code. It works fine with single-statement transactions, but would break on multi-statement transactions. Because the decision whether need to add to the write set was done based on the tx's log emptiness. It is always empty, and so the transaction could be added to the write set twice and corrupt its list-link member. The patch makes the decision about being added to the write set based on emptiness of the list-link member instead of the log so it works fine both during recovery and normal operation. Needed for #5874 --- src/box/vy_tx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c index ff63cd7a1..cd210beb0 100644 --- a/src/box/vy_tx.c +++ b/src/box/vy_tx.c @@ -899,8 +899,15 @@ vy_tx_begin_statement(struct vy_tx *tx, struct space *space, void **savepoint) } assert(tx->state == VINYL_TX_READY); tx->last_stmt_space = space; - if (stailq_empty(&tx->log)) + /* + * When want to add to the writer list, can't rely on the log emptiness. + * During recovery it is empty always for the data stored both in runs + * and xlogs. Must check the list member explicitly. + */ + if (rlist_empty(&tx->in_writers)) { + assert(stailq_empty(&tx->log)); rlist_add_entry(&tx->xm->writers, tx, in_writers); + } *savepoint = stailq_last(&tx->log); return 0; } -- 2.24.3 (Apple Git-128)