Jackie-Jiang opened a new pull request, #20320: URL: https://github.com/apache/pinot/pull/20320
## Summary A new upsert segment is registered for queries before `PartitionUpsertMetadataManager.addSegment()` initializes its upsert metadata. When that initialization fails: - The segment stays registered with partial valid docs, and Helix marks it ERROR. - The ERROR -> OFFLINE reset only logs, so the segment stays registered. - The retried OFFLINE -> ONLINE finds the segment, and `replaceSegmentIfCrcMismatch` returns early because the CRC matches. The segment then reports ONLINE with incomplete upsert metadata. Queries see incomplete valid docs, and a partial-upsert consumer can apply an increment without its base value. This was raised in review of #20106 and kept out of that PR. ## Change - `BaseTableDataManager.hasUninitializedUpsertMetadata()` detects a registered upsert segment whose `ImmutableSegmentDataManager` is not marked initialized. Only the upsert add path registers a segment before initializing its metadata. - `BaseTableDataManager.reloadUninitializedUpsertSegment()` rebuilds that segment through the regular reload path (`reloadSegment` -> `addSegment` -> `handleUpsert` -> `replaceUpsertSegment`). The reload reuses the local index directory when the CRC matches, and the reloaded segment replaces the registered one with its upsert metadata initialized. - `OfflineTableDataManager.doAddOnlineSegment()` and `RealtimeTableDataManager.doAddOnlineSegment()` rebuild such a segment instead of running the CRC check. On realtime tables this also happens before the completed-status check, so a pauseless COMMITTING segment is rebuilt from its local copy. The reload downloads only a completed segment. Unchanged: - `replaceSegmentIfCrcMismatch` and the segment refresh path. Only the ONLINE transition makes a segment ONLINE in CurrentState, and a refresh with a new CRC already rebuilds the metadata. - Consumer readiness. Once the retry rebuilds the metadata, ONLINE in CurrentState implies it is initialized. A failure inside the rebuild's replace is a separate, pre-existing problem in `replaceUpsertSegment` that this PR does not change. Under consistency mode NONE the newly loaded segment is never registered or destroyed. Under SYNC and SNAPSHOT a `DuoSegmentDataManager` stays registered, so later ONLINE retries fail. ## Validation `BaseTableDataManagerPartitionMetadataTest.testOnlineRetryRebuildsOnlyUninitializedUpsertSegment` covers offline tables and realtime tables with a COMMITTING segment. In each case the first ONLINE add either fails or succeeds, then an ONLINE retry runs with a matching CRC. - After a failed add, it checks that the segment is reloaded from its local metadata without a forced download, and that the upsert metadata is rebuilt against the old segment. The registered manager must be replaced by an initialized one, and the old segment offloaded. - After a successful add, it checks that nothing is reloaded. No tests or formatting, checkstyle, or license checks were run locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
