-
Notifications
You must be signed in to change notification settings - Fork 55
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
Database:onDisconnect() callback feature request #135
Comments
So if I understand correctly you would require a In the meantime, you can already implement this yourself (although somewhat more tedious) by keeping track of the number of running queries, increasing when launched, and decreasing when any callback is called (abort/error/success). Apart from that, I am not sure why you don't just immediately remove the database instance from the table. If the same player reconnects you cannot reuse the old, disconnected db instance anyways, right? Also, have you considered using a single db instance for all the queries related to inventory operations? That way you get the sequential order you want and you won't overload your database with too many connections. (most databases cannot handle 100 connections at the same time and will error. |
Thats correct regarding the callback. I decided that way so a player couldnt throttle the queue maliciously (only his own) somehow. A lot of my queries rely on others/daisy-chained in the success callback |
Just for your particular use case I'd suggest ensuring that the queue isn't overloaded by rate limiting player actions. If one connection is still not enough, I'd suggest using a static pool of say 5 connections and assigning each player to one of the 5 connections when they join, that way you still have the guaranteed order of operations. |
Its a bit more complicated then that, I appreciate your input though. Id have to consider a lot of edge cases with different methods, id rather keep things simple given how economy driven my server is its important that weird things dont occur. Its unlikely someone will throttle their own queue, but its vital theyre in order - my own current concern is just killing the stale references in the global table. That being said its not a massive issue as the map changes every 30 minutes or so, i like to keep things clean. |
This is now done in the latest beta release, please let me know if it works for you! |
My current setup is each player has their own connection, this ensures that any actions they do with my inventory system are completed in order - however, my global table of connections can become stale and essentially a memory leak.
With the above scenario, SQL_CONS will still maintain an index with an disconnected connection that is not needed.
I have no way of detecting the successful disconnection to clear out the value in the global table - I'm going to write a timer that will check the connections every 10 minutes or so and drop stale references, but it would be nice to clear it out as soon as the queue is empty.
The text was updated successfully, but these errors were encountered: