From 4c97752ee2dd8b12962d61002b17aa883023a387 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Thu, 10 Sep 2015 21:52:37 +0300 Subject: [PATCH] gh-1002: transation.test failed sporadically iproto thread can add quirks to thread scheduling, replace single-call yields with yields in a loop. --- test/box/transaction.result | 25 ++++++++++--------------- test/box/transaction.test.lua | 13 ++++++------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/test/box/transaction.result b/test/box/transaction.result index e80b2c7e3a..2de70ddff4 100644 --- a/test/box/transaction.result +++ b/test/box/transaction.result @@ -47,19 +47,8 @@ f = fiber.create(sloppy); ... -- when the sloppy fiber ends, its session has an active transction -- ensure it's rolled back automatically -f:status(); +while f:status() ~= 'dead' do fiber.sleep(0) end; --- -- dead -... -fiber.sleep(0); ---- -... -fiber.sleep(0); ---- -... -f:status(); ---- -- dead ... -- transactions and system spaces box.begin() box.schema.space.create('test'); @@ -205,14 +194,14 @@ box.commit(); box.begin() s:insert{1, 'Must be rolled back'}; --- ... +-- nothing - the transaction was rolled back -- nothing to commit because of yield +while s:get{1} ~= nil do fiber.sleep(0) end box.commit(); --- ... --- nothing - the transaction was rolled back -- Test background fiber -- -s:select{} function sloppy() box.begin() s:insert{1, 'From background fiber'} @@ -233,6 +222,9 @@ s:select{}; --- - [] ... +t = nil; +--- +... function sloppy() box.begin() s:insert{1, 'From background fiber'} @@ -245,7 +237,7 @@ end; f = fiber.create(sloppy); --- ... -while f:status() == 'running' do +while f:status() ~= 'dead' do fiber.sleep(0) end; --- @@ -395,3 +387,6 @@ box.space.test:len() --- - 10001 ... +box.space.test:drop() +--- +... diff --git a/test/box/transaction.test.lua b/test/box/transaction.test.lua index bb02ccf48d..d03f78cb2c 100644 --- a/test/box/transaction.test.lua +++ b/test/box/transaction.test.lua @@ -24,10 +24,7 @@ end; f = fiber.create(sloppy); -- when the sloppy fiber ends, its session has an active transction -- ensure it's rolled back automatically -f:status(); -fiber.sleep(0); -fiber.sleep(0); -f:status(); +while f:status() ~= 'dead' do fiber.sleep(0) end; -- transactions and system spaces box.begin() box.schema.space.create('test'); box.rollback(); @@ -90,10 +87,10 @@ box.begin(); -- back a transction with no statements. box.commit(); box.begin() s:insert{1, 'Must be rolled back'}; +-- nothing - the transaction was rolled back +while s:get{1} ~= nil do fiber.sleep(0) end -- nothing to commit because of yield box.commit(); --- nothing - the transaction was rolled back -s:select{} -- Test background fiber -- function sloppy() @@ -107,6 +104,7 @@ end; -- When the sloppy fiber ends, its session has an active transction -- It's rolled back automatically s:select{}; +t = nil; function sloppy() box.begin() s:insert{1, 'From background fiber'} @@ -115,7 +113,7 @@ function sloppy() t = s:select{} end; f = fiber.create(sloppy); -while f:status() == 'running' do +while f:status() ~= 'dead' do fiber.sleep(0) end; t; @@ -186,3 +184,4 @@ _ = box.schema.space.create('test'); _ = box.space.test:create_index('primary'); tx_limit(10000) box.space.test:len() +box.space.test:drop() -- GitLab