* [Tarantool-patches] [PATCH 1/1] test: fix flaky box/gh-4627-session-use-after-free
@ 2019-12-03 0:05 Vladislav Shpilevoy
2019-12-04 11:35 ` Alexander Turenko
0 siblings, 1 reply; 4+ messages in thread
From: Vladislav Shpilevoy @ 2019-12-03 0:05 UTC (permalink / raw)
To: tarantool-patches, alexander.turenko
The problem was in that the test uses the global trigger
box.session.on_disconnect() to set a global variable by one
connection. But test-run can do multiple connects/reconnects to
the same instance. That led to multiple invocations of
box.session.on_disconnect(), which could override the global
variable in unexpected ways and moments.
The patch makes only one session execute that trigger.
Probably related to https://github.com/tarantool/test-run/issues/46
Follow up #4627
---
Branch: https://github.com/tarantool/tarantool/tree/gerold103/session-flaky-test
.../box/gh-4627-session-use-after-free.result | 28 +++++++++++++++++++
.../gh-4627-session-use-after-free.test.lua | 20 +++++++++++++
2 files changed, 48 insertions(+)
diff --git a/test/box/gh-4627-session-use-after-free.result b/test/box/gh-4627-session-use-after-free.result
index 5e5c154b9..33e5a7af1 100644
--- a/test/box/gh-4627-session-use-after-free.result
+++ b/test/box/gh-4627-session-use-after-free.result
@@ -20,6 +20,21 @@ fiber = require('fiber')
| ---
| ...
+box.schema.user.grant('guest', 'execute', 'universe')
+ | ---
+ | ...
+
+-- This is a workaround for flakiness of the test
+-- appearing when another test tries to connect to
+-- this one. By setting a flag for only one
+-- session, others won't interfere in
+-- session.on_disconnect().
+function enable_on_disconnect() \
+ box.session.storage.is_enabled = true \
+end
+ | ---
+ | ...
+
sid_before_yield = nil
| ---
| ...
@@ -27,6 +42,9 @@ sid_after_yield = nil
| ---
| ...
func = box.session.on_disconnect(function() \
+ if not box.session.storage.is_enabled then \
+ return \
+ end \
sid_before_yield = box.session.id() \
fiber.yield() \
sid_after_yield = box.session.id() \
@@ -37,6 +55,12 @@ end)
connection = net_box.connect(box.cfg.listen)
| ---
| ...
+-- Connections, not related to this one, won't
+-- call this function, and therefore won't do
+-- anything in session.on_disconnect() trigger.
+connection:call('enable_on_disconnect')
+ | ---
+ | ...
connection:ping()
| ---
| - true
@@ -58,3 +82,7 @@ sid_after_yield == sid_before_yield and sid_after_yield ~= 0 or \
box.session.on_disconnect(nil, func)
| ---
| ...
+
+box.schema.user.revoke('guest', 'execute', 'universe')
+ | ---
+ | ...
diff --git a/test/box/gh-4627-session-use-after-free.test.lua b/test/box/gh-4627-session-use-after-free.test.lua
index 70624a96a..1b2ebfdc4 100644
--- a/test/box/gh-4627-session-use-after-free.test.lua
+++ b/test/box/gh-4627-session-use-after-free.test.lua
@@ -15,15 +15,33 @@
net_box = require('net.box')
fiber = require('fiber')
+box.schema.user.grant('guest', 'execute', 'universe')
+
+-- This is a workaround for flakiness of the test
+-- appearing when another test tries to connect to
+-- this one. By setting a flag for only one
+-- session, others won't interfere in
+-- session.on_disconnect().
+function enable_on_disconnect() \
+ box.session.storage.is_enabled = true \
+end
+
sid_before_yield = nil
sid_after_yield = nil
func = box.session.on_disconnect(function() \
+ if not box.session.storage.is_enabled then \
+ return \
+ end \
sid_before_yield = box.session.id() \
fiber.yield() \
sid_after_yield = box.session.id() \
end)
connection = net_box.connect(box.cfg.listen)
+-- Connections, not related to this one, won't
+-- call this function, and therefore won't do
+-- anything in session.on_disconnect() trigger.
+connection:call('enable_on_disconnect')
connection:ping()
connection:close()
@@ -33,3 +51,5 @@ sid_after_yield == sid_before_yield and sid_after_yield ~= 0 or \
{sid_after_yield, sid_before_yield}
box.session.on_disconnect(nil, func)
+
+box.schema.user.revoke('guest', 'execute', 'universe')
--
2.21.0 (Apple Git-122.2)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Tarantool-patches] [PATCH 1/1] test: fix flaky box/gh-4627-session-use-after-free
2019-12-03 0:05 [Tarantool-patches] [PATCH 1/1] test: fix flaky box/gh-4627-session-use-after-free Vladislav Shpilevoy
@ 2019-12-04 11:35 ` Alexander Turenko
2019-12-05 20:42 ` Vladislav Shpilevoy
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Turenko @ 2019-12-04 11:35 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches
This fix itself is okay for me, but, please, look at a few minor
comments below.
WBR, Alexander Turenko.
On Tue, Dec 03, 2019 at 01:05:30AM +0100, Vladislav Shpilevoy wrote:
> The problem was in that the test uses the global trigger
> box.session.on_disconnect() to set a global variable by one
> connection. But test-run can do multiple connects/reconnects to
> the same instance. That led to multiple invocations of
> box.session.on_disconnect(), which could override the global
> variable in unexpected ways and moments.
>
> The patch makes only one session execute that trigger.
>
> Probably related to https://github.com/tarantool/test-run/issues/46
> Follow up #4627
> ---
> Branch: https://github.com/tarantool/tarantool/tree/gerold103/session-flaky-test
>
> .../box/gh-4627-session-use-after-free.result | 28 +++++++++++++++++++
> .../gh-4627-session-use-after-free.test.lua | 20 +++++++++++++
> 2 files changed, 48 insertions(+)
> diff --git a/test/box/gh-4627-session-use-after-free.test.lua b/test/box/gh-4627-session-use-after-free.test.lua
> index 70624a96a..1b2ebfdc4 100644
> --- a/test/box/gh-4627-session-use-after-free.test.lua
> +++ b/test/box/gh-4627-session-use-after-free.test.lua
> @@ -15,15 +15,33 @@
> net_box = require('net.box')
> fiber = require('fiber')
>
> +box.schema.user.grant('guest', 'execute', 'universe')
> +
> +-- This is a workaround for flakiness of the test
> +-- appearing when another test tries to connect to
I tentative that another test may access to a unix socket (tarantool's
binary port) that run on another worker: all those sockets are placed in
worker's directory. It seems that test-run itself doing some reconnects.
> +-- this one. By setting a flag for only one
> +-- session, others won't interfere in
> +-- session.on_disconnect().
> +function enable_on_disconnect() \
> + box.session.storage.is_enabled = true \
> +end
> +
> sid_before_yield = nil
> sid_after_yield = nil
> func = box.session.on_disconnect(function() \
> + if not box.session.storage.is_enabled then \
> + return \
> + end \
> sid_before_yield = box.session.id() \
> fiber.yield() \
> sid_after_yield = box.session.id() \
> end)
>
> connection = net_box.connect(box.cfg.listen)
> +-- Connections, not related to this one, won't
> +-- call this function, and therefore won't do
> +-- anything in session.on_disconnect() trigger.
> +connection:call('enable_on_disconnect')
> connection:ping()
It seems that :ping() is not needed anymore.
> connection:close()
>
> @@ -33,3 +51,5 @@ sid_after_yield == sid_before_yield and sid_after_yield ~= 0 or \
> {sid_after_yield, sid_before_yield}
>
> box.session.on_disconnect(nil, func)
> +
> +box.schema.user.revoke('guest', 'execute', 'universe')
> --
> 2.21.0 (Apple Git-122.2)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Tarantool-patches] [PATCH 1/1] test: fix flaky box/gh-4627-session-use-after-free
2019-12-04 11:35 ` Alexander Turenko
@ 2019-12-05 20:42 ` Vladislav Shpilevoy
2019-12-05 22:53 ` Alexander Turenko
0 siblings, 1 reply; 4+ messages in thread
From: Vladislav Shpilevoy @ 2019-12-05 20:42 UTC (permalink / raw)
To: Alexander Turenko; +Cc: tarantool-patches
Hi! Thanks for the review!
I submitted fixes to the branch.
On 04/12/2019 12:35, Alexander Turenko wrote:
> This fix itself is okay for me, but, please, look at a few minor
> comments below.
>
> WBR, Alexander Turenko.
>
> On Tue, Dec 03, 2019 at 01:05:30AM +0100, Vladislav Shpilevoy wrote:
>> The problem was in that the test uses the global trigger
>> box.session.on_disconnect() to set a global variable by one
>> connection. But test-run can do multiple connects/reconnects to
>> the same instance. That led to multiple invocations of
>> box.session.on_disconnect(), which could override the global
>> variable in unexpected ways and moments.
>>
>> The patch makes only one session execute that trigger.
>>
>> Probably related to https://github.com/tarantool/test-run/issues/46
>> Follow up #4627
>> ---
>> Branch: https://github.com/tarantool/tarantool/tree/gerold103/session-flaky-test
>>
>> .../box/gh-4627-session-use-after-free.result | 28 +++++++++++++++++++
>> .../gh-4627-session-use-after-free.test.lua | 20 +++++++++++++
>> 2 files changed, 48 insertions(+)
>
>> diff --git a/test/box/gh-4627-session-use-after-free.test.lua b/test/box/gh-4627-session-use-after-free.test.lua
>> index 70624a96a..1b2ebfdc4 100644
>> --- a/test/box/gh-4627-session-use-after-free.test.lua
>> +++ b/test/box/gh-4627-session-use-after-free.test.lua
>> @@ -15,15 +15,33 @@
>> net_box = require('net.box')
>> fiber = require('fiber')
>>
>> +box.schema.user.grant('guest', 'execute', 'universe')
>> +
>> +-- This is a workaround for flakiness of the test
>> +-- appearing when another test tries to connect to
>
> I tentative that another test may access to a unix socket (tarantool's
I am sorry, but I don't understand - what do you mean as 'I tentative'?
This is not a verb. You meant, that you guess, assume, doubt, investigated
or something else?
I assume you've meant 'I doubt', as so there is a fix:
===========================================================================
diff --git a/test/box/gh-4627-session-use-after-free.result b/test/box/gh-4627-session-use-after-free.result
index 33e5a7af1..67196b33d 100644
--- a/test/box/gh-4627-session-use-after-free.result
+++ b/test/box/gh-4627-session-use-after-free.result
@@ -25,8 +25,9 @@ box.schema.user.grant('guest', 'execute', 'universe')
| ...
-- This is a workaround for flakiness of the test
--- appearing when another test tries to connect to
--- this one. By setting a flag for only one
+-- appearing when test-run does reconnects to the
+-- instance and therefore creates multiple
+-- sessions. By setting a flag for only one
-- session, others won't interfere in
-- session.on_disconnect().
function enable_on_disconnect() \
diff --git a/test/box/gh-4627-session-use-after-free.test.lua b/test/box/gh-4627-session-use-after-free.test.lua
index 1b2ebfdc4..256195186 100644
--- a/test/box/gh-4627-session-use-after-free.test.lua
+++ b/test/box/gh-4627-session-use-after-free.test.lua
@@ -18,8 +18,9 @@ fiber = require('fiber')
box.schema.user.grant('guest', 'execute', 'universe')
-- This is a workaround for flakiness of the test
--- appearing when another test tries to connect to
--- this one. By setting a flag for only one
+-- appearing when test-run does reconnects to the
+-- instance and therefore creates multiple
+-- sessions. By setting a flag for only one
-- session, others won't interfere in
-- session.on_disconnect().
function enable_on_disconnect() \
===========================================================================
> binary port) that run on another worker: all those sockets are placed in
> worker's directory. It seems that test-run itself doing some reconnects.
>
>> +-- this one. By setting a flag for only one
>> +-- session, others won't interfere in
>> +-- session.on_disconnect().
>> +function enable_on_disconnect() \
>> + box.session.storage.is_enabled = true \
>> +end
>> +
>> sid_before_yield = nil
>> sid_after_yield = nil
>> func = box.session.on_disconnect(function() \
>> + if not box.session.storage.is_enabled then \
>> + return \
>> + end \
>> sid_before_yield = box.session.id() \
>> fiber.yield() \
>> sid_after_yield = box.session.id() \
>> end)
>>
>> connection = net_box.connect(box.cfg.listen)
>> +-- Connections, not related to this one, won't
>> +-- call this function, and therefore won't do
>> +-- anything in session.on_disconnect() trigger.
>> +connection:call('enable_on_disconnect')
>> connection:ping()
>
> It seems that :ping() is not needed anymore.
>
Yes, it is not.
===========================================================================
diff --git a/test/box/gh-4627-session-use-after-free.result b/test/box/gh-4627-session-use-after-free.result
index 33e5a7af1..29144b098 100644
--- a/test/box/gh-4627-session-use-after-free.result
+++ b/test/box/gh-4627-session-use-after-free.result
@@ -61,10 +62,6 @@ connection = net_box.connect(box.cfg.listen)
connection:call('enable_on_disconnect')
| ---
| ...
-connection:ping()
- | ---
- | - true
- | ...
connection:close()
| ---
| ...
diff --git a/test/box/gh-4627-session-use-after-free.test.lua b/test/box/gh-4627-session-use-after-free.test.lua
index 1b2ebfdc4..18d56e203 100644
--- a/test/box/gh-4627-session-use-after-free.test.lua
+++ b/test/box/gh-4627-session-use-after-free.test.lua
@@ -42,7 +43,6 @@ connection = net_box.connect(box.cfg.listen)
-- call this function, and therefore won't do
-- anything in session.on_disconnect() trigger.
connection:call('enable_on_disconnect')
-connection:ping()
connection:close()
while not sid_after_yield do fiber.yield() end
===========================================================================
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Tarantool-patches] [PATCH 1/1] test: fix flaky box/gh-4627-session-use-after-free
2019-12-05 20:42 ` Vladislav Shpilevoy
@ 2019-12-05 22:53 ` Alexander Turenko
0 siblings, 0 replies; 4+ messages in thread
From: Alexander Turenko @ 2019-12-05 22:53 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: tarantool-patches
LGTM.
Pushed to master, 2.2 and 1.10.
CCed Kirill.
WBR, Alexander Turenko.
On Thu, Dec 05, 2019 at 09:42:11PM +0100, Vladislav Shpilevoy wrote:
> Hi! Thanks for the review!
>
> I submitted fixes to the branch.
> >> +-- This is a workaround for flakiness of the test
> >> +-- appearing when another test tries to connect to
> >
> > I tentative that another test may access to a unix socket (tarantool's
>
> I am sorry, but I don't understand - what do you mean as 'I tentative'?
> This is not a verb. You meant, that you guess, assume, doubt, investigated
> or something else?
>
> I assume you've meant 'I doubt', as so there is a fix:
Exactly.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-12-05 22:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03 0:05 [Tarantool-patches] [PATCH 1/1] test: fix flaky box/gh-4627-session-use-after-free Vladislav Shpilevoy
2019-12-04 11:35 ` Alexander Turenko
2019-12-05 20:42 ` Vladislav Shpilevoy
2019-12-05 22:53 ` Alexander Turenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox