-
Notifications
You must be signed in to change notification settings - Fork 97
Fix goroutine and connection leak on database connect #59
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 goroutine and connection leak on database connect #59
Conversation
CI didn't like my go.sum. How can I fix it? |
Hey @EldarKurbanov you'll need to run Regarding the test coverage changes I'd imagine you probably only need to verify no leak in one of the top level tests as they cover almost all the code and run on every operating system. |
Could you help me a bit and clarify a few things: if I understood correctly, I need to leave a check for a goroutine leak only in one test? |
Hi @EldarKurbanov apologies for the delay. Yes I suggest this is probably only actually needed inline inside the We also should attempt to keep the coverage above 90% as a general rule project so users can be confident from a glance we're reliable. Is there anything you can do to get those extra lines you've added covered? |
I would really be very happy if you could tell me how I can check my added code that close the connection to the database. The only one the way I see for increase test coverage is by adding a mock to the database connection. I can do it if there are no better ideas and no one will mind. |
I removed |
Looks much better! I think you're correct maybe wrapping There are some good examples of making sure these error cases are covered in |
Thank you for your suggestion! But I found an easier way to test the database connection closing code, wrote a test for it, and the coverage increased. I would be very glad to hear your opinion about the rewritten code. |
Hey @EldarKurbanov sorry this has taken so long! I needed some bandwidth to get my head around your changes. They make sense to me now. I may try and clean up a little in the next few releases to align better with the style of the rest of the code, and make the tests a little more verbose, but functionally this looks great. Thanks for your contribution and hopefully this helps resolve your issues! |
Closes #58
I also added a goroutine leak detector to prevent unclosed connections in the future and one exception for goroutine leak detector, since I did not find how to fix it.