Repository navigation
Accept explicit zero reconnect backoff factor - #668
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. The core fix looks right, and the closed-port test that pins every delay at 1.00 s for factor 0 is a good way to lock down the documented behaviour. A few questions:
The parser change and tests look good. I'd mainly like an answer on (1) before merge, since it decides whether this PR also breaks input that used to work. |
|
I made the compatibility change explicit in the PR description: previously accepted infinity/overflow inputs and underflowing positive values now produce an argument error. Ordinary finite positive values, including large factors such as Fractional factors are preserved deliberately for compatibility. The man-page sentence describes their existing effect so users do not assume every positive factor increases delay. Adding a delay floor or requiring factors of at least one would change reconnect policy; this patch leaves that behavior unchanged while fixing explicit zero and validating numeric input. The risk of delay shrinking toward zero remains an existing limitation. |
Move the "zero keeps the delay at one second" note into usage() so make rebuild-man keeps it, and say that factors below 1 shrink the delay toward zero. Name the range failure in the parser error, since tiny positive values that underflow are rejected too. Add a closed-port test asserting factor 0 logs 1.00 s for every reconnect attempt, and note that --help exits 2 regardless, so the diagnostic is what proves rejection. Co-Authored-By: Claude Opus 5.5 <[email protected]>
7a848a5 to
013669b
Compare
|
Follow-up on the review points, now at 013669b (rebased on master):
|
…ests --help exits 2 whether or not the value is valid, so the rejection loop now uses --version (0 if accepted, 2 if rejected). Add a case where an earlier option's strtoul overflow leaves errno set to ERANGE; without the errno reset before strtod, a valid factor would be rejected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Answers to the updated review at 19658b8:
|
--retry-backoff-factor only checked "< 0" and trailing characters, so nan, inf, 1e9999, 1e-9999 and an empty value were accepted: nan silently meant constant backoff, inf/overflow jumped straight to the cap, an empty value meant 0, and the run's JSON recorded null for nan/inf. Move the validation #668 added for --reconnect-backoff-factor into one static parse_backoff_factor() helper (errno reset, endptr, ERANGE, isfinite, >= 0) and use it for both flags, so they accept exactly the same inputs: finite, representable numbers >= 0, including 0 and -0.0. Subnormal values that strtod reports with ERANGE are rejected as before for the reconnect flag. The retry error message now says "must be a finite, representable number >= 0". Adds tests/test_cli_validation_retry_backoff.py (accepted values, the same 19 invalid values as the reconnect test, errno carry-over), wired into the ASan/TSan/UBSan cli selections. It fails on master and passes here. Fixes #687 Co-Authored-By: Claude Opus 5.5 <[email protected]>
--reconnect-backoff-factor=0previously exited with an argument error even though zero is the documented default. Accept explicit zero so wrappers can pass the default value directly.Require a fully parsed, finite, nonnegative factor and reject out-of-range conversions, including underflow that could otherwise turn a negative input into zero. Positive fractional factors remain supported. Clarify the existing behavior in
--helpand the man page: zero keeps the one-second delay, while positive factors multiply it. Reconnect scheduling is unchanged. This intentionally tightens validation for previously accepted infinity/overflow inputs and underflowing positive values; they now produce an argument error.Validation:
make check: 6 passed. Formatting and staged C++ hook passed.test_reconnect_backoff_zero_keeps_one_second_delaypins the documented zero behaviour: against a closed port, every logged reconnect delay is 1.00 s (fails with 0.00 s if the> 0.0guard is changed to>= 0.0).--help, somake rebuild-mankeeps them; the man page matches help2man output.1e308remains the finite replacement for the previously acceptedinf.Fixes #658.
Note
Low Risk
Narrow CLI parsing and documentation change with regression tests; previously accepted non-finite or overflow inputs now error at startup.
Overview
Fixes
--reconnect-backoff-factor=0being rejected at parse time even though zero is the documented default. Validation now accepts any finite, nonnegative value (including explicit0and fractional factors) and rejects garbage, negatives, NaN/inf, and overflow/underflow fromstrtod, witherrnocleared so a prior option’s parse error cannot spuriously fail this flag.Help and
memtier_benchmark.1now state that zero keeps a 1 s reconnect delay and positive values multiply it per attempt. A newtest_cli_validation_reconnect_backoff.pysuite covers successful runs, invalid inputs, and the 1.00 s delay behavior against a closed port. ASan/TSan/UBSan TLS matrix cells include the new test file.Reviewed by Cursor Bugbot for commit 19658b8. Bugbot is set up for automated code reviews on this repo. Configure here.