Count pipeline errors per-command, not per-window - #125
Open
fcostaoliveira wants to merge 2 commits into
Open
fcostaoliveira wants to merge 2 commits into
fcostaoliveira wants to merge 2 commits into
Conversation
radix.Pipeline.Run stops decoding at the first failing command, drains (discards) the remaining replies, and returns a single aggregate error for the whole batch. flushPending then marked EVERY command in the pipeline window as errored, so one bad reply (e.g. a WRONGTYPE) in a window of N inflated the error count by up to N. Replace radix.Pipeline with a small custom Action (pipelineErrs) that still sends the whole batch in one buffered write (via multiMarshal) but decodes every reply and records each command's own error in errs[i]. flushPending now attributes hadError/isTimeout per command from that slice: a RESP error fails only its own command; a transport error (i/o timeout) fails that command and the ones after it (the connection is broken) while the already-decoded ones stay successful. The read cost is unchanged -- radix.Pipeline also decodes/drains all N replies. Regression guard: TestFTSBPipelineErrorCountedPerCommandNotPerWindow feeds one WRONGTYPE among 9 good HSETs in a pipeline of 10 (workers=1, deterministic) and asserts Errors==1. Verified the pre-fix binary reports Errors==10 for the same input. Existing error/timeout integration tests still pass.
…#118) Two adversarial-review findings on the initial #118 change: 1. Undercount when client.Do fails BEFORE pe.Run (minor): radix Pool.Do calls pool.get() before Action.Run, so a connection-acquisition failure during a server outage returns an error without ever running pipelineErrs. pe.errs then stayed all-nil, so every command in the window was recorded as a SUCCESS -- the batch's errors were undercounted to zero (pre-#118 counted the whole window). Add a `ran` flag set at the top of Run; flushPending's cmdErr falls back to the Do error for the whole window when !pe.ran, and keeps exact per-command attribution once the batch executed. 2. Untested transport-error tail (minor): the only multi-command test used a WRONGTYPE (connection stays healthy). Add pipeline_action_test.go with a fake radix.Conn driving Run deterministically through: a mid-batch i/o-timeout tail (cmd0 ok, cmd1 timeout, cmd2 on broken conn -> each recorded, none dropped or blamed on cmd0), a lone RESP error (only its own command fails), an encode failure (whole batch fails, nothing decoded), and the unrun ran=false state. Full cmd unit suite and the #118 integration guard still pass under -race.
|
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.



Closes #118. (Supersedes #124, which auto-closed when its stacked base branch — #117/#123 — was deleted on merge. #123 is now in master, so this retargets cleanly to master and the diff is just the #118 delta.)
Problem
radix.Pipeline.Runstops decoding at the first failing command, drains the remaining replies, and returns a single aggregate error for the whole batch.flushPendingthen marked every command in the pipeline window as errored — so one bad reply (e.g. aWRONGTYPE) in a window of N inflated the error count by up to N.Fix
Replace
radix.Pipelinewith a small customAction(pipelineErrs) that still sends the whole batch in one buffered write (multiMarshal) but decodes every reply and records each command's own error inerrs[i].flushPendingattributeshadError/isTimeoutper command.Review-gate fixes (from 15 adversarial reviews)
client.Dofails beforeRun: radixPool.Docallspool.get()beforeAction.Run, so a connection-acquisition failure during an outage returns without ever runningpipelineErrs, leavingerrsall-nil → the batch was counted as fully successful. Added aranflag;cmdErrfalls back to theDoerror for the whole window when!pe.ran, and keeps exact per-command attribution once the batch executed.pipeline_action_test.go— a fakeradix.ConndrivesRundeterministically through a mid-batch i/o-timeout tail, a lone RESP error, an encode failure, and the unrun state.Validation
TestFTSBPipelineErrorCountedPerCommandNotPerWindow: oneWRONGTYPEamong 9 goodHSETs in a pipeline of 10 →Errors == 1(pre-fix binary:Errors == 10, verified). New unit tests + full suite green under-race.