Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v1 1/1] net.box: fix invalid index:count() with iterator
@ 2018-07-17 11:41 Kirill Shcherbatov
  2018-07-17 21:44 ` [tarantool-patches] " Vladislav Shpilevoy
  2018-07-19 10:23 ` Kirill Yukhin
  0 siblings, 2 replies; 3+ messages in thread
From: Kirill Shcherbatov @ 2018-07-17 11:41 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Kirill Shcherbatov

Net.box didn't pass options containing iterator to
server side.
There were also invalid results for two :count tests in
net.box.result file.

Thanks @ademenev for contributing problem and help with
problem locating.

Closes #3262.
---
Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-3262-fix-netbox-index-count
Issue: https://github.com/tarantool/tarantool/issues/3262

 src/box/lua/net_box.lua   |  2 +-
 test/box/net.box.result   | 34 ++++++++++++++++++++++++++++++++--
 test/box/net.box.test.lua | 23 +++++++++++++++++++++++
 3 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua
index cf7b672..a5091ed 100644
--- a/src/box/lua/net_box.lua
+++ b/src/box/lua/net_box.lua
@@ -1093,7 +1093,7 @@ index_metatable = function(remote)
         end
         local code = string.format('box.space.%s.index.%s:count',
                                    self.space.name, self.name)
-        return remote:_request('call_16', opts, code, { key })[1][1]
+        return remote:_request('call_16', opts, code, { key, opts })[1][1]
     end
 
     function methods:delete(key, opts)
diff --git a/test/box/net.box.result b/test/box/net.box.result
index 21cff4a..ed14c4d 100644
--- a/test/box/net.box.result
+++ b/test/box/net.box.result
@@ -891,11 +891,11 @@ remote_pk:count({2})
 ...
 remote_pk:count({2}, { timeout = 1.00, iterator = 'LE' })
 ---
-- 1
+- 3
 ...
 remote_pk:count({2}, { iterator = 'LE'})
 ---
-- 1
+- 3
 ...
 remote_pk:count({2}, { timeout = 1e-9, iterator = 'LE' })
 ---
@@ -949,6 +949,36 @@ remote_pk:max({2})
 ---
 - [2]
 ...
+--
+-- gh-3262: index:count() inconsistent results
+--
+test_run:cmd("setopt delimiter ';'")
+---
+- true
+...
+function do_count_test(min, it)
+    local r1 = remote_pk:count(min, {iterator = it} )
+    local r2 = box.space.net_box_test_space.index.primary:count(min, {iterator = it} )
+    local r3 = remote.self.space.net_box_test_space.index.primary:count(min, {iterator = it} )
+    return r1 == r2 and r2 == r3
+end;
+---
+...
+data = remote_pk:select();
+---
+...
+for _, v in pairs(data) do
+    local itrs = {'GE', 'GT', 'LE', 'LT' }
+    for _, it in pairs(itrs) do
+        assert(do_count_test(v[0], it) == true)
+    end
+end;
+---
+...
+test_run:cmd("setopt delimiter ''");
+---
+- true
+...
 _ = remote_space:delete({0}, { timeout = 1e-9 })
 ---
 - error: Timeout exceeded
diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua
index 14fb6eb..0187aaf 100644
--- a/test/box/net.box.test.lua
+++ b/test/box/net.box.test.lua
@@ -347,6 +347,29 @@ remote_pk:max({0}, { timeout = 1.00 })
 remote_pk:max({1}, { timeout = 1e-9 })
 remote_pk:max({2})
 
+--
+-- gh-3262: index:count() inconsistent results
+--
+test_run:cmd("setopt delimiter ';'")
+
+function do_count_test(min, it)
+    local r1 = remote_pk:count(min, {iterator = it} )
+    local r2 = box.space.net_box_test_space.index.primary:count(min, {iterator = it} )
+    local r3 = remote.self.space.net_box_test_space.index.primary:count(min, {iterator = it} )
+    return r1 == r2 and r2 == r3
+end;
+
+data = remote_pk:select();
+
+for _, v in pairs(data) do
+    local itrs = {'GE', 'GT', 'LE', 'LT' }
+    for _, it in pairs(itrs) do
+        assert(do_count_test(v[0], it) == true)
+    end
+end;
+
+test_run:cmd("setopt delimiter ''");
+
 _ = remote_space:delete({0}, { timeout = 1e-9 })
 _ = remote_pk:delete({0}, { timeout = 1.00 })
 _ = remote_space:delete({1}, { timeout = 1.00 })
-- 
2.7.4

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

* [tarantool-patches] Re: [PATCH v1 1/1] net.box: fix invalid index:count() with iterator
  2018-07-17 11:41 [tarantool-patches] [PATCH v1 1/1] net.box: fix invalid index:count() with iterator Kirill Shcherbatov
@ 2018-07-17 21:44 ` Vladislav Shpilevoy
  2018-07-19 10:23 ` Kirill Yukhin
  1 sibling, 0 replies; 3+ messages in thread
From: Vladislav Shpilevoy @ 2018-07-17 21:44 UTC (permalink / raw)
  To: tarantool-patches, Kirill Shcherbatov

Thanks for the patch! LGTM.

On 17/07/2018 14:41, Kirill Shcherbatov wrote:
> Net.box didn't pass options containing iterator to
> server side.
> There were also invalid results for two :count tests in
> net.box.result file.
> 
> Thanks @ademenev for contributing problem and help with
> problem locating.
> 
> Closes #3262.
> ---
> Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-3262-fix-netbox-index-count
> Issue: https://github.com/tarantool/tarantool/issues/3262
> 
>   src/box/lua/net_box.lua   |  2 +-
>   test/box/net.box.result   | 34 ++++++++++++++++++++++++++++++++--
>   test/box/net.box.test.lua | 23 +++++++++++++++++++++++
>   3 files changed, 56 insertions(+), 3 deletions(-)
> 

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

* [tarantool-patches] Re: [PATCH v1 1/1] net.box: fix invalid index:count() with iterator
  2018-07-17 11:41 [tarantool-patches] [PATCH v1 1/1] net.box: fix invalid index:count() with iterator Kirill Shcherbatov
  2018-07-17 21:44 ` [tarantool-patches] " Vladislav Shpilevoy
@ 2018-07-19 10:23 ` Kirill Yukhin
  1 sibling, 0 replies; 3+ messages in thread
From: Kirill Yukhin @ 2018-07-19 10:23 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Kirill Shcherbatov

Hello,
On 17 июл 14:41, Kirill Shcherbatov wrote:
> Net.box didn't pass options containing iterator to
> server side.
> There were also invalid results for two :count tests in
> net.box.result file.
> 
> Thanks @ademenev for contributing problem and help with
> problem locating.
> 
> Closes #3262.
> ---
> Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-3262-fix-netbox-index-count
> Issue: https://github.com/tarantool/tarantool/issues/3262
I've checked the patch into 1-9 branch.

--
Regards, Kirill Yukhin

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

end of thread, other threads:[~2018-07-19 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 11:41 [tarantool-patches] [PATCH v1 1/1] net.box: fix invalid index:count() with iterator Kirill Shcherbatov
2018-07-17 21:44 ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-19 10:23 ` Kirill Yukhin

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