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 DC3CB6EC5A; Wed, 14 Jul 2021 21:31:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DC3CB6EC5A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1626287516; bh=ocXJKPB7l1hWdgSHv14gcs5BeeyXOfnN7TSO/Pn+sEI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Sd7js2xgRdy44iP/gp0j8iC8bDkhDthOHBU00ycokBwR/AITZgb+JGFbz4mkT4FPO A2e056c/tyTu8nWvoZBPCVETQXic8Fo2t0kWIRlrtAHy265j5605mUfzKlZVkErBa8 q0xiaNig88grfRRU6bdefq3axkEBLRtb2lvHHetg= Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (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 C27986F3CB for ; Wed, 14 Jul 2021 21:26:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C27986F3CB Received: by smtp58.i.mail.ru with esmtpa (envelope-from ) id 1m3jaE-0007Q7-1d; Wed, 14 Jul 2021 21:26:10 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Wed, 14 Jul 2021 21:25:40 +0300 Message-Id: X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD97BB0EF39AD2B33D598226807B8A1E9DC331E3F9997896515182A05F5380850407041D053DBE4B64685D0E5424B34F28414B8C85873771400BC467AA882FA0AF9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7990060B5002FF78EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B9ECF1867A781AFF8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8006623A23BC94E19BC09BD86230FE001117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B8C7ADC89C2F0B2A5A471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C0B02670E5FEECA50C4224003CC83647689D4C264860C145E X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CE68746B1F2AB10C66A0F6875B1A87FBE5EE41A8487D0F6CD9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF309DFB797F6729CB699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A2EC120135420F90A59CDF0E97E9645E0482B5FC5237C9598A9FBA44C65A16CDC0EF6798E237DEB81D7E09C32AA3244C9BE8CE4150C23FC1B8CC60BA6ED8869CD9ADFF0C0BDB8D1F927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojDdSFIg49M1QEwVyR2cgqtg== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A446DCF67A6ACA5D040DE49EA74FA49BDF59770536845BCBA975424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v4 12/16] box: fix an assertion failure after a spurious wakeup in 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: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Follow-up #3055 --- src/box/raft.c | 8 +++- .../gh-3055-promote-wakeup-crash.result | 43 +++++++++++++++++++ .../gh-3055-promote-wakeup-crash.test.lua | 20 +++++++++ test/replication/suite.cfg | 1 + 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 test/replication/gh-3055-promote-wakeup-crash.result create mode 100644 test/replication/gh-3055-promote-wakeup-crash.test.lua diff --git a/src/box/raft.c b/src/box/raft.c index b04932cd9..d16ec952a 100644 --- a/src/box/raft.c +++ b/src/box/raft.c @@ -344,13 +344,17 @@ box_raft_wait_leader_found(void) struct trigger trig; trigger_create(&trig, box_raft_wait_leader_found_f, fiber(), NULL); raft_on_update(box_raft(), &trig); - fiber_yield(); + + do { + fiber_yield(); + } while (box_raft()->is_enabled && !fiber_is_cancelled() && + box_raft()->leader == REPLICA_ID_NIL); + trigger_clear(&trig); if (fiber_is_cancelled()) { diag_set(FiberIsCancelled); return -1; } - assert(box_raft()->leader != REPLICA_ID_NIL || !box_raft()->is_enabled); return 0; } diff --git a/test/replication/gh-3055-promote-wakeup-crash.result b/test/replication/gh-3055-promote-wakeup-crash.result new file mode 100644 index 000000000..e508611e5 --- /dev/null +++ b/test/replication/gh-3055-promote-wakeup-crash.result @@ -0,0 +1,43 @@ +-- test-run result file version 2 +test_run = require('test_run').new() + | --- + | ... +-- +-- gh-3055 follow-up: box.ctl.promote() could crash on an assertion after a +-- spurious wakeup. +-- +_ = box.space._cluster:insert{2, require('uuid').str()} + | --- + | ... +box.cfg{election_mode='manual',\ + replication_synchro_quorum=2,\ + election_timeout=1000} + | --- + | ... + +fiber = require('fiber') + | --- + | ... +f = fiber.create(function() box.ctl.promote() end) + | --- + | ... +f:set_joinable(true) + | --- + | ... +f:wakeup() + | --- + | ... +fiber.yield() + | --- + | ... + +-- Cleanup. +f:cancel() + | --- + | ... +box.cfg{election_mode='off'} + | --- + | ... +test_run:cleanup_cluster() + | --- + | ... diff --git a/test/replication/gh-3055-promote-wakeup-crash.test.lua b/test/replication/gh-3055-promote-wakeup-crash.test.lua new file mode 100644 index 000000000..2ac901b08 --- /dev/null +++ b/test/replication/gh-3055-promote-wakeup-crash.test.lua @@ -0,0 +1,20 @@ +test_run = require('test_run').new() +-- +-- gh-3055 follow-up: box.ctl.promote() could crash on an assertion after a +-- spurious wakeup. +-- +_ = box.space._cluster:insert{2, require('uuid').str()} +box.cfg{election_mode='manual',\ + replication_synchro_quorum=2,\ + election_timeout=1000} + +fiber = require('fiber') +f = fiber.create(function() box.ctl.promote() end) +f:set_joinable(true) +f:wakeup() +fiber.yield() + +-- Cleanup. +f:cancel() +box.cfg{election_mode='off'} +test_run:cleanup_cluster() diff --git a/test/replication/suite.cfg b/test/replication/suite.cfg index 7f9014b22..8b2204e2a 100644 --- a/test/replication/suite.cfg +++ b/test/replication/suite.cfg @@ -3,6 +3,7 @@ "anon_register_gap.test.lua": {}, "gh-2991-misc-asserts-on-update.test.lua": {}, "gh-3055-election-promote.test.lua": {}, + "gh-3055-promote-wakeup-crash.test.lua": {}, "gh-3111-misc-rebootstrap-from-ro-master.test.lua": {}, "gh-3160-misc-heartbeats-on-master-changes.test.lua": {}, "gh-3247-misc-iproto-sequence-value-not-replicated.test.lua": {}, -- 2.30.1 (Apple Git-130)