-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
96161: ccl/sqlproxyccl: fix possible NPE within the connector r=JeffSwenson a=jaylim-crl Related: https://github.com/cockroachlabs/support/issues/2040 Previously, an invariant is violated where it was possible to return err=nil when the infinite retry dial loop exits. When that happens, callers would attempt to read from the net.Conn object, which is nil, leading to a panic. The invariant is violated whenever the context that was passed down to `dialTenantCluster` gets cancelled or expires. In particular, this can happen in two cases: 1. when the main stopper stops 2. when a connection migration process hits a timeout (of 15 seconds) The first case is rare since this has to happen in concert with a transient failure to dial the SQL server. Here's one example for the second case: 1. we block while dialing the SQL server 2. while we're waiting for (1), transfer hits a timeout, so context gets cancelled 3. (1) gets unblocked due to a timeout 4. err from (1) gets replaced with the error from ReportFailure 5. retry loop checks for context cancellation, and exits 6. we end up returning `nil, errors.Mark(nil, ctx.Err())` = `nil, nil` The root cause of this issue is that the error from ReportFailure replaced the original error, and usually ReportFailure suceeds. This commit fixes that issue by not reusing the same error variable for ReportFailure. Epic: none Release note: None Co-authored-by: Jay <[email protected]>
- Loading branch information
Showing
2 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters