Skip to content

[Bug]: objectio: writer entry points swallow block serialization errors #26870

Closed

Description

@LeftHandCold

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch and commit

  • Discovery branch: main
  • Discovery commit: 26903703bb98f67858c2daf32640ae1ecf4ebdc7

Code location

Actual behavior

All three public writer entry points call AddBlock/AddTombstone and discard the returned (size, error), then unconditionally return a nil error. The lower-level addBlock can fail while serializing a vector or compressing its bytes. The caller is therefore told that the block was accepted even though it was not appended completely.

Expected behavior

Every object-writer entry point must propagate the lower-level block-write error. A caller must not proceed to WriteEnd after a block serialization/compression failure under the false assumption that the block was accepted.

Steps to reproduce

bat := batch.NewWithSize(1)
bat.Vecs[0] = vector.NewVec(types.T_int64.ToType())
bat.Vecs[0].SetLength(1) // malformed: logical row without fixed-width backing data
bat.SetRowCount(1)

writer, err := objectio.NewObjectWriterSpecial(objectio.WriterNormal, path, fs)
require.NoError(t, err)
_, err = writer.Write(bat)
require.Error(t, err) // currently err is nil

vec.MarshalBinaryWithBuffer rejects this vector because its data is shorter than the encoded logical length. addBlock returns that error at the serialization boundary, but Write discards it. Equivalent tests apply to WriteTombstone and WriteWithoutSeqnum.

Evidence

Confirmed code facts

  • Write, WriteTombstone, and WriteWithoutSeqnum ignore the result of the lower-level block call and return nil.
  • addBlock explicitly returns errors from MarshalBinaryWithBuffer and WriteWithCompress.
  • addBlock appends the completed block only after all columns serialize, so an early error leaves the writer without the advertised block while the public method still reports success.

Inference

A caller that continues with WriteEnd can persist an empty or incomplete object and publish success for an operation whose block was rejected. The precise SQL/storage paths that can naturally produce a serialization or compression error still need caller-level validation.

Impact

Silent error loss at a storage boundary can turn a detectable write failure into missing object data, incorrect metadata, or delayed read failures.

Unverified assumptions

  • A production SQL path that naturally constructs a malformed vector has not been demonstrated.
  • Compression-error reachability under valid input has not been demonstrated.

Additional information

  • Duplicate searches: objectWriter AddBlock error, objectio writer error, MarshalBinaryWithBuffer objectio in open and closed issues/PRs; no matching issue found.
  • Reproduction status: deterministic code-level counterexample; not yet added as a committed unit test.
  • Suggested validation: add table-driven tests for all three entry points with a vector whose marshal validation fails, then return the exact AddBlock/AddTombstone error.

Activity

  1. added
    kind/bug
    on Aug 9, 2026
  2. added
    severity/s0
    and removed on Aug 9, 2026
  3. LeftHandCold commented on Sep 1, 2026

    @LeftHandCold
    CollaboratorAuthor

    Current-main root-cause verification (2026-09-01)

    Classification: proven historical root cause; production code is already fixed on current main.

    I reproduced the same deterministic malformed-vector counterexample on the real
    default-branch commit at this issue's creation time,
    1d00cca77012a2fac20c94bbbd170579e715d217:

    • objectWriterV1.Write returned a non-nil block and a nil error.
    • objectWriterV1.WriteWithoutSeqnum returned a non-nil block and a nil error.
    • In both cases addBlock had already returned
      vector data is shorter than its marshal length.

    The violated invariant was therefore exact: the two public wrappers discarded
    the AddBlock result and advertised acceptance after serialization rejected the
    block. Callers such as BlockWriter.WriteBatch, GC metadata writers, and
    snapshot metadata writers already had error branches, but those branches were
    unreachable for this lower-level failure.

    Baseline correction

    The issue's stated discovery SHA
    26903703bb98f67858c2daf32640ae1ecf4ebdc7 is a 2024 side-branch commit and is
    not an ancestor of current main. The core finding still holds on the actual
    2026-08-09 main SHA above, but the third entry point in the report does not:
    WriteTombstone had already been removed from the current production writer
    path by #19075.

    Current status

    #26616 incidentally fixed both active wrappers in
    ed4a810a539d8b7feae95711d37e7d7d9449d89f by returning the AddBlock
    error. On current main 33af6ae3c0c23e4f277137460577ea64678f7ecf,
    the same two-entry counterexample passes, and the complete pkg/objectio
    package test passes.

    PR #27949 adds the missing permanent regression subcase for
    WriteWithoutSeqnum; the existing #26616 test covered only Write.

    Impact boundary

    The API contract defect was real. The worst storage consequence was conditional
    on an upstream invalid/oversized vector or another actual serialization failure.
    No natural valid-SQL path or observed production data corruption was established
    by the issue evidence. The deterministic proof uses the marshal validator; an
    LZ4 failure under valid input remains unproven because the writer allocates
    CompressBlockBound before compression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions