Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The call
ZManaged.fromAutoCloseable
does not catch exceptions thrown onconnection.close()
but instead directly proceeds to the die-channel. This makes sense for ZIO because resource-releases are typically indicative of filesystem-level resource leaks (e.g. open-file handles). However, for JDBC this does not make sense.My Personal Thoughts about this issue:
Typically I think of finalizers as something you need to do in order to avoid OS-level resource leaks e.g. open-file handles, database connetions are a little different. They're a resource that can leak but when they do, the application should not have a panic-attack because ultimately the connection pool will "take care of it" and if it doesn't, the Database will. That's not to say that in high-system-stress production scenarios, Database resource leakage isn't dangerous, it most definitely is! However the way you typically deal with that is by putting circut breakers on the incoming user-connections and let 'enough time pass' so that the DB can kill off the connections that it can't serve. What you absolutely don't want to do is to kill the whole application since if you do, when it starts back up it will immediately hammer the DB with requests that have probably been buffered upstream.
It's interesting to note that in practice, nearly all of the cases where I've seen
connection.close()
fail is where a connection becomes stale (because it's held by a user-thread which is blocked by something else) and the database times out the connection. In practice, most good JDBC implementations try not to throw exceptions on aconnecction.close()
if another exception has already been thrown (especially if these connections are pooled!) but the JDBC API was designed to allow the former scenario to happen.@getquill/maintainers