feat(table): skip validator registration for no-op producers#1022
feat(table): skip validator registration for no-op producers#1022laskoviymishka merged 3 commits intoapache:mainfrom
Conversation
…e#830 Signed-off-by: hectar-glitches <hectar@uni.minerva.edu>
There was a problem hiding this comment.
![]()
Thanks for contribution!
Skipping the no-op closure for fast/merge append matches Java’s BaseFastAppend / MergeAppend, which also don’t register validate() on the append path.
No correctness or spec concerns from my side.
A few nits before merging @hectar-glitches :
- The comment above the gated
ifincommit()looks a bit stale now — “pay only the no-op-closure cost” no longer quite describes the new behavior. - A one-line doc comment on
needsValidation()would make the interface contract clearer for future readers. mergeAppendFiles.needsValidationis inherited through Go method promotion. That works, but an explicit override could make the intent easier to see locally.- If we keep relying on promotion,
TestMergeAppendFiles_InheritsFastAppendValidatorcould also assertrequire.False(t, ma.needsValidation()).
Overall LGTM from my side.
| // and merge-append). | ||
| validate(cc *conflictContext) error | ||
|
|
||
| needsValidation() bool |
There was a problem hiding this comment.
Worth a one-line doc on the contract here? The neighbour validate has a 7-line block (lines 50-56), and needsValidation is the gate that decides whether validate even runs — defining "return false iff validate is unconditionally a no-op" pins the invariant at the declaration. Without it, someone could add real work to a producer's validate() later without flipping the predicate and silently bypass the check.
| return nil | ||
| } | ||
|
|
||
| func (fa *fastAppendFiles) needsValidation() bool { return false } |
There was a problem hiding this comment.
Tiny robustness ask while we're here: I'd consider adding an explicit func (m *mergeAppendFiles) needsValidation() bool { return false } next to the mergeAppendFiles declaration so the choice is local to that type rather than inherited via Go method promotion from the embedded fastAppendFiles. Right now nothing at the mergeAppendFiles site signals the policy, and a future producer copy-pasting the embed pattern would silently inherit false with no compiler nudge. wdyt?
| // only in unit tests that exercise commit() directly on a bare | ||
| // snapshotProducer; guard to keep those tests green. | ||
| if impl := sp.producerImpl; impl != nil { | ||
| if impl := sp.producerImpl; impl != nil && impl.needsValidation() { |
There was a problem hiding this comment.
Comment block just above is now stale — it still says fast/merge-append pay only the no-op-closure cost, but with the new gate they pay nothing. I'd freshen the rationale while we're here, e.g. "Producers that are commutative against concurrent appends (fast-append, merge-append) opt out via needsValidation() == false and skip registration entirely. The nil guard remains for unit tests that drive commit() on a bare snapshotProducer."
|
I'll get on those nit-picks |
Signed-off-by: hectar-glitches <hectar@uni.minerva.edu>
Summary
This PR gates validator registration on a new
needsValidation() boolmethod on theproducerImplinterface:fastAppendFilesreturnsfalse: appends are commutative and need no conflict checksmergeAppendFilesinheritsfalsevia embeddingoverwriteFilesreturnstrue: real conflict validation requiredsnapshotProducer.commit()skips registration whenneedsValidation()is falseThe no-op
validate()methods are kept as belt-and-suspenders.Behavior is locked with two unit tests asserting that fast-append and merge-append commits leave
txn.validatorsempty.Parent: #830