You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Partial-update checked sum fails when a retraction-only flush reaches the signed minimum #11636
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'
Commit +I(-1), +I(2147483647), +I(1). The table reads 2147483647.
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).
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:
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.
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.
Activity