Re: [PR] [core] Fall back to listing when the LATEST hint points to an expired snapshot [paimon]

2026-10-02 Thread via GitHub


JingsongLi commented on PR #10323:
URL: https://github.com/apache/paimon/pull/10323#issuecomment-5965917048

   The expiration-side direction (B alone, with the read-side recovery 
reverted) looks preferable for this PR. It preserves the invariant used by the 
existing readers and commit-user deduplication, and keeps recovery of 
already-broken tables as an explicit repair operation. The current `d8ef8b9` 
head still has the replay finding above; this is feedback on the proposed 
direction, not validation of an updated implementation.
   
   Please implement the protection as a cap on the entire expiration prefix, 
like the consumer boundary, rather than skipping only snapshot N. Keep the 
contiguous suffix from the hinted snapshot onward: retaining N while deleting 
N+1 would still make `findLatest` return the stale N. Apply the cap before any 
data/manifest deletion, including the time-retention early-return paths, and 
keep EARLIEST consistent with the actual retained range.
   
   One detail needs care: `HintFileUtils.readHint` currently returns null for 
both an absent hint and exhausted read retries. Expiration must not treat a 
transient hint-read failure as proof that there is no hint and delete the 
protected prefix. Please distinguish confirmed absence from an unreadable hint 
and conservatively skip deletion when that boundary cannot be established. 
Cover hint-read failures as well as hint-write failures, then successful 
recovery, concurrent commit/expiration, rollback, both replay conflict-check 
modes, streaming startup and timestamp-range reads. Skip the filesystem-hint 
policy only when the catalog actually supplies the snapshot state for this 
table.
   
   The expiration warning is useful; include the hinted ID, actual latest ID 
and retained boundary, and avoid repeating it without bound. A concise warning 
on the retry path that finds the snapshot already committed is also reasonable, 
with the completed snapshot ID and conditional wording such as “LATEST may not 
have been updated.” Keep it off the normal successful commit path and avoid 
claiming a failed hint write when the preceding exception does not establish 
that. Please update the PR and its tests to B before treating the current 
findings as resolved.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [core] Fall back to listing when the LATEST hint points to an expired snapshot [paimon]

2026-10-02 Thread via GitHub


dev-donghwan commented on PR #10323:
URL: https://github.com/apache/paimon/pull/10323#issuecomment-5947044510

   Thanks for the detailed review, @JingsongLi. You're right about both points. 
I reproduced the duplicate commit on `d8ef8b9`, both in core (replay with and 
without the append-file check) and through the Flink `END_INPUT` path on a 
`bucket=-1` table.
   
   I think I took the wrong approach with this PR, so before pushing anything 
I'd like to ask for your view as the original author of the hint files.
   
   The current direction is to fix the read side. To continue with it, every 
caller that relies on the latest snapshot id would have to handle a hint that 
points to an expired snapshot. `latestSnapshotId()` alone has about 50 callers 
in the main code, and `latestSnapshot()` and `latestSnapshotOfUser()` have 
more, in core, Flink and Spark. I started with the ones you pointed out and 
fixed the dedup path, including the `commit.last-safe-snapshot` branch, which 
removed the duplicate commit. But the tests then showed other callers behaving 
differently from what they intend, because only `latestSnapshot()` gets the 
real latest while `latestSnapshotId()` still returns the stale id. For example:
   
   - `incremental-between-timestamp` silently reads all retained snapshots 
instead of the requested range (5 rows instead of 2), where master fails.
   - `scan.mode=latest` still starts from the stale id, so your second point 
stays unfixed.
   - The Flink/Spark rollback procedures call `latestSnapshot()` before 
`rollbackTo`, which is what currently stops them on a stale hint. With 
read-side recovery that call succeeds, and they go on to a `rollbackTo` that 
keeps the snapshots after the target and deletes newer tags.
   
   Fixing each of these one by one would make the change much larger, and each 
fix could bring another side effect like these. So instead of the read side, I 
looked at the side that deletes snapshots. The stale state only appears when 
expiration deletes the snapshot the `LATEST` hint points to, so I'd like to 
propose preventing that instead.
   
   **Proposal**
   
   Snapshot expiration does not expire the snapshot the `LATEST` hint points 
to, similar to how it already keeps the snapshots consumers still need. Then 
`findLatest` works as it is. When the hint is behind, `snapshot-(N + 1)` 
exists, so it lists the directory and returns the real latest. All read-side 
changes are reverted, so every caller behaves exactly as on master.
   
   - No extra IO on the normal path. Expiration reads the `LATEST` hint once, 
and only when it is about to delete snapshots.
   - Expiration logs a warning whenever it keeps snapshots because the hint is 
behind.
   - I would skip the check when the catalog provides the latest snapshot 
itself (e.g. REST), where the `LATEST` file is not the source of truth.
   - A table that is already in the stale state behaves as on master. Some 
