deepthi912 opened a new pull request, #18895: URL: https://github.com/apache/pinot/pull/18895
## Summary When a CONSUMING segment transitions to ONLINE and its offset matches the committed offset in ZK, the server builds the segment locally and swaps it in. For **upsert tables** this is unsafe: a locally-built segment can diverge from the segment committed by the winning replica (e.g. different docId ordering), so its CRC differs from the committed CRC. Swapping in a CRC-divergent local build can leave the upsert metadata (`validDocIds` / primary-key → record-location) inconsistent across replicas. ## Changes - Adds a `buildSegmentAndReplace(SegmentZKMetadata)` overload that, for upsert-enabled tables, compares the locally-built segment's CRC against the committed CRC in ZK (via `BaseTableDataManager.hasSameCRC`). On a mismatch it skips the local build so the caller downloads the committed segment instead. - The guard is applied on both the matched-offset and post-catch-up reconciliation paths in `goOnlineFromConsuming`. - If the locally-built segment metadata cannot be read, the check reports a mismatch so the transition downloads the committed segment rather than throwing. Non-upsert tables and callers that do not pass the committed metadata are unaffected. ## Rolling upgrade Behavior change is scoped to upsert tables; no wire/ZK format change. Mixed-version replicas converge to the committed segment either way. ## Testing Added coverage in `RealtimeSegmentDataManagerTest` for the CRC-match, CRC-mismatch, unreadable-metadata, and non-upsert paths. -- 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]
