-
Notifications
You must be signed in to change notification settings - Fork 28
Add cleanup function. #210
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
Conversation
Hmm, this is new to me. Any recommendation on how mysqln's pool could be improved in this regard, or what specifically the problem is?
Ahh, mysqln's travis tests have been getting that, too. I wonder if there's any way this could be used to fix that? I'd guess maybe not, at least not without too much trouble, just because of the way D testrunners work (no real concept of "last line of code before exiting" or "on exit hook" that I'm aware of).
It should be easy enough to build the docs yourself, just run the "./build-docs" script. If that doesn't work right out-of-the box go ahead and file an issue. In any case, if the function only exists under certain conditions, that should probably be explained in the function's docs.
The 0.8.6 is Bear in mind, since I switched it to |
| /++ | ||
| Removes all unused connections from the pool. This can | ||
| be used to clean up before exiting the program to | ||
| ensure the event core driver can be properly shut down. |
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.
If this function only exists under certain conditions, that should probably be explained in its doc comments here.
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.
Updated
Well, the specific problem is that |
Both vibe-d:core and vibe-core (I think version 1.7.0+) have the function available I think. What I meant is that if you link this against earlier versions of the library (maybe for other reasons), this function would not be available. |
This is callable at any time. All it does is close any unused connections that have not been closed (i.e. they are in the pool but nobody has any references to them). So I'd say go ahead and put a |
Hmm, I guess I’m just unclear/confused about what you’re talking about with this:
I think I’m just having a bit of a brain fart moment on this. IIUC: You’re saying there’s some new functionality in vibe’s connection pool that (due to the design of mysql-native’s connection pool) is difficult to use/expose in mysql-native’s connection pool. And therefore, the next best thing that can be done is simply to add this
You may be right about that…
Ah, ok, so there are older versions of vibe-core that lack it. That’s fine then. Maybe just one more adjustment to the docs then about how
Honestly, I wouldn’t worry too much about it. That would just mean the tests would constantly be re-creating new connections, which would just slow the tests down, and travis is already taking like 3-4 minutes on most of these jobs. If there were a trivial way to just to it once after all the tests were complete, then that’d be great, but as things stand, I don’t it’s worth it just to silence a few benign warnings at the end of the tests. |
Oh, yeah, definitely it's not possible to call the functionality because the |
about squelching exceptions. Also fixed some spacing.
Done |
Ah, ok, I see.
Yea, I'd have to go digging around there again to be certain exactly what would happen, but it's definitely not a recommended approach, especially since the prepared statements are now pretty much the default and get used behind-the-scenes (rather than something you have to go out of your way to deliberately use, which is part of the whole intent). So this all looks good now. The second commit is just comments and whitespace, so I think we can safely skip waiting for travis and trust its initial OK. |
Vibe-core now includes a mechanism to clean up all unused connection pool connections so the event driver can be properly destroyed. The way mysql-native's pool wraps vibe's ConnectionPool makes it difficult to reproduce the same functionality AND provide access to the cleanup function. In addition, this makes sure it does the cleanup properly.
In my code, if I don't have this function, I get "Leaking eventcore driver" messages.
I tried to make sure this properly shows up in the docs, we'll see what happens. I also tried to ensure this function only gets defined for vibe-core that supports it (requires 0.8.6). We will see if the CI accepts that.