Skip to content

Commit

Permalink
fix: exponential backoff upon refresh failure (#509)
Browse files Browse the repository at this point in the history
Fixed the format
  • Loading branch information
annafang-google committed Aug 29, 2023
1 parent a053400 commit d3d62cb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/cloudsql/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,13 @@ func (i *Instance) scheduleRefresh(d time.Duration) *refreshOperation {

// if failed, scheduled the next refresh immediately
if r.err != nil {
i.next = i.scheduleRefresh(0)
// Exponential backoff
if d == time.Duration(0) {
d = refreshInterval
} else {
d = 2 * d
}
i.next = i.scheduleRefresh(d)
// If the latest refreshOperation is bad, avoid replacing the
// used refreshOperation while it's still valid and potentially
// able to provide successful connections. TODO: This
Expand Down

0 comments on commit d3d62cb

Please sign in to comment.