Skip to content

[Bug] Partial-update checked sum fails when a retraction-only flush reaches the signed minimum #11636

Backlog

Description

@houlinchn

Search before asking

  • I searched in the issues and found nothing similar.

Paimon version

master, with #11274 applied. Master fails the same case for a different reason (#11273).

Compute Engine

Java API (the behavior is in paimon-core).

Minimal reproduce step

A primary-key table with a checked sum in a sequence group:

amount INT NOT NULL,
'merge-engine' = 'partial-update',
'fields.seq.sequence-group' = 'amount',
'fields.amount.aggregate-function' = 'sum',
'fields.amount.sum.fail-on-overflow' = 'true'
  1. Commit +I(-1), +I(2147483647), +I(1). The table reads 2147483647.
  2. Commit -U(2147483647), -U(1).

What doesn't meet your expectations?

Expected -1. Writing all five records in one commit reads -1.

The second commit fails. Its write buffer only has retractions, so the sum accumulates -2147483648. getResult() writes a retraction-only result as a DELETE whose payload is the retracted amount, so it negates the accumulator, and +2147483648 does not fit an INT. With fail-on-overflow off, both commit layouts read -1.

On master the leading retraction seeds the sum (#11273), so the flush writes DELETE(-1) and the read fails at 2147483647 - (-1).

Anything else?

Found in the review of #11274: #11274 (comment)

A DELETE payload can not carry this result. Writing the result as INSERT(-2147483648) would fix this case, but a key with no earlier row that only receives these retractions would then read as a row instead of no row. Options discussed in the review:

  1. Keep a checked integer sum in a wider accumulator during a merge and narrow it once in getResult(). A batch whose net change does not fit the field type still fails.
  2. Also keep a key's original records in separate level-0 files when its merged result does not fit, and merge them at read time. A checked sum then fails only when the final value overflows, but flush and compaction output changes.

Either option needs to keep a retraction-only key absent across flushes and compaction.

Workarounds: turn off fail-on-overflow, or use a wider type such as BIGINT.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions