[Feature request] Notify when a new OFFLINE segment is query-able
Following Slack discussion: https://apache-pinot.slack.com/archives/C011C9JHN7R/p1649059683439889
Summary
In some cases, there is a need to know when / if a new OFFLINE segment is ready for query.
For example:
- A new segment is pushed to Pinot's controller via a
SegmentCreationAndTarPushJob. - The job ends as soon as this segment is copied over to the Controller (as far as I know).
- Some services may be interested in the fact that new data is available (e.g. to update some materialized view), we can notify them using a pub/sub system for exemple.
- Those services come ask for this updated data.
- As long as Pinot's servers are not done downloading the new segment from the deep store, they serve "stale" data.
=> The root issue comes from the fact that the business-level notify message is tied to the end of the SegmentCreationAndTarPush Job and not the true availability of new data in Pinot.
Proposition
- Implement a callback mechanism into Pinot which will be called as soon as data is ready for query (By @snleee)
- Could be a generic Java function callback
- Could be a message being sent on a pub/sub system
- Could be a call to some external REST API
-
Implement a
waitForDataAvailabilityoption (poor name) from within Pinot's Push Jobs. -
Other?
Current workarounds
- Wait for a fixed time: Brittle solution
- Wait for IS == EV (By @mayankshriv)
- Poll segment status (given that its name is known)
- Other?
In order to know if a new segment is ready for query, the information should come from the broker. Here is the steps of new segment becoming queryable:
- Segment uploaded to the deep store via controller (or metadata push)
- Server gets notified to download and load the segment
- Controller collects server status and updates table's external view
- Broker listens to the external view change and includes the query into the routing. The segment is queryable only when it is loaded on an enabled server that is not disabled for routing.
Do you think it can solve the problem if we add an API to the broker to return if the given segment is ready for query (and all queryable segments for a given table)? We may also add the API to the controller to be redirected to the broker