Skip to content

Commit 54c44ce

Browse files
committed
dashboard/dashapi: retry requests on errors
API requests episodically fail due to internal datastore errors, some timeouts, etc. Failure of some requests is especially unpleasant and leads to lots of wasted work (uploading of syz-ci build info, job completion, etc). So we retry requests several times. We do this always for all requests, since we don't expect any of them to legitimately fail (we don't send malformed requests), and it won't harm for any request types.
1 parent b99f5fb commit 54c44ce

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

dashboard/dashapi/dashapi.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -992,15 +992,28 @@ func (dash *Dashboard) Query(method string, req, reply any) error {
992992
if dash.logger != nil {
993993
dash.logger("API(%v): %#v", method, req)
994994
}
995-
err := dash.queryImpl(method, req, reply)
996-
if err != nil {
997-
if dash.logger != nil {
998-
dash.logger("API(%v): ERROR: %v", method, err)
999-
}
1000-
if dash.errorHandler != nil {
1001-
dash.errorHandler(err)
995+
for try := 0; ; try++ {
996+
err := dash.queryImpl(method, req, reply)
997+
if err != nil {
998+
if dash.logger != nil {
999+
dash.logger("API(%v): ERROR: %v", method, err)
1000+
}
1001+
if dash.errorHandler != nil {
1002+
dash.errorHandler(err)
1003+
}
1004+
// API requests episodically fail due to internal datastore errors, some timeouts, etc.
1005+
// Failure of some requests is especially unpleasant and leads to lots of wasted work
1006+
// (uploading of syz-ci build info, job completion, etc). So we retry requests
1007+
// several times. We do this always for all requests, since we don't expect any of them
1008+
// to legitimately fail (we don't send malformed requests), and it won't harm for any
1009+
// request types.
1010+
if try < 3 {
1011+
time.Sleep(time.Second)
1012+
continue
1013+
}
1014+
return err
10021015
}
1003-
return err
1016+
break
10041017
}
10051018
if dash.logger != nil {
10061019
dash.logger("API(%v): REPLY: %#v", method, reply)

0 commit comments

Comments
 (0)