From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 7D6B845C304 for ; Wed, 2 Dec 2020 11:10:27 +0300 (MSK) References: <20201130093551.62113-1-sergepetrenko@tarantool.org> From: Serge Petrenko Message-ID: <9ebaf301-f9ab-5f02-ada0-c67f37fbf4dd@tarantool.org> Date: Wed, 2 Dec 2020 11:10:25 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [Tarantool-patches] [PATCH v2] box: make instace ro while limbo is not empty List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org 02.12.2020 01:25, Vladislav Shpilevoy пишет: > Pushed to master and 2.6. > > Could you please backport it to 2.5 in a new branch? It seems > we need a test which wouldn't depend on elections anyhow. > Because we don't have them in 2.5. No problem. Here's the branch: sp/gh-5440-2.5 I had to cherry pick your commit introducing is_ro_summary, since it wasn't in 2.5 I've also made a test for read-only limbo without elections. Please, push it to 2.6 and master as well. I think a proper test won't hurt there. The test's also on the branch. Pasting it here just in case. ============================================================ commit 9d14706bacbd62afd474af7bb6d00f675241010e Author: Serge Petrenko Date:   Wed Dec 2 11:02:07 2020 +0300     test: add tests for ro on non-empty limbo     Follow-up #5440 diff --git a/test/replication/gh-5440-qsync-ro.result b/test/replication/gh-5440-qsync-ro.result new file mode 100644 index 000000000..1ece26a42 --- /dev/null +++ b/test/replication/gh-5440-qsync-ro.result @@ -0,0 +1,133 @@ +-- test-run result file version 2 +-- +-- gh-5440 everyone but the limbo owner is read-only on non-empty limbo. +-- +env = require('test_run') + | --- + | ... +test_run = env.new() + | --- + | ... +fiber = require('fiber') + | --- + | ... + +box.schema.user.grant('guest', 'replication') + | --- + | ... +test_run:cmd('create server replica with rpl_master=default, script="replication/replica.lua"') + | --- + | - true + | ... +test_run:cmd('start server replica with wait=True, wait_load=True') + | --- + | - true + | ... + +_ = box.schema.space.create('test', {is_sync=true}) + | --- + | ... +_ = box.space.test:create_index('pk') + | --- + | ... + +old_synchro_quorum = box.cfg.replication_synchro_quorum + | --- + | ... +old_synchro_timeout = box.cfg.replication_synchro_timeout + | --- + | ... + +-- Make sure that the master stalls on commit leaving the limbo non-empty. +box.cfg{replication_synchro_quorum=3, replication_synchro_timeout=1000} + | --- + | ... + +f = fiber.new(function() box.space.test:insert{1} end) + | --- + | ... +f:status() + | --- + | - suspended + | ... + +-- Wait till replica's limbo is non-empty. +test_run:wait_lsn('replica', 'default') + | --- + | ... +test_run:cmd('switch replica') + | --- + | - true + | ... + +box.info.ro + | --- + | - true + | ... +box.space.test:insert{2} + | --- + | - error: Can't modify data because this instance is in read-only mode. + | ... +success = false + | --- + | ... +f = require('fiber').new(function() box.ctl.wait_rw() success = true end) + | --- + | ... +f:status() + | --- + | - suspended + | ... + +test_run:cmd('switch default') + | --- + | - true + | ... + +-- Empty the limbo. +box.cfg{replication_synchro_quorum=2} + | --- + | ... + +test_run:cmd('switch replica') + | --- + | - true + | ... + +test_run:wait_cond(function() return success end) + | --- + | - true + | ... +box.info.ro + | --- + | - false + | ... +-- Should succeed now. +box.space.test:insert{2} + | --- + | - [2] + | ... + +-- Cleanup. +test_run:cmd('switch default') + | --- + | - true + | ... +box.cfg{replication_synchro_quorum=old_synchro_quorum,\ +        replication_synchro_timeout=old_synchro_timeout} + | --- + | ... +box.space.test:drop() + | --- + | ... +test_run:cmd('stop server replica') + | --- + | - true + | ... +test_run:cmd('delete server replica') + | --- + | - true + | ... +box.schema.user.revoke('guest', 'replication') + | --- + | ... diff --git a/test/replication/gh-5440-qsync-ro.test.lua b/test/replication/gh-5440-qsync-ro.test.lua new file mode 100644 index 000000000..d63ec9c1e --- /dev/null +++ b/test/replication/gh-5440-qsync-ro.test.lua @@ -0,0 +1,53 @@ +-- +-- gh-5440 everyone but the limbo owner is read-only on non-empty limbo. +-- +env = require('test_run') +test_run = env.new() +fiber = require('fiber') + +box.schema.user.grant('guest', 'replication') +test_run:cmd('create server replica with rpl_master=default, script="replication/replica.lua"') +test_run:cmd('start server replica with wait=True, wait_load=True') + +_ = box.schema.space.create('test', {is_sync=true}) +_ = box.space.test:create_index('pk') + +old_synchro_quorum = box.cfg.replication_synchro_quorum +old_synchro_timeout = box.cfg.replication_synchro_timeout + +-- Make sure that the master stalls on commit leaving the limbo non-empty. +box.cfg{replication_synchro_quorum=3, replication_synchro_timeout=1000} + +f = fiber.new(function() box.space.test:insert{1} end) +f:status() + +-- Wait till replica's limbo is non-empty. +test_run:wait_lsn('replica', 'default') +test_run:cmd('switch replica') + +box.info.ro +box.space.test:insert{2} +success = false +f = require('fiber').new(function() box.ctl.wait_rw() success = true end) +f:status() + +test_run:cmd('switch default') + +-- Empty the limbo. +box.cfg{replication_synchro_quorum=2} + +test_run:cmd('switch replica') + +test_run:wait_cond(function() return success end) +box.info.ro +-- Should succeed now. +box.space.test:insert{2} + +-- Cleanup. +test_run:cmd('switch default') +box.cfg{replication_synchro_quorum=old_synchro_quorum,\ +        replication_synchro_timeout=old_synchro_timeout} +box.space.test:drop() +test_run:cmd('stop server replica') +test_run:cmd('delete server replica') +box.schema.user.revoke('guest', 'replication') diff --git a/test/replication/suite.cfg b/test/replication/suite.cfg index a862f5a97..d01f0023b 100644 --- a/test/replication/suite.cfg +++ b/test/replication/suite.cfg @@ -32,6 +32,7 @@      "gh-4739-vclock-assert.test.lua": {},      "gh-4730-applier-rollback.test.lua": {},      "gh-4928-tx-boundaries.test.lua": {}, +    "gh-5440-qsync-ro.test.lua": {},      "*": {          "memtx": {"engine": "memtx"},          "vinyl": {"engine": "vinyl"} -- Serge Petrenko