deepthi912 opened a new pull request, #20391:
URL: https://github.com/apache/pinot/pull/20391

   Fixes #20196.
   
   OFFLINE upsert tables have no consuming segment, so the upsert snapshot and 
the metadata TTL cleanup, which REALTIME tables run on segment commit, never 
ran. Primary keys out of `metadataTTL` were never removed, and the TTL 
watermark was never persisted.
   
   ## Changes
   - `OfflineTableDataManager` runs the snapshot and the expired-key removal 
after a segment is added or replaced, in the same order as a REALTIME commit: 
with `metadataTTL`, snapshot first; otherwise, removal first.
     - It runs as a background task on the existing segment refresh executor, 
so Helix transitions don't wait on it.
     - There is at most one task per partition. Adds that arrive while a task 
is queued or running fold into one rerun.
     - It only runs once every segment of the partition is loaded locally.
     - Failures are logged and don't fail the segment transition.
     - A run skipped because the partition isn't loaded increments a new meter, 
`UPSERT_SNAPSHOT_SKIPPED_PARTITION_NOT_LOADED`. It keeps increasing if a 
segment of the partition stays in ERROR, which would otherwise silently stop 
the TTL sweep.
   - `TableStateUtils.ReadinessSnapshot.isPartitionLoaded`: the per-partition 
check above. It reuses the required-segment check from `isReadyToConsume`.
   - `BaseTableDataManager`:
     - now owns the readiness snapshot cache, moved from 
`RealtimeTableDataManager`;
     - now owns the locally-ready predicate, which `RealtimeTableDataManager` 
overrides for consuming segments;
     - `handleUpsert` calls a new no-op hook, `onUpsertSegmentAdded`, after a 
segment add or replace. It isn't called for preloaded segments.
   - `BasePartitionUpsertMetadataManager` no longer skips snapshots on OFFLINE 
tables while waiting for a first consuming segment. REALTIME behaviour is 
unchanged.
   
   ## Tests
   - `OfflineTableDataManagerTest` (new):
     - snapshot and removal order, with and without TTL;
     - skipped until the partition is loaded, and the skip is metered;
     - coalescing: one task for several adds, and a rerun for an add during a 
run;
     - one task per partition;
     - a failure doesn't stop later runs;
     - a rejected task is retried on the next add.
   - `UpsertSnapshotRestartTest`:
     - an OFFLINE table takes snapshots without a consuming segment;
     - a REALTIME table still waits for its first one;
     - an OFFLINE restart after TTL cleanup skips the out-of-TTL segment.
   - `BaseTableDataManagerPartitionMetadataTest`: a segment add and a replace 
schedule the snapshot; a preload or a failed add doesn't.
   - `UpsertSnapshotRestartIntegrationTest`: an OFFLINE table with snapshot, 
preload and TTL takes snapshots after uploads, returns one row per key after a 
restart that preloads an out-of-TTL segment, and snapshots again on the next 
upload.
   - `TableStateUtilsTest`: `isPartitionLoaded` only checks segments of its own 
partition.
   - The upsert, `TableStateUtils`, `BaseTableDataManager*` and REALTIME 
readiness and consumer suites pass.
   
   ## Follow-ups (not in this PR)
   - On a new server, an out-of-TTL segment can be skipped before its keys are 
recorded, which can leave duplicates.
   - A TTL sweep during a partial load can drop keys that a segment not yet 
loaded still needs.
   
   
   


-- 
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]

Reply via email to