Skip to content

Commit

Permalink
align with grpc base/balancer to trigger reconnect in Idle state (whe…
Browse files Browse the repository at this point in the history
…n we move to gRPC 1.41+) (#335)

* build(deps): bump github.com/prometheus/client_golang

Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.11.0 to 1.11.1.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](prometheus/client_golang@v1.11.0...v1.11.1)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* align with grpc base/balancer to trigger reconnect in Idle state

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
ddowker and dependabot[bot] authored Nov 21, 2023
1 parent dfed675 commit def1636
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
13 changes: 12 additions & 1 deletion broker/protocol/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,19 @@ func (d *dispatcher) UpdateSubConnState(sc balancer.SubConn, state balancer.SubC
panic("unexpected SubConn")
}

if state.ConnectivityState == connectivity.Connecting && d.connState[sc] == connectivity.TransientFailure {
if (state.ConnectivityState == connectivity.Connecting || state.ConnectivityState == connectivity.Idle) &&
d.connState[sc] == connectivity.TransientFailure {
// gRPC will quickly transition failed connections back into a Connecting
// state. In many cases, such as a remote-initiated close from a
// shutting-down server, the SubConn may never return. Until we see a
// successful re-connect, continue to consider the SubConn as broken
// (and trigger invalidations of cached Routes which use it).

if state.ConnectivityState == connectivity.Idle {
sc.Connect()
}
d.mu.Unlock()
return
} else {
d.connState[sc] = state.ConnectivityState
}
Expand All @@ -132,6 +139,10 @@ func (d *dispatcher) UpdateSubConnState(sc balancer.SubConn, state balancer.SubC
delete(d.connID, sc)
delete(d.connState, sc)
}

if state.ConnectivityState == connectivity.Idle {
sc.Connect()
}
d.mu.Unlock()

// Notify gRPC that block requests may now be able to proceed.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/olekukonko/tablewriter v0.0.5
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/client_golang v1.11.1
github.com/prometheus/client_model v0.2.0
github.com/sirupsen/logrus v1.8.1
github.com/soheilhy/cmux v0.1.5
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ=
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.11.1 h1:+4eQaD7vAZ6DsfsxB15hbE0odUjGI5ARs9yskGu1v4s=
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down

0 comments on commit def1636

Please sign in to comment.