-
Notifications
You must be signed in to change notification settings - Fork 43
Document new behaviour of session.on_disconnect #682
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
Comments
In what version did this occur? If it's a significant behaviour change, we have to say "starting in version x this incompatible change was made ...". But I wonder whether the version-10 documentation is already correct by accident, because it says |
The new behaviour appears since 1.10. As I know, beforehand on_disconnect triggers were called only after a last request has finished. Now they are called right after disconnect. If the documentation does not specify the time of triggers invocation, then maybe it should start specifying. |
Also, it is worth documenting that not all session properties are valid after disconnect. box.session.fd() will return -1, box.session.sync() will return 0, and box.session.push will return nil + error after disconnect. |
The manual says that the on_disconnect trigger function is called after disconnect. As far as I can tell, it does not wait for the last request to finish, but that is true in both version 1.9 and version 1.10. It does wait for other requests to yield,but that seems obvious -- otherwise how can the trigger function be called? Here is an example based on how I understand what you are saying. |
box.cfg{listen = 3313}
netbox = require('net.box')
fiber = require('fiber')
box.schema.user.grant('guest', 'read,write,execute', 'universe')
finish_long = false
disconnected = false
function long()
box.session.on_disconnect(function() disconnected = true end)
while not finish_long do fiber.sleep(0.01) end
end
c = netbox.connect(box.cfg.listen)
c:call('long', {}, {timeout = 0.01})
c:close()
disconnected -- (1), false in 1.9, true in 1.10
finish_long = true
while not disconnected do fiber.sleep(0.01) end
disconnected -- (2), true in both In 1.9 label (1) will print false, (2) - true. In 1.10 they both print true. |
Okay, I can add, following what I quoted previously: "Since version 1.10, the trigger function is invoked immediately after the disconnect, even if requests that were made during the session have not finished." It doesn't seem significant enough to deserve a warning about changed behaviour, since in the version 1.9 manual we don't say something different. And in section https://tarantool.io/en/doc/1.10/book/box/box_session/#box-session-id I will change "The result can be 0 meaning there is no session." because the result might be -1; plus in the overview I can add that some items become invalid after disconnect. |
|
Okay, I made the additions that I described, except that instead of putting something in the overview I added notes in id() and push() (we don't document fd). The mention of -1 is not about what one sees from the trigger function after disconnect, it merely is stated that -1 is a possible value. |
Now session.on_disconnect triggers are called right after disconnect. Not after a last request is finished.
The text was updated successfully, but these errors were encountered: