Repository navigation
Conversation
fff4082 to
405eed5
Compare
zyin-squareup
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent on behalf of @zyin-squareup.
Summary: LGTM. timeout-connect now actually reaches the go-sql-driver DSN. I checked:
dbconn/factory.go:98/:148: parsing happens after my.cnf defaults are applied. Empty falls back toDEFAULT_MONITOR_TIMEOUT_CONNECT, which covers callers that skip defaults, like the global plan-table path inplan/loader.go:106.0leaves out the param, and negative or invalid values return an error.Makeis the onlysql.Openpath for monitor, plan loader, and heartbeat connections.Repo.ReloadDSN(dbconn/reload_password.go:39-72) doesParseDSN→FormatDSN, soTimeoutsurvives a credential hotswap.TestConnectTimeoutReloadDSNcovers this.- In go-sql-driver v1.8.1,
timeoutonly setsnet.Dialer.Timeout. It does not limit queries on an established connection, which matches the updated docs. - I ran
go test ./dbconn -run TestConnectTimeout -vlocally and all tests pass.TestConnectTimeoutBoundsDialfailed after 1.0s withdial tcp 10.255.255.1:3306: i/o timeout.
Non-blocking:
- Upgrade behavior for malformed values. A config that used to have a bad
timeout-connect(for example"10"with no unit) was silently ignored before. NowMakereturns an error, so that monitor won't start or connect. Nothing inconfig.govalidates this field, so the error only appears per monitor at runtime, not at boot. Consider validating it in the config validation path so it fails fast, and/or adding a release note next to the "default is now 10s" note. - Network-dependent test.
TestConnectTimeoutBoundsDialdials10.255.255.1during a normalgo test ./...and is skipped only with-short. The 20s context backstop keeps it from hanging, and the pass condition holds whether the network drops or rejects the packets, so this is fine. Just be aware it depends on the CI runner's network.
405eed5 to
8c97089
Compare
zyin-squareup
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent on behalf of @zyin-squareup.
Re-approving after the rebase. The new head 8c97089 has the same content as 405eed5, which I approved earlier: dbconn/factory.go, dbconn/factory_test.go and docs/content/config/config-file.md have the same blob SHAs (278c268, 7200eba, ffb62ec). The only changes come from the updated #187 base, which touches monitor/sink/status, not dbconn. My earlier review still applies, including the two non-blocking notes: malformed timeout-connect values now fail per monitor in Make instead of at config validation, and TestConnectTimeoutBoundsDial depends on the network.
CI was still queued when I checked.
8c97089 to
1aff2f2
Compare
zyin-squareup
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent on behalf of @zyin-squareup.
Re-approving after the rebase onto #187's new head (54b2026). The new head 1aff2f2 has the same content in this PR as 8c97089 and 405eed5, which I approved earlier. dbconn/factory.go, dbconn/factory_test.go and docs/content/config/config-file.md have the same blob SHAs (278c268, 7200eba, ffb62ec). The neighbouring code I checked last time is also unchanged: dbconn/reload_password.go, plan/loader.go and go.sum. The rest of the compare diff comes from the updated #187 base (monitor/sink/status), not from this commit. CI (build, Semgrep, zizmor, DCO) is green on 1aff2f2.
My first review still applies, including its two non-blocking notes:
- A malformed
timeout-connectvalue now fails per monitor inMakeinstead of at config validation. TestConnectTimeoutBoundsDialdepends on the network.
config.monitor.timeout-connect (default 10s) was parsed and merged but never reached the go-sql-driver DSN, so the driver dialed with no timeout. When a host drops packets, every new connection waited for the kernel's TCP SYN retries (about 130s on Linux) instead of failing fast. The connection factory now sets the DSN "timeout" param from timeout-connect. An empty value uses the default (10s), zero disables the timeout (previous behavior), and an invalid or negative value is a config error from Make. All Blip MySQL connections (monitor, plan loader, heartbeat, etc.) come from this factory, and the hotswap credential reload preserves the param. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1aff2f2 to
4dbb925
Compare
zyin-squareup
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent on behalf of @zyin-squareup.
Re-approving after the rebase onto #187's new head (371659c). This PR's content at 4dbb925 is the same as 1aff2f2, which I approved earlier. dbconn/factory.go, dbconn/factory_test.go and docs/content/config/config-file.md have the same blob SHAs (278c268, 7200eba, ffb62ec). The neighbouring code is also unchanged: dbconn/reload_password.go, plan/loader.go, config.go, go.mod and go.sum. git diff --stat 371659c 4dbb925 shows only those three files. The new base commit 371659c changes only counter docs (docs/content/api/status.md, monitor/monitor.go, status/counters.go) and doesn't touch dbconn.
I didn't rerun the tests locally this round because the code is the same as what I tested before. On 4dbb925, CI build (both jobs), zizmor and DCO pass. Semgrep was still queued when I checked.
My first review still applies, including its two non-blocking notes:
- A malformed
timeout-connectvalue now fails per monitor inMakeinstead of at config validation. TestConnectTimeoutBoundsDialdepends on the network.
A malformed timeout-connect (for example "10", with no unit) was only caught by the connection factory, inside the monitor's startup loop. That loop retries making the DB connection forever, so the monitor never collected and the only trace was its status. Config.Validate now checks config.mysql.timeout-connect, so a bad default fails at server boot. ConfigMonitor.Validate checks config.monitor.timeout-connect for MySQL monitors, so a bad value fails the monitor load like any other invalid field. Empty and zero remain valid. The factory check stays as a backstop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🤖 Thanks for the two non-blocking notes.
|
zyin-squareup
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent on behalf of @zyin-squareup.
Re-reviewed at 9a11cc4. The first commit, 4dbb925, is unchanged from my last approval: git diff 4dbb925 9a11cc4 touches only config.go, config_test.go, monitor/loader_test.go and the release notes. So this review covers just the new validation commit.
My earlier notes:
- Malformed
timeout-connectonly failed per monitor inMake. Fixed and pinned.ConfigMySQL.Validate(config.go:919) runs fromConfig.Validateat boot. That happens afterInterpolateEnvVars(server/server.go:172-174).ConfigMonitor.Validate(config.go:478) runs fromLoader.saveafter defaults and both interpolation passes (monitor/loader.go:426-432). Every load source goes throughsave: plugin, config file, monitor files and AWS.config.plans.monitoris covered too, throughConfigPlans.Validate→ConfigMonitor.Validate.- Empty values still pass, so monitors that skip defaults keep falling back to the factory's 10s default. Zero is still valid.
- The release note covers the stricter validation.
TestConnectTimeoutBoundsDialdepends on the network. The author chose to keep it, and I agree. The 20s context backstop stops it hanging, and the pass condition holds whether the network drops or rejects the packets.
Pin check (from the assertions, not mutation runs): the strings invalid config.mysql.timeout-connect and invalid config.monitor.timeout-connect only come from the two new validTimeoutConnect calls. If either call is removed, TestValidateTimeoutConnect fails. If the monitor check is removed, TestLoaderInvalidTimeoutConnect fails because Load no longer returns that error. I couldn't run actual mutations because the scratch checkout is read-only for edits.
Validation: I ran go test . ./dbconn ./monitor -run 'TestValidateTimeoutConnect|TestApplyDefaultConfig|TestConnectTimeout|TestLoaderInvalidTimeoutConnect' -count=1. It exited 0 and all 6 tests passed; TestConnectTimeoutBoundsDial took 1.00s. CI build and DCO are green on 9a11cc4.
Non-blocking:
- The PR description's "How" section still says an invalid value "is a config error from
Make". It's now rejected when the config loads, withMakeas a backstop. Consider updating that line.
Why
config.monitor.timeout-connect(default10s) is parsed but never reaches the MySQL driver's DSN, so the driver dials with no timeout. When a host drops packets, each new connection waits for the kernel's TCP SYN retries, about 130 s on Linux, instead of failing fast.What
The connection factory sets the DSN
timeoutparam fromtimeout-connect.How
10s).0disables the timeout, which was the old behavior.mysql.timeout-connectat server boot andmonitor.timeout-connectwhen the monitor loads.Makekeeps the same check as a backstop.Risk
Medium. Every MySQL connection now has a 10 s dial timeout by default. A server that takes longer than that to accept a connection now fails where it used to wait. Set
timeout-connect: 0to get the old behavior.Testing
A local benchmark against MySQL 8.0 servers put a half-open network partition between Blip and one server.
Bigger picture
Part of a stack of 5 fixes found by the same benchmark. This one doesn't depend on #187's code. It sits on top only to keep the stack linear.
🤖 Generated with Claude Code