From da3d067bf23956d55297f1a6df4239882ce63e8c Mon Sep 17 00:00:00 2001 From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Date: Mon, 19 Jun 2017 15:46:21 +0300 Subject: [PATCH] test: add test on upserts not used cache When an UPSERT is prepared, it can use a cached statement to be turned into REPLACE. But now it doesn't use the cache. Test for #2520 --- test/vinyl/upsert.result | 52 +++++++++++++++++++++++++++++++++++++- test/vinyl/upsert.test.lua | 18 ++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/test/vinyl/upsert.result b/test/vinyl/upsert.result index 32f5105c3e..9f48d6136a 100644 --- a/test/vinyl/upsert.result +++ b/test/vinyl/upsert.result @@ -673,7 +673,7 @@ space:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i = s:create_index('test') +i = s:create_index('test', { run_count_per_level = 20 }) --- ... s:replace({1, 1}) @@ -694,6 +694,56 @@ s:select() --both upserts are ignored due to primary key change --- - - [1, 1] ... +-- gh-2520 use cache as a hint for upserts applying. +old_stat = box.info.vinyl().performance["iterator"].run.lookup_count +--- +... +s:upsert({100}, {{'=', 2, 200}}) +--- +... +box.snapshot() +--- +- ok +... +s:get{100} +--- +- [100] +... +new_stat = box.info.vinyl().performance["iterator"].run.lookup_count +--- +... +new_stat - old_stat +--- +- 1 +... +old_stat = new_stat +--- +... +box.snapshot() +--- +- ok +... +s:upsert({100}, {{'=', 2, 300}}) +--- +... +box.snapshot() +--- +- ok +... +s:get{100} +--- +- [100, 300] +... +new_stat = box.info.vinyl().performance["iterator"].run.lookup_count +--- +... +new_stat - old_stat +--- +- 2 +... +old_stat = new_stat +--- +... s:drop() --- ... diff --git a/test/vinyl/upsert.test.lua b/test/vinyl/upsert.test.lua index 82af24a698..1a73be48da 100644 --- a/test/vinyl/upsert.test.lua +++ b/test/vinyl/upsert.test.lua @@ -272,7 +272,7 @@ space:drop() -- fix behaviour after https://github.com/tarantool/tarantool/issues/2104 s = box.schema.space.create('test', {engine = 'vinyl'}) -i = s:create_index('test') +i = s:create_index('test', { run_count_per_level = 20 }) s:replace({1, 1}) box.snapshot() @@ -280,4 +280,20 @@ s:upsert({1, 1}, {{'+', 1, 1}}) s:upsert({1, 1}, {{'+', 2, 1}}) s:select() --both upserts are ignored due to primary key change +-- gh-2520 use cache as a hint for upserts applying. +old_stat = box.info.vinyl().performance["iterator"].run.lookup_count +s:upsert({100}, {{'=', 2, 200}}) +box.snapshot() +s:get{100} +new_stat = box.info.vinyl().performance["iterator"].run.lookup_count +new_stat - old_stat +old_stat = new_stat +box.snapshot() +s:upsert({100}, {{'=', 2, 300}}) +box.snapshot() +s:get{100} +new_stat = box.info.vinyl().performance["iterator"].run.lookup_count +new_stat - old_stat +old_stat = new_stat + s:drop() -- GitLab