Skip to content

praefect: Praefect should not hang if db is not reachable

Pavlo Strokov requested to merge ps-db-connect-hangs into master

If the database is not accessible the at the time of Praefect start it hangs forever and doesn't report much information about the reason. The attempt to fix it by using PingContext with timeout set on the context failed because of the issue in the lib/pq that is not yet fixed. The problem is solved by a separate goroutine that issues the PingContext and main goroutine watching the timeout. If timeout occurs it returns an error up to the caller. Another goroutine won't be over and hangs, but we don't care much as it is a critical error and the service will be terminated.

The log message about listening addresses moved closer to the place where the service starts to actually listen on this addresses as before message was printed too early.

Closes: #3678 (closed)

Merge request reports