Jackie-Jiang opened a new pull request, #20313: URL: https://github.com/apache/pinot/pull/20313
## Summary An optional segment is a new segment the broker has not seen online on a server yet. The server queries it if it has loaded it, and skips it without failing the query otherwise. The single-stage engine has routed optional segments since #11978. The multi-stage engine dropped them, so new data stayed invisible until the external view caught up, and a query on a replicated table failed when a server had not loaded a new segment yet. The segments of a leaf worker are now carried as a `SegmentsToQuery`, the pair of segments and optional segments the routing table already returns, from routing through the planner and the wire to the server. No layer converts it back to a plain list, so an extension point such as `WorkerManager#filterLeafStageSegments` cannot drop the optional segments by accident. Each kind of leaf gets its optional segments from where it already gets its segments: - **Non-partitioned leaves, logical tables and the physical optimizer** pass on the pair the routing table gives each server. - **Partitioned leaves** get the new segments a partition leaves out of its fully replicated segments. `SegmentPartitionMetadataManager` publishes them as the optional segments of the partition, and the worker of the partition queries them. - **Replicated leaves** ask the instance selector which of the table's segments are new and not online on every server, through the new `RoutingManager#getSegmentsToQuery`. Every worker queries the other segments as before. ## Wire format and compatibility - The proto segment list gets an `optionalSegment` field. - The legacy JSON encoding sends the optional segments in a new `optionalSegmentsMap` custom property, because older servers parse the existing properties as maps of segment lists. - A server that predates this change ignores either one and keeps skipping these segments, so a newer broker does not fail any query that succeeds today. ## Behavior changes - Leaf workers query the optional segments their server has loaded, as the single-stage engine does. - With broker pruning, a partition whose only unpruned segment is optional keeps its worker. - On a replicated leaf, a new segment that is not online on every server is optional instead of required. The query no longer fails when a server has not loaded it, but until every server has, the segment is visible on some workers and not on others. A server that predates this change skips it until it is online everywhere. A table whose segments are all optional is still queried, which relies on #20262 when a server has not set up the table yet. - `NON_ACTIVE_WORKERS` no longer counts a worker that only has optional segments. - `RoutingManager#getSegments` is removed. The replicated leaf was its only caller, and `getSegmentsToQuery` replaces it. ## Not covered - A partition whose segments are all new still fails the partitioned assignment, or loses its rows under broker pruning. Giving it a worker that only has optional segments needs servers with #20262, so it is left as a TODO until 1.7.0 servers are deployed. - The routing table still leaves out a server that would only get optional segments. Earlier takes on this: #19144, #19537, #20017. 🤖 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]
