Skip to content

Commit

Permalink
fix: update ForceRefresh to block if invalid (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwotherspoon authored Aug 18, 2023
1 parent 95371dd commit 61c72e3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/cloudsql/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (i *Instance) UpdateRefresh(cfg RefreshCfg) {

// ForceRefresh triggers an immediate refresh operation to be scheduled and
// used for future connection attempts. Until the refresh completes, the
// existing connection info will be available for use.
// existing connection info will be available for use if valid.
func (i *Instance) ForceRefresh() {
i.refreshLock.Lock()
defer i.refreshLock.Unlock()
Expand All @@ -269,6 +269,11 @@ func (i *Instance) ForceRefresh() {
if i.next.cancel() {
i.next = i.scheduleRefresh(0)
}
// block all sequential connection attempts on the next refresh operation
// if current is invalid
if !i.cur.isValid() {
i.cur = i.next
}
}

// refreshOperation returns the most recent refresh operation
Expand Down

0 comments on commit 61c72e3

Please sign in to comment.