Repository navigation
Conversation
panavenue
force-pushed
the
metrics-open-conns-test
branch
from
October 21, 2026 18:26
7dedf97 to
80d4a4d
Compare
…e close The AlloyDB connector hit a race (alloydb-go-connector#820) where the OpenTelemetry open_connections increment ran in a background goroutine while the decrement in instrumentedConn.Close was synchronous, so prompt closes drove the up/down counter negative. The Cloud SQL dial path records all OpenTelemetry measurements synchronously and in order, so the bug does not apply here; this test guards against introducing it. Verified the test fails (-1) if the increment is moved into a goroutine.
panavenue
force-pushed
the
metrics-open-conns-test
branch
from
October 23, 2026 04:19
80d4a4d to
d90ea95
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the AlloyDB finding in GoogleCloudPlatform/alloydb-go-connector#820 (
open_connectionscould go negative because the OTel increment ran in a goroutine while the decrement ininstrumentedConn.Closewas synchronous).Cloud SQL does not have the bug: every OpenTelemetry record on the dial path is synchronous and happens before the
net.Connis returned, so a decrement cannot precede its increment (dialer.gosuccess path:RecordOpenConnection→RecordConnectLatencies→RecordOpenConnectionCount→ return;closeFunccan only run afterwards).This PR adds a regression test only: 20 dial + immediate close pairs against the mock instance, then asserts every exported
open_connectionspoint is 0. Verified that temporarily moving the increment into a goroutine (as AlloyDB had) makes it fail withopen_connections exported -1.No production code changes.