operations there are already wrong on master today (see below), so I think such 
tables are better handled by an explicit `repair_latest_snapshot` procedure, 
similar to `repair_earliest_snapshot` (#8883), as a follow-up.
   
   **If hint writes keep failing**
   
   In our incident, hint writes failed because of a broken TaskManager, which 
Paimon cannot prevent. What Paimon can avoid is turning that into a permanent 
outage: the TaskManager problem lasted about 6 minutes, while the table stayed 
stuck for two days until `LATEST` was fixed by hand.
   
   I ran 30 commits with every `LATEST` write failing. With the proposal, all 
of them succeeded (each one slower because of the existing hint-write retries), 
reads and `scan.mode=latest` stayed correct, and snapshots piled up to 31. The 
first commit after hint writes recovered moved the hint, and expiration cleaned 
up back to the retention. On master the same run gets stuck once the hinted 
snapshot is expired.
   
   Today the only trace of this is the generic `Retry commit for exception` 
warning, and the retry path that finds the commit already done logs nothing. If 
you agree, I'd also add a warning there, e.g. "Snapshot #N was committed by a 
previous attempt that failed, the LATEST hint may not have been updated", so 
the problem shows up at the first commit rather than only once snapshots pile 
up.
   
   I also tried letting expiration rewrite the `LATEST` hint before deleting. 
It repairs the hint when another process runs expiration, but without a 
compare-and-swap on hint files it can race with rollback and write a hint that 
points to a snapshot the rollback has just deleted, which is the same stuck 
state. It also adds the hint-write retry delay to every expiration while writes 
fail. So I kept the proposal read-only.
   
   **Measured comparison**
   
   - master: current behaviour
   - A: read-side recovery (`d8ef8b9` plus the dedup fix)
   - B: the proposal above
   
   All cells come from running the same probe on the four variants, 

Re: [PR] [core] Fall back to listing when the LATEST hint points to an expired snapshot [paimon]

2026-10-01 Thread via GitHub


JingsongLi commented on PR #10323:
URL: https://github.com/apache/paimon/pull/10323#issuecomment-5944451719

   Reviewed head `d8ef8b9aa0`. The stale-hint outage has clear production 
value, but this revision introduces a replay correctness problem.
   
   **[P1] Recover commit-user deduplication before allowing the commit to 
proceed** (`SnapshotManager.java:227–232`)
   
   `filterCommitted` still calls `latestSnapshotOfUser`, which starts from 
`latestSnapshotId()`. If LATEST points to an expired snapshot and its successor 
is also expired, that lookup stops at the missing snapshot and reports no 
previous commit. The new fallback then lets `tryCommit` find the real latest 
snapshot and publish the same files again.
   
   This is reachable in Flink's batch committer restart path: 
`CommitterOperator#commitUpToCheckpoint(END_INPUT_CHECKPOINT_ID)` calls 
`filterAndCommit(committables, false, true)`, deliberately disabling 
append-file conflict checks after deduplication.
   
   I reproduced this with an append table (`bucket=-1`), retained snapshot 7 
containing the batch user's `Long.MAX_VALUE` commit, expired snapshots 1/2, and 
LATEST reset to 1. After reopening the table and replaying the original 
messages through `filterAndCommitMultiple(..., false)`, this head returns 1, 
publishes snapshot 8, and a real table read returns **8 rows instead of 7, 
including the same row twice**. With the baseline implementation, the same 
replay fails on the missing hinted snapshot before publishing. With append-file 
checks enabled, this head instead throws a duplicate-file conflict and cannot 
recover.
   
   Please make the commit-user lookup recover from the missing hint as well 
before concluding that a commit is new, and add replay coverage for both 
conflict-check modes. A failure-only fallback can preserve the normal-path I/O 
cost.
   
   There is also a remaining scope gap: `latestSnapshotId()` remains stale. 
Before another successful writer repairs LATEST, a fresh `scan.mode=latest` 
stream chose checkpoint 2 while the actual latest was 6 (expected checkpoint 
7). The added test only checks reading after a successful commit repairs the 
hint. Please cover reader startup before that repair; this is an existing 
outage left unresolved, separate from the new duplicate-row regression.
   
   Validation: `SnapshotManagerTest` + `StaleLatestHintTest`: **45 tests 
passed**, including a final run without `fast-build` 
(Checkstyle/Spotless/enforcer enabled). Additional local replay/read probes 
reproduced the failures above; no probe changes were pushed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] [core] Fall back to listing when the LATEST hint points to an expired snapshot [paimon]

2026-10-01 Thread via GitHub


dev-donghwan commented on PR #10323:
URL: https://github.com/apache/paimon/pull/10323#issuecomment-5944432441

   Thanks for the review, @JingsongLi! You're right, I overlooked that 
`findLatest` is on the hot path and the extra `exists` check would cost another 
IO on every lookup.
   
   I've reverted the `findLatest` change and moved the fix into the existing 
fallback in `latestSnapshotFromFileSystem`. Only when reading the hinted 
snapshot fails with `FileNotFoundException` and the hint still returns the same 
id, it now lists the snapshot directory to find the real latest snapshot. If 
the listing finds no newer snapshot, it still throws as before. So there's no 
extra IO on the normal path, and the commit path can still recover and rewrite 
the hint.
   
   Could you take another look when you have time?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]