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 A922A74152; Wed, 6 Oct 2021 11:39:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A922A74152 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633509559; bh=ZxvWxkbjnFzK/DVPW80Y9uvKFkK+Y+FeJ1Vvu/uZ2Y0=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=jDuRRlV4vk3eZvV62PlSjEbq7Pe7HOdFGzh2kCcd9RWqjsqyPnU38v0McP5HUc7KL bahke3vbGeVb9FDoukZrt45iMoPZaj+4r/zQSffAFrM3phX2DdI3O5Ue8D/tkbsOK6 iEhhnjlDfJojuEOVRqSdKTqi/eIccJnlRdnjiRU8= Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 6F56C74151 for ; Wed, 6 Oct 2021 11:39:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6F56C74151 Received: by mail-lf1-f53.google.com with SMTP id y26so7142178lfa.11 for ; Wed, 06 Oct 2021 01:39:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UPumsCkDxRidhP6wMfTIiiJlFl4ZOnNi5qGt7eq0we0=; b=aRLTQ8hni2bQRFeAHWJf0cMCaCCoj6Nqkj38geg34iN8w5G0p9wzHT7kHhavGtwhna CDalBpPGr05P1WAFF6leL1Xb5we9i0bLuRcjOCTMERhF8t1urlWmXcroT51sI5rI69vN EcuMCFORBj5fY+f9m9ezPDL1His9iDzdDEP0HR/94Ibc6SrO/vUvbWvDUKPytVSwr1JW YC30bzlxJGbUSdDhyqmRD8aF8gB3HpHf20FDp+gt1D0aJoOvJi11k25YczOySHIbexPs qpyRKDFQ+HxD1cv6L8aBHvxYWRnEsgMVhuKJJYrB6rInYtqmru5dJpB4/n+GWAa7BN6S Wf2Q== X-Gm-Message-State: AOAM533vd4qMCWWQIM6qR3hMleP5FSbUD3dCWXYAZay8D6WBQmnxWIS0 aORDrv27BrS2fkfHK5HUXA+IuuW7zuM= X-Google-Smtp-Source: ABdhPJxa4tsQwyuPEIgS3wFiw59i/Xs9QLhF56nBs9l6hUoFF0/8BuBzRUJ/e8dI6XiUhDLvwK4HIg== X-Received: by 2002:a19:fc09:: with SMTP id a9mr8237117lfi.302.1633509555662; Wed, 06 Oct 2021 01:39:15 -0700 (PDT) Received: from localhost.localdomain (broadband-46-242-13-228.ip.moscow.rt.ru. [46.242.13.228]) by smtp.gmail.com with ESMTPSA id m3sm2204134lfh.2.2021.10.06.01.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 01:39:15 -0700 (PDT) To: tarantool-patches@dev.tarantool.org Cc: Yan Shtunder Date: Wed, 6 Oct 2021 11:39:09 +0300 Message-Id: <20211006083909.7750-1-ya.shtunder@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v2] replication: the truncate method called from within a transaction 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: Yan Shtunder via Tarantool-patches Reply-To: Yan Shtunder Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" The truncate method could be called from within a transaction. The flag of GROUP_LOCAL was set in truncate method after statement row had been being checked on the GROUP_LOCAL. Accordingly, after a local transaction NOP row was not appended. Closes #6123 --- Issue: https://github.com/tarantool/tarantool/issues/6123 Patch: https://github.com/tarantool/tarantool/tree/yshtunder/gh-6123-truncate-is-local-transaction src/box/alter.cc | 10 +-- test/replication-luatest/gh_6123_test.lua | 2 - ...-6123-truncate-is-local-transaction.result | 90 ------------------- ...123-truncate-is-local-transaction.test.lua | 36 -------- 4 files changed, 2 insertions(+), 136 deletions(-) delete mode 100644 test/replication/gh-6123-truncate-is-local-transaction.result delete mode 100644 test/replication/gh-6123-truncate-is-local-transaction.test.lua diff --git a/src/box/alter.cc b/src/box/alter.cc index 399dfe049..ff1404205 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -2902,14 +2902,8 @@ on_replace_dd_truncate(struct trigger * /* trigger */, void *event) space_group_id(old_space) == GROUP_LOCAL) { stmt->row->group_id = GROUP_LOCAL; /* - * In order to append a dummy NOP statement - * to preserve the tx replication boundaries, - * it is necessary that the condition - * txn->n_local_rows > 0 must be true. - * Therefore it is necessary to increase the - * value of n_local_rows, because the checking - * on the flag of GROUP_LOCAL will occurs - * before it is set. + * The trigger is invoked after txn->n_local_rows + * is counted, so don't forget to update it here. */ ++txn->n_local_rows; } diff --git a/test/replication-luatest/gh_6123_test.lua b/test/replication-luatest/gh_6123_test.lua index 7341ccc95..a19d1135b 100644 --- a/test/replication-luatest/gh_6123_test.lua +++ b/test/replication-luatest/gh_6123_test.lua @@ -12,7 +12,6 @@ g.before_all(function() command = './test/replication-luatest/instance_files/master.lua', workdir = fio.tempdir(), env = {TARANTOOL_REPLICA = '13302'}, - http_port = 8081, net_box_port = 13301, }) @@ -21,7 +20,6 @@ g.before_all(function() command = './test/replication-luatest/instance_files/replica.lua', workdir = fio.tempdir(), env = {TARANTOOL_MASTER = '13301'}, - http_port = 8082, net_box_port = 13302, }) diff --git a/test/replication/gh-6123-truncate-is-local-transaction.result b/test/replication/gh-6123-truncate-is-local-transaction.result deleted file mode 100644 index db57d37d8..000000000 --- a/test/replication/gh-6123-truncate-is-local-transaction.result +++ /dev/null @@ -1,90 +0,0 @@ --- test-run result file version 2 -test_run = require('test_run').new() - | --- - | ... - - --- Step 1 -box.schema.user.grant("guest", "replication") - | --- - | ... -s = box.schema.space.create("temp", {temporary=true}) - | --- - | ... -_ = s:create_index('pk') - | --- - | ... -s:insert{1,2} - | --- - | - [1, 2] - | ... -s:insert{4} - | --- - | - [4] - | ... -s:select() - | --- - | - - [1, 2] - | - [4] - | ... - - --- Step 2 -test_run:cmd('create server replica with rpl_master=default,\ - script="replication/replica.lua"') - | --- - | - true - | ... -test_run:cmd('start server replica') - | --- - | - true - | ... - - --- Step 3 -box.begin() box.space._schema:replace{"smth"} s:truncate() box.commit() - | --- - | ... -s:select() - | --- - | - [] - | ... -box.space._schema:select{'smth'} - | --- - | - - ['smth'] - | ... - - --- Step 4 --- Checking that replica has received the last transaction, --- and that replication isn't broken. -test_run:switch('replica') - | --- - | - true - | ... -box.space._schema:select{'smth'} - | --- - | - - ['smth'] - | ... -box.info.replication[1].upstream.status - | --- - | - follow - | ... - - -test_run:switch('default') - | --- - | - true - | ... -test_run:cmd('stop server replica') - | --- - | - true - | ... -test_run:cmd('cleanup server replica') - | --- - | - true - | ... -test_run:cmd('delete server replica') - | --- - | - true - | ... diff --git a/test/replication/gh-6123-truncate-is-local-transaction.test.lua b/test/replication/gh-6123-truncate-is-local-transaction.test.lua deleted file mode 100644 index 336c0c44d..000000000 --- a/test/replication/gh-6123-truncate-is-local-transaction.test.lua +++ /dev/null @@ -1,36 +0,0 @@ -test_run = require('test_run').new() - - --- Step 1 -box.schema.user.grant("guest", "replication") -s = box.schema.space.create("temp", {temporary=true}) -_ = s:create_index('pk') -s:insert{1,2} -s:insert{4} -s:select() - - --- Step 2 -test_run:cmd('create server replica with rpl_master=default,\ - script="replication/replica.lua"') -test_run:cmd('start server replica') - - --- Step 3 -box.begin() box.space._schema:replace{"smth"} s:truncate() box.commit() -s:select() -box.space._schema:select{'smth'} - - --- Step 4 --- Checking that replica has received the last transaction, --- and that replication isn't broken. -test_run:switch('replica') -box.space._schema:select{'smth'} -box.info.replication[1].upstream.status - - -test_run:switch('default') -test_run:cmd('stop server replica') -test_run:cmd('cleanup server replica') -test_run:cmd('delete server replica') -- 2.25.1