You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] SQL Join timeout isn't applied when using PIT #3820
For Join, blockHash operator read one block from LeftTable, and iterate all data from rightTable. So if iterate all data from rightTable took more than keep_alive time, then the pit on LeftTable will be deleted.
Question, Could we confirm that iterate all data from rightTable took more than keep_alive time?
Did some testing with @noCharger, it looks like on Serverless the PIT extension isn't automatic, so we have the right index PIT getting deleted after 60s. We'd need to add the keep_alive parameter to the PointInTimeBuilder for our batch loader to make it apply.
Here's a trace from the join running on it, out.txt. This is the right index PIT getting deleted for this query:
SELECT /*! JOIN_TIME_OUT(90) */ l.spanId, r.spanId, r.epoch FROM nginx_logs_left AS l LEFT JOIN nginx_logs_right AS r ON l.epoch = r.epoch LIMIT 3
We can see that it creates the PIT on the logs_right index (the shards are listed at the end), paginates through the PIT (~6 pages/second), and then the PIT is dropped after 60s.
To your point, I do see that it loads the first batch of some earlier PITs before the big scan, which also would be deleted in spite of fixing the keepalive since no new pages are fetched for those other PITs.
2025-06-24 22:40:51.619 Created Point In Time FZuhvrtKReSRxx51Vzo3CA successfully.
2025-06-24 22:40:51.630 Created Point In Time tkUYvb-IRcCuZgDWxsMWzw successfully.
2025-06-24 22:40:51.631 Loading first batch of response using Point In Time
2025-06-24 22:40:51.821 Created Point In Time y_T7MwDnSG-rblpw9Xa6mQ successfully.
2025-06-24 22:40:51.821 Loading first batch of response using Point In Time
2025-06-24 22:40:52.105 Loading next batch of response using Point In Time. - y_T7MwDnSG-rblpw9Xa6mQ
2025-06-24 22:40:52.325 Loading next batch of response using Point In Time. - y_T7MwDnSG-rblpw9Xa6mQ
2025-06-24 22:40:52.622 Loading next batch of response using Point In Time. - y_T7MwDnSG-rblpw9Xa6mQ
2025-06-24 22:40:52.838 Loading next batch of response using Point In Time. - y_T7MwDnSG-rblpw9Xa6mQ
...
So a robust solution I think needs to fix both: the left index PIT needs to be kept alive long enough to scan the right index, and the right index PIT also needs to be extended. (Alternatively, we can skip extending the right index and just create both PITs with the correct timing, since we need that solution for the left index anyway.)
Did some more debugging across environments and discussed in side channels. Action items for this:
Modify the PIT creation logic to use a join timeout hint for keepalive if present; don't worry about PIT extension since it won't generalize to the left index
Improve the error handling around these timeouts, guide user to using join timeout hint if the query fails due to timeout
The actual issue is how this join timeout hint works with PIT keep_alive:
When join timeout <= keep_alive, ResourceManager will circuit-break the query (for example, in the default case, both are 60s).
When join timeout > keep_alive, if PIT doesn't auto-extend, the query will be stopped due to PIT not existing.
The proposal makes sense to me in terms of join timeout hint control PIT keep_alive in case PIT doesn't auto-extend. That would force case 2 to go to case 1.
However, if PIT can auto-extend, it will always go to case 1, and user can send new query with the hint as current codebase
Activity
penghuo commentedon Jun 25, 2025
Every time you access a PIT by using the Search API, the PIT lifetime is extended by the amount of time equal to the keep_alive parameter.
For Join, blockHash operator read one block from LeftTable, and iterate all data from rightTable. So if iterate all data from rightTable took more than keep_alive time, then the pit on LeftTable will be deleted.
Question, Could we confirm that iterate all data from rightTable took more than keep_alive time?
Swiddis commentedon Jun 25, 2025
Did some testing with @noCharger, it looks like on Serverless the PIT extension isn't automatic, so we have the right index PIT getting deleted after 60s. We'd need to add the keep_alive parameter to the PointInTimeBuilder for our batch loader to make it apply.
Here's a trace from the join running on it, out.txt. This is the right index PIT getting deleted for this query:
We can see that it creates the PIT on the logs_right index (the shards are listed at the end), paginates through the PIT (~6 pages/second), and then the PIT is dropped after 60s.
To your point, I do see that it loads the first batch of some earlier PITs before the big scan, which also would be deleted in spite of fixing the keepalive since no new pages are fetched for those other PITs.
So a robust solution I think needs to fix both: the left index PIT needs to be kept alive long enough to scan the right index, and the right index PIT also needs to be extended. (Alternatively, we can skip extending the right index and just create both PITs with the correct timing, since we need that solution for the left index anyway.)
Swiddis commentedon Jun 25, 2025
Did some more debugging across environments and discussed in side channels. Action items for this:
noCharger commentedon Jun 26, 2025
The actual issue is how this join timeout hint works with PIT
keep_alive:The proposal makes sense to me in terms of join timeout hint control PIT keep_alive in case PIT doesn't auto-extend. That would force case 2 to go to case 1.
However, if PIT can auto-extend, it will always go to case 1, and user can send new query with the hint as current codebase
Wire JOIN_TIME_OUT hint to PIT keepalive (opensearch-project#3820)