KKcorps commented on PR #20391:
URL: https://github.com/apache/pinot/pull/20391#issuecomment-7212977993
This comes from a model of upsert thread orders that StarTree runs on upsert
PRs.
**The snapshot and TTL task holds up when it races pushes, reloads and
restarts, but the model found one new bad order: once the first snapshot writes
the watermark file, a backfill push older than `metadataTTL` loads with every
row valid.**
The model replayed the 124 histories of its known bad orders with and
without this change, and none of them changed. A 62-minute search then made
1,196 runs, 240 of them on OFFLINE tables with and without `metadataTTL`, and
12 more runs started from pushes already near or past the window.
**Backfill past the TTL window.** Today an OFFLINE table never writes the
watermark file, so `canSkipSegmentOutOfTTL` stays false and every push is
compared. After the first snapshot, any push whose newest row is past the
window takes `skipAddSegmentOutOfTTL`. A pushed segment has no validDocIds
file, so all of its rows stay valid, even one that loses to a newer row still
inside the window. This is the first gap your PR body lists, but it is not only
a new server, because any late backfill on a running server reaches it.
```mermaid
sequenceDiagram
participant J as Push job
participant H as Helix add thread
participant T as Snapshot task
participant M as Upsert metadata
J->>H: push U1 with A at 0 and A at 2
H->>M: A points to the row at 2, watermark 2
H->>T: onUpsertSegmentAdded
T->>M: takeSnapshot persists watermark 2
J->>H: backfill U2 with A at 0
H->>M: canSkipSegmentOutOfTTL is true, skip the add
H->>H: U2 has no validDocIds file, every row stays valid
Note over M: queries return A twice, the row at 2 and the stale row at 0
```
<details><summary>Model history</summary>
```
('upload_many', 'U1', [('A', (0,), {'a': 0}), ('A', (2,), {'a': 0})])
('step', 'upload', 'U1', 'register')
('step', 'upload', 'U1', 'start_add')
('step', 'upload', 'U1', 'add_row:A')
('step', 'upload', 'U1', 'add_row:A')
('step', 'upload', 'U1', 'finish_add')
('offline_upsert_task', 'start:loaded')
('offline_upsert_task', 'snapshot')
('upload', 'U2', 'A', (0,), {'a': 0})
('step', 'upload', 'U2', 'register')
('step', 'upload', 'U2', 'start_add')
('step', 'upload', 'U2', 'add_row:A')
('step', 'upload', 'U2', 'finish_add')
```
</details>
The model covers one partition on one replica, and it does not model a
refresh push that replaces a segment with different rows.
<!-- upsert-model-check head=2b41004c1e4664b617508f36d471e07e66807f6b -->
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]