-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hotreloadability #10
Conversation
Thanks! I got the idea and it looks okay on the first glance. I'll look deeper soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patch. I left several comments. They are quite minor and some of them maybe could be skipped.
test:test('hotreload', function(test) | ||
test:plan(2) | ||
|
||
_G.tuple = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that "tuple" defined in global affect something. It seems an artefact of luaL_register
usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. I think it should not be so, it is the mistake.
Anyway, while the global is set at the module initialization, it looks meaningful to drop it in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll propose a fix after PR #15. Too much PRs in the fly :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The draft commit is a56ff5d (as said, I'll open a PR later).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened PR #16.
collectgarbage() | ||
collectgarbage() | ||
|
||
tuple_keydef = require('tuple.keydef') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case when this line fails all following tests will be stopped. I suggest to use something like:
local ok, tuple_keydef = pcall(require, 'tuple.keydef')
test:ok(ok)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However a next test case definitely will fail due to tuple_keydef = nil
. We can move the test to a separate file or pass it over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In PR #15 I moved those test cases into its own file. I wrapped require()
into pcall()
, where the goal of a test case is to verify, whether it succeeds. However I found it unconvenient to wrap a preparation code into pcall()
(or wrap each test case into pcall()
). So, in fact, nothing changes: if one test case will fail, others will not run.
If we'll move toward luatest, it'll handle this problem for us. But prior that I would disregard it.
CTID_STRUCT_TUPLE_KEY_DEF_REF = | ||
luaL_ctypeid(L, "struct tuple_keydef *"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure it's related to current patch and current problem. But is it possible to eliminate this call at all (https://github.com/tarantool/tarantool/blob/35dd826460e876c6cdb1ab7395ef7a5064615d2b/src/lua/utils.c#L141)?
E.g. initialize CTID_STRUCT_TUPLE_KEY_DEF_REF by default (with e.g. 0) and then call luaL_ctypeid
only if value is 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I'm not sure I got the idea. Do you propose to set it at the first load and don't touch on next reloads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you propose to set it at the first load and don't touch on next reloads?
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. I don't know, whether I should do or don't. The behaviour is exactly same. I left it as is in PR #15, it is out of scope there.
I proposed an alternative fix in PR #15. My doubts about this implementation (PR #10) are the following:
Since all those points may be eliminated, I think that they should be eliminated. I did it in PR #15. |
Superseded by PR #15. |
Gracefully handle hotreload. It didn't work because
postload.lua
always tried to callffi.metatype()
, but luajit doesn't allow to do it twice for the same type.Fixes #9.