-
Notifications
You must be signed in to change notification settings - Fork 148
Description
Hello,
I observed an issue where trying to reopen a connection to a previously accessed database causes the sql.Open()
function to hang. The situation looks like the following:
- Connection was opened to
x.db
- Connection to
x.db
was closed. - Connection was opened to
y.db
. - Connection to
y.db
was closed. - Connection to
x.db
was supposed to open considering that I've closed it before but it doesn't. It just hangs indefinitely.
On delving deeper into the issue, I noticed that this originates from the InstanceCache not being invalidated. I suppose that the stale cache assumes that the connection already exists but cannot find it hence causes it to malfunction. On reading through the go bindings lib, the comments above CreateInstanceCache
state that the cache should be destroyed with DestroyInstanceCache
.
This function was missing from the implementation for the library, which I think is the cause of my issue. I'm not entirely sure about my solution but I propose adding in an invalidation function too which could be called when the connection is closed?
Here are the references to the code blocks where:
- The connection is opened with the cache being created
- The singleton cache which doesn't update
- Where closing the connection should invalidate the cache too
I'm new to this so perhaps my solution may not be the best, but I'll raise a PR open to critique.
Thanks for creating and maintaining the library!