Skip to content

Fail the process when imported data verification fails - #771

Merged
fcostaoliveira merged 4 commits into
masterfrom
codex/20261017-pr768
Oct 17, 2026
Merged

fcostaoliveira merged 4 commits into
masterfrom
codex/20261017-pr768

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

--data-verify and --verify-only report missing keys, mismatched values, and error replies but exit 0. A pass receiving no verification replies also appears successful to shell callers.

Root cause

main() prints the verification counters and destroys the verifier without using those counters in the final exit status.

Fix

Preserve a verification-failure flag until normal teardown completes. Any failed key, a pass with zero verified keys, or a partial pass interrupted by connection loss exits 1, with a concise stderr summary. Completion uses the configured generated-request budget and the actual verification GET count, preserving default-ratio skips and repeated passes over the import file. Successful verification stays at 0; benchmark connection-stage aborts retain exit 2 precedence, and existing worker/output failures still fail the process. Existing text and JSON counters remain unchanged. Help, man page, and README document the status contract.

The Prometheus teardown tests now preload matching fixture data so their expected successful verification remains meaningful. Import/verification remain unsupported in cluster mode.

Tests

On baseline dc79a95, the seven new RLTest cases give 5 failures / 2 passes: missing keys, wrong values, WRONGTYPE replies, post-benchmark verification errors, and zero replies all incorrectly return 0. On this change they give 7 passes / 0 failures (4 seconds), checking parsed JSON counters as well as status and diagnostics. Successful standalone verification and successful post-benchmark verification are controls. The follow-up partial-disconnect regression also fails on baseline (one match, zero failures, incorrect exit 0). The final suite passes 10/10 standalone and 9/9 TLS (the plaintext Unix peer case skips TLS), including default-ratio and import-wrap controls. After a normal merge of current master bc8e316, the final head 762c20d passes 13/13 unit tests and 10/10 focused verification tests. The earlier TLS result remains 9/9 with one plaintext-peer skip. Format check passes. Scripted-peer comparisons on baseline and fix preserve abort exit 2 and worker-failure exit 1, even when verification subsequently fails. A successful verification with /dev/full output still exits 1. The existing Prometheus teardown case passes its eight iterations with matching data (local auth adapter only). Cluster/import rejection remains unchanged on baseline and fix.

Compatibility / release note

Verification now exits 1 for failed, empty, or incomplete verification. This is intentional for existing callers too: an opt-in or warn-only default would preserve the false-success bug for scripts that depend on process status. Callers deliberately accepting stale data can handle status 1 explicitly and inspect the existing verification counters; no new tolerance flag is added. A zero-SET-position ratio intentionally fails because it checks no keys.

Timed verification with --test-time and no request limit already fails to terminate on both baseline and this change: its verifier does not use the benchmark deadline and the import reader wraps. This existing limitation is tracked separately; this PR does not promise timed verification support or weaken incomplete-pass detection.

Affected versions

Introduced by af97483 ("Add data verification options.", 2013-08-14). git tag --contains af97483 includes every release from 1.1.0 through 2.5.2; current master dc79a95 is affected too.

Fixes #768

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

🤖 Automated first-pass review — a human maintainer's review is still required before merge.

Thanks for this. The fix is small and well-scoped, and the tests are what I'd want to see: they check the parsed JSON counters as well as the exit status, and the description says 5 of the 7 new cases fail on baseline. Mostly questions:

  • --test-time without -n. I may be wrong, but in that case cfg.requests stays 0 (config_init_defaults() only defaults it to 10000 when test_time is unset). verification_complete() then always returns false because of the m_config->requests > 0 guard. If such a verify pass can end at all, a fully clean pass with no failures would now print "data verification did not complete" and exit 1. Is --data-verify --test-time=N reachable today? If it is, should the completeness check be skipped when requests == 0, and could it get a test either way?

  • Exit-status change for existing users. This is a real behavior change: any script that runs --data-verify with a known-stale dataset and ignores the result will start failing. I think it's justified, since verification that can't fail is hard to defend. Still, was an opt-in or warn-only mode considered and rejected? A line in the release notes calling out the new exit-1 contract would help either way.

  • Zero SET positions. Something like --verify-only --ratio=0:1 now hits verified_keys == 0 and exits 1 with "no keys were verified". That's probably the right answer, since no key was actually checked. I'm just confirming it's intended and not a side effect of the zero-replies case.

  • Nitpicking: verification_complete() sits above the constructor in the public: block in client.h. Grouping it with the other getters (get_verified_keys/get_errors) would read a bit more naturally.

The core fix looks solid. I'd mainly like the --test-time question answered before this merges.

(Would file this as a comment, not a formal block.)

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Thanks. The partial-pass concern was real: a peer returning one matching GET and dropping the next left verified=1, failed=0 and exit 0. Fixed in fc2c622, with a regression that fails on the baseline. Completion checks the generated request budget and replies for actual verification GETs; it deliberately does not use finished(), because skipped GET/MGET/WAIT positions count toward the configured budget without producing verification replies. Default 1:10 and wrap-around success controls pass.

The README now calls out imported expiry and --no-expiry; the post-benchmark success test explains why it starts with missing keys.

Validation is complete and the PR body is updated: 10/10 standalone, 9/9 TLS (scripted Unix peer skips), 12/12 unit tests, eight existing Prometheus teardown iterations. Actual scripted-peer baseline/fix runs retain exit 2 for a benchmark stage abort followed by failed verification, and exit 1 for a worker drop followed by failed verification. Successful verification with an output write failure also remains exit 1. Independent review and CI are still running.

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Addressed the current review on final head 762c20d, after a normal merge of master bc8e316:

  • Timed verification is reachable, but does not terminate normally today. Independent baseline/head comparisons reproduced this with --data-verify --test-time and no -n: the verifier has no benchmark deadline termination and repeatedly wraps its import input. It is a pre-existing limitation, recorded separately with the reproduction. Skipping completeness when requests is zero would let an interrupted partial pass masquerade as success; I am retaining the guard. The PR body now states this limitation explicitly.
  • The exit-1 behavior is intentional for existing callers. An opt-in or warn-only default would leave status-dependent automation falsely reporting success. The compatibility/release note now calls out failed, empty, and incomplete verification; callers intentionally accepting stale data can handle status 1 explicitly and use the unchanged counters.
  • Zero SET positions intentionally fails: no key was checked. This is the same public contract as the zero-reply guard, rather than a claim that unchecked data is valid.
  • I am leaving the completion predicate at its existing declaration location in this small fix. Grouping accessors can be a later style-only cleanup; it does not affect the completion contract.

The owner pass also aligns help/man wording with incomplete verification and checks that successful verification emits no incomplete-pass diagnostic. Final merged-tree build and unit tests pass 13/13; focused verification passes 10/10. The independent seven-lens reviews have converged, with a focused final-merge recheck in progress. CI still gates merging.

@fcostaoliveira
fcostaoliveira merged commit 88989a7 into master Oct 17, 2026
131 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--data-verify / --verify-only exits 0 when keys are missing or have wrong values

1 participant