forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net.box: reference the connection object from asynchronous requests
In order to prevent the garbage collection of the discarded connection, asynchronous requests must reference the connection object. We must reference the connection object rather than the transport object, because our garbage collection hook is attached to the former. Closes tarantool#9629 NO_DOC=<bugfix>
- Loading branch information
1 parent
40bd0eb
commit 4a5b793
Showing
4 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
changelogs/unreleased/gh-9629-netbox-async-request-connection-gc.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## bugfix/lua | ||
|
||
* Fixed a bug in `net.box` the allowed a connection with asynchronous requests | ||
to get garbage collected (gh-9629). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
test/box-luatest/gh_9629_netbox_async_request_connection_gc_test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
local net_box = require('net.box') | ||
local server = require('luatest.server') | ||
local t = require('luatest') | ||
|
||
local g = t.group() | ||
|
||
g.before_all(function(cg) | ||
cg.server = server:new() | ||
cg.server:start() | ||
end) | ||
|
||
g.after_all(function(cg) | ||
cg.server:drop() | ||
end) | ||
|
||
-- Tests that a connection with asynchronous requests does not get garbage | ||
-- collected. | ||
g.test_async_request_connection_gc = function(cg) | ||
local c = net_box.connect(cg.server.net_box_uri) | ||
local f = c:eval('return 777', {}, {is_async = true}) | ||
c = nil -- luacheck: no unused | ||
collectgarbage() | ||
local res, err = f:wait_result(0.1) | ||
t.assert_equals(err, nil) | ||
t.assert_equals(res[1], 777) | ||
end |