Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Searched objectWriterV1, objectWriterV1 AddBlock error, AddBlock error ignored — no existing report.
Branch Name
main
Commit ID
c30cd37058
Actual Behavior
objectWriterV1.Write (pkg/objectio/writer.go:316) calls AddBlock and throws away its error, then unconditionally returns nil:
func (w *objectWriterV1) Write(batch *batch.Batch) (BlockObject, error) {
if col := len(w.seqnums.Seqs); col == 0 {
w.seqnums.InitWithColCnt(len(batch.Vecs))
} else if col != len(batch.Vecs) {
panic(fmt.Sprintf("Unmatched Write Batch, expect %d, get %d, %v", col, len(batch.Vecs), batch.Attrs))
}
block := NewBlock(w.seqnums)
w.AddBlock(block, batch, w.seqnums) // <-- (int, error) both discarded
return block, nil // <-- always nil
}AddBlock is declared as func (w *objectWriterV1) AddBlock(blockMeta BlockObject, bat *batch.Batch, seqnums *Seqnums) (int, error) (pkg/objectio/writer.go:832) and can genuinely fail — e.g. marshalling or compression failures in the column loop.
Two consequences:
- Callers cannot detect the failure. Every
if _, err := writer.Write(bat); err != nilin the codebase is dead code. A block that failed to serialize is reported as written; the error surfaces later, elsewhere, or not at all. Writealso hides its first return value (the number of bytes/rows added), which is discarded here as well.
This was found while investigating a leak in saveMeta (#27405), whose Write error branch is consequently unreachable — which in turn made it harder to reason about which cleanup paths matter.
Introduced in 9b6d192ea3 (#9248, 2023-05-08); AddBlock gained its error return shortly before, in a181a764b7 (#9058, 2023-04-18), so the error has been dropped ever since it existed.
Expected Behavior
Write propagates the error:
block := NewBlock(w.seqnums)
if _, err := w.AddBlock(block, batch, w.seqnums); err != nil {
return nil, err
}
return block, nilWorth checking whether other AddBlock call sites drop the error the same way, and whether any caller currently depends on Write never failing.
Steps to Reproduce
- Inject a failure inside
objectWriterV1.AddBlock(e.g. forceWriteWithCompressto fail for one column). - Call
objectWriterV1.Writewith any batch. Writereturns(block, nil)— the caller sees success despite the block not having been added correctly.
Additional information
Found by source review, not observed as a runtime failure. Filed separately from #27405 / #27406 because it is an independent defect in a different package.
Activity
LeftHandCold commentedon Sep 1, 2026
Current-main root-cause verification (2026-09-01)
Classification: proven at the reported SHA, but already resolved on current
main; this overlaps the earlier #26870.At the issue's exact baseline
c30cd3705855a61333519dc7a27693c0b4443d92,a malformed text vector makes
AddBlockreturnvector data is shorter than its marshal length. A deterministic test confirmsthat both
WriteandWriteWithoutSeqnumnevertheless returned a non-nilblock and nil error. The root cause was exactly the unchecked call followed by
an unconditional
return block, nil.The production fix already landed in #26616 at
ed4a810a539d8b7feae95711d37e7d7d9449d89f: both active wrappers now returnnil, err. Current main33af6ae3c0c23e4f277137460577ea64678f7ecfpasses the same counterexample andthe full
pkg/objectiopackage tests.PR #27949 is a narrow regression follow-up: it keeps the existing
Writecoverage and adds the missing
WriteWithoutSeqnumsubcase. No additionalproduction-code patch is appropriate because the implementation is already
correct on main.
Impact remains conditional: the defect silently hid a real serialization error,
but the available evidence does not establish a naturally occurring valid-SQL
input or observed production data loss.
LeftHandCold commentedon Sep 1, 2026
fixed
LeftHandCold commentedon Sep 1, 2026
#26616
test(objectio): cover marshal errors in writer entry points (#27949)
test(objectio): cover marshal errors in writer entry points (matrixor…
test(objectio): cover marshal errors in writer entry points (matrixor…
test(objectio): cover marshal errors in writer entry points (matrixor…