Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH] tarantoolctl: fix cat and play for empty body requests
@ 2018-09-11 16:15 Serge Petrenko
  2018-09-13 13:04 ` Vladimir Davydov
  0 siblings, 1 reply; 3+ messages in thread
From: Serge Petrenko @ 2018-09-11 16:15 UTC (permalink / raw)
  To: vdavydov.dev; +Cc: tarantool-patches, Serge Petrenko

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 skipping such requests, since they have no effect anyway.

Closes #3675
---
https://github.com/tarantool/tarantool/issues/3675
https://github.com/tarantool/tarantool/tree/sp/gh-3675-tarantoolctl-cat-empty-body

 extra/dist/tarantoolctl.in | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index 3d7ff3ec5..f7b6dd36d 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -816,11 +816,14 @@ 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 = nil
+            if record.BODY then
+                sid = record.BODY.space_id
+            end
             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
-               (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
@@ -857,11 +860,14 @@ 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 = nil
+            if record.BODY then
+                sid = record.BODY.space_id
+            end
             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
-               (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
-- 
2.15.2 (Apple Git-101.1)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tarantoolctl: fix cat and play for empty body requests
  2018-09-11 16:15 [PATCH] tarantoolctl: fix cat and play for empty body requests Serge Petrenko
@ 2018-09-13 13:04 ` Vladimir Davydov
  2018-09-14 14:39   ` [tarantool-patches] " Serge Petrenko
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Davydov @ 2018-09-13 13:04 UTC (permalink / raw)
  To: Serge Petrenko; +Cc: tarantool-patches

On Tue, Sep 11, 2018 at 07:15:06PM +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 skipping such requests, since they have no effect anyway.
> 
> Closes #3675
> ---
> https://github.com/tarantool/tarantool/issues/3675
> https://github.com/tarantool/tarantool/tree/sp/gh-3675-tarantoolctl-cat-empty-body
> 
>  extra/dist/tarantoolctl.in | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)

Please add a test.

> 
> diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
> index 3d7ff3ec5..f7b6dd36d 100755
> --- a/extra/dist/tarantoolctl.in
> +++ b/extra/dist/tarantoolctl.in
> @@ -816,11 +816,14 @@ 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 = nil
> +            if record.BODY then
> +                sid = record.BODY.space_id
> +            end

Nit:

  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

I want to see BODY-less requests in the output while this code makes
tarantoolctl-cat ignore them AFAIU.

>                 (not spaces and sid and sid < 512 and not show_system) or
> -               (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
> @@ -857,11 +860,14 @@ 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 = nil
> +            if record.BODY then
> +                sid = record.BODY.space_id
> +            end
>              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
> -               (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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [tarantool-patches] [PATCH] tarantoolctl: fix cat and play for empty body requests
  2018-09-13 13:04 ` Vladimir Davydov
@ 2018-09-14 14:39   ` Serge Petrenko
  0 siblings, 0 replies; 3+ messages in thread
From: Serge Petrenko @ 2018-09-14 14:39 UTC (permalink / raw)
  To: Vladimir Davydov; +Cc: tarantool-patches



> 13 сент. 2018 г., в 16:04, Vladimir Davydov <vdavydov.dev@gmail.com> написал(а):
> 
> On Tue, Sep 11, 2018 at 07:15:06PM +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 skipping such requests, since they have no effect anyway.
>> 
>> Closes #3675
>> ---
>> https://github.com/tarantool/tarantool/issues/3675
>> https://github.com/tarantool/tarantool/tree/sp/gh-3675-tarantoolctl-cat-empty-body
>> 
>> extra/dist/tarantoolctl.in | 18 ++++++++++++------
>> 1 file changed, 12 insertions(+), 6 deletions(-)
> 
> Please add a test.
> 
>> 
>> 
>> +            end
> 
> Nit:
> 
>  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
> 
> I want to see BODY-less requests in the output while this code makes
> tarantoolctl-cat ignore them AFAIU.
> 
>>                (not spaces and sid and sid < 512 and not show_system) or
>> 
>> -            if (lsn < from) or
>> +            if (lsn < from) or sid == nil 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
>> +               (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
> 

Hi! I fixed all your comments and resent the patch as a part of a patchset together with
a patch regarding #3678.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-14 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11 16:15 [PATCH] tarantoolctl: fix cat and play for empty body requests Serge Petrenko
2018-09-13 13:04 ` Vladimir Davydov
2018-09-14 14:39   ` [tarantool-patches] " Serge Petrenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox