You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
During boot or restarts of postgresql, it might be, that the connection is temporarily unavailable. We should a) open connections on-demand (only open it, when we try to use it the first time) and b) retry a limited number of times (e.g. exponential backoff), when an error occured due to it closing unexpectedly. database/sql apparently doesn't expose a special error for that, so we have to investigate whether we can catch that in other ways (e.g. if it passes through an error about reading/writing to a closed socket) or need to do a catch-all, on error reopen connection thing.
This is the same issue as #5 and should be resolved in the same way.
The text was updated successfully, but these errors were encountered:
After looking at http://godoc.org/database/sql#Open I think it should be enough to just open the connection on the first use. For that, I recommend:
• Adding a sync.Mutex as a global variable to protect db against concurrent changes
• Write a helper function, that Locks the mutex, checks if db is nil and if not, opens a connection. Then it returns the (possibly new) Pointer db and an error, if any occured
• Use this helper function in all sql-functions to get a *DB and use that.
• Remove the code from main, opening a connection.
During boot or restarts of postgresql, it might be, that the connection is temporarily unavailable. We should a) open connections on-demand (only open it, when we try to use it the first time) and b) retry a limited number of times (e.g. exponential backoff), when an error occured due to it closing unexpectedly. database/sql apparently doesn't expose a special error for that, so we have to investigate whether we can catch that in other ways (e.g. if it passes through an error about reading/writing to a closed socket) or need to do a catch-all, on error reopen connection thing.
This is the same issue as #5 and should be resolved in the same way.
The text was updated successfully, but these errors were encountered: