From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 14 Sep 2018 18:37:43 +0300 From: Vladimir Davydov Subject: Re: [PATCH 1/2] tarantoolctl: fix cat and play for empty body requests Message-ID: <20180914153743.w52ihkiimvddl7tm@esperanza> References: <99dd15d5748aa49e99f7e98ce63f73dda63d25bc.1536934854.git.sergepetrenko@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <99dd15d5748aa49e99f7e98ce63f73dda63d25bc.1536934854.git.sergepetrenko@tarantool.org> To: Serge Petrenko Cc: tarantool-patches@freelists.org List-ID: On Fri, Sep 14, 2018 at 05:36:40PM +0300, Serge Petrenko wrote: > If space.before_replace returns the old tuple, the operation turns into > no-op, but is still written to WAL as IPROTO_NOP for the sake of > replication. Such a request doesn't have a body, and tarantoolctl failed > to parse such requests in `tarantoolctl cat` and `tarantoolctl play`. > Fix this by checking whether a request has a body. Also skip such > requests in `play`, since they have no effect. > > Closes #3675 > --- > extra/dist/tarantoolctl.in | 11 +++++++---- > test/app-tap/tarantoolctl.test.lua | 14 +++++++++++--- > 2 files changed, 18 insertions(+), 7 deletions(-) > > diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in > index 3d7ff3ec5..a6bd15e95 100755 > --- a/extra/dist/tarantoolctl.in > +++ b/extra/dist/tarantoolctl.in > @@ -373,6 +373,9 @@ write_lua_table = function(tuple) > end > > local function cat_lua_cb(record) > + if record.HEADER.type == 'NOP' then > + return > + end IMO better check 'record.BODY.space_id' instead of the type, because the code below tries to use it. > io.stdout:write(('box.space[%d]'):format(record.BODY.space_id)) > local op = record.HEADER.type:lower() > io.stdout:write((':%s('):format(op)) > @@ -816,7 +819,7 @@ local function cat() > for id, file in ipairs(positional_arguments) do > log.error("Processing file '%s'", file) > for lsn, record in xlog.pairs(file) do > - local sid = record.BODY.space_id > + local sid = record.BODY and record.BODY.space_id > local rid = record.HEADER.replica_id > if (lsn < from) or > (not spaces and sid and sid < 512 and not show_system) or > @@ -857,11 +860,11 @@ local function play() > for id, file in ipairs(positional_arguments) do > log.info(("Processing file '%s'"):format(file)) > for lsn, record in xlog.pairs(file) do > - local sid = record.BODY.space_id > + local sid = record.BODY and record.BODY.space_id > local rid = record.HEADER.replica_id > - if (lsn < from) or > + if (lsn < from) or sid == nil or > (not spaces and sid and sid < 512 and not show_system) or 'and sid' is useless after this change Anyway, strictly speaking this is incorrect, because you won't stop on a NOP record with lsn >= to, as you're supposed to. > - (spaces and (sid == nil or not find_in_list(sid, spaces))) or > + (spaces and not find_in_list(sid, spaces)) or > (replicas and not find_in_list(rid, replicas)) then > -- pass this tuple > elseif lsn >= to then