Skip to content
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

retry.Retryable(): treat ENOENT (AF_UNIX) like ECONNREFUSED, i.e. also retry #583

Conversation

Al2Klimov
Copy link
Member

During connect(2) we may get ECONNREFUSED between server's bind(2) and listen(2), but the most downtime between boot and service start the socket won't exist, yet. I.e. ENOENT is the de facto ECONNREFUSED of *nix sockets.

Tested this new commit vs. its parent commit. Test case - see:

fixes #543

Copy link
Member

@yhabteab yhabteab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works!

2023-05-24T17:10:33.241+0200    INFO    icinga-notifications    Connecting to database at '/run/postgresql'
2023-05-24T17:10:33.242+0200    WARN    database        Can't connect to database. Retrying     {"error": "dial unix /run/postgresql/.s.PGSQL.5432: connect: no such file or directory"}
2023-05-24T17:15:33.242+0200    FATAL   icinga-notifications    cannot connect to database      {"error": "can't connect to database: can't retry: dial unix /run/postgresql/.s.PGSQL.5432: connect: no such file or directory", "errorVerbose": "dial unix /run/postgresql/.s.PGSQL.5432: connect: no such file or directory\ncan't retry\ngithub.com/icinga/icingadb/pkg/retry.WithBackoff\n\t/Users/yhabteab/Workspace/go/src/icingadb/pkg/retry/retry.go:78
...

@@ -114,7 +114,7 @@ func Retryable(err error) bool {
// which is not considered temporary or timed out by Go.
err = opError.Err
}
if errors.Is(err, syscall.ECONNREFUSED) {
if errors.Is(err, syscall.ECONNREFUSED) || errors.Is(err, syscall.ENOENT) {
// syscall errors provide Temporary() and Timeout(),
// which do not include ECONNREFUSED, so we check this ourselves.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please adjust the comment here as well.

…o retry

During connect(2) we may get ECONNREFUSED between server's bind(2) and
listen(2), but the most downtime between boot and service start the socket
won't exist, yet. I.e. ENOENT is the de facto ECONNREFUSED of *nix sockets.
@Al2Klimov Al2Klimov force-pushed the inconsistent-retry-behavior-between-tcp-and-unix-sockets-543 branch from a73e398 to a3c1007 Compare June 5, 2023 09:21
@Al2Klimov Al2Klimov requested a review from lippserd June 5, 2023 09:21
@julianbrost julianbrost merged commit 049a62b into master Jun 5, 2023
32 checks passed
@julianbrost julianbrost deleted the inconsistent-retry-behavior-between-tcp-and-unix-sockets-543 branch June 5, 2023 10:52
@julianbrost julianbrost added this to the 1.2.0 milestone Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent retry behavior between TCP and UNIX sockets
4 participants