From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Alexander Turenko <alexander.turenko@tarantool.org>,
tarantool-patches@freelists.org
Subject: [PATCH 2/2] Fix tarantoolctl cat/play premature stop with --to
Date: Wed, 20 Mar 2019 21:41:14 +0300 [thread overview]
Message-ID: <c5af8d001946dbde0232961e64f57fe95c9755bf.1553104456.git.alexander.turenko@tarantool.org> (raw)
In-Reply-To: <cover.1553104456.git.alexander.turenko@tarantool.org>
Stop a file processing loop only when it is guaranteed that we will not
find a record that match user-provided filters later in this file. If
--replica R is provided one time and we're meet a record from R with a
LSN equal or above of a --to value, we'll stop the loop. Otherwise (no
--replica, several --replica arguments) a file will be read until an end
even if --to is provided.
Fixes #3827.
---
| 14 +++++++-------
test/app-tap/tarantoolctl.test.lua | 4 ++--
2 files changed, 9 insertions(+), 9 deletions(-)
--git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index 014acee6c..0796f4605 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -839,11 +839,11 @@ end
-- 4. If @a opts.replica is set, record.HEADER.replica_id should
-- not be nil and should be in @a opts.replica list.
--
--- Once a record with LSN >= @a opts.to is found the loop stops
--- (even if a file contains next records with smaller LSN from
--- another replicas). Note however that this function is called
--- once for each xlog / snap file, so even when it stops on LSN
--- >= @a opts.to on a current file a next file will be processed.
+-- If @a opts.replica is set and is a singleton list and a record
+-- **from this replica** with LSN >= @a opts.to is found the loop
+-- stops. Note however that this function is called once for each
+-- xlog / snap file, so even when it stops on LSN >= @a opts.to on
+-- a current file a next file will be processed.
local function filter_xlog(gen, param, state, opts, cb)
local spaces = opts.spaces
local from, to, spaces = opts.from, opts.to, opts.space
@@ -852,11 +852,11 @@ local function filter_xlog(gen, param, state, opts, cb)
for lsn, record in gen, param, state do
local sid = record.BODY and record.BODY.space_id
local rid = record.HEADER.replica_id
- if lsn >= to then
+ if replicas and #replicas == 1 and replicas[1] == rid and lsn >= to then
-- stop, as we've finished reading tuple with lsn == to
-- and the next lsn's will be bigger
break
- elseif (lsn < from) or
+ elseif (lsn < from) or (lsn >= to) or
(not spaces and sid and sid < 512 and not show_system) or
(spaces and (sid == nil or not find_in_list(sid, spaces))) or
(replicas and not find_in_list(rid, replicas)) then
diff --git a/test/app-tap/tarantoolctl.test.lua b/test/app-tap/tarantoolctl.test.lua
index 4910b94f3..a914db5c5 100755
--- a/test/app-tap/tarantoolctl.test.lua
+++ b/test/app-tap/tarantoolctl.test.lua
@@ -590,7 +590,7 @@ test:test('filter_xlog', function(test)
{
'to w/o replica id',
opts = merge(default_opts, {to = 120}),
- exp_result = {},
+ exp_result = {x[9], x[10]},
},
{
'to and replica id',
@@ -600,7 +600,7 @@ test:test('filter_xlog', function(test)
{
'to and replica ids',
opts = merge(default_opts, {to = 137, replica = {1, 2}}),
- exp_result = {x[7]},
+ exp_result = {x[7], x[9]},
},
}
test:plan(#cases)
--
2.20.1
next prev parent reply other threads:[~2019-03-20 18:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-20 18:41 [PATCH 0/2] Fix tarantoolctl cat/play premature stop Alexander Turenko
2019-03-20 18:41 ` [PATCH 1/2] Unify tarantoolctl cat/play xlog filtering code Alexander Turenko
2019-03-20 18:41 ` Alexander Turenko [this message]
2019-03-26 18:11 ` [PATCH 0/2] Fix tarantoolctl cat/play premature stop Vladimir Davydov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c5af8d001946dbde0232961e64f57fe95c9755bf.1553104456.git.alexander.turenko@tarantool.org \
--to=alexander.turenko@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=vdavydov.dev@gmail.com \
--subject='Re: [PATCH 2/2] Fix tarantoolctl cat/play premature stop with --to' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox