With retention rules and queries that span aged segments there can be race conditions that would cause this.
How prevalent is this issue?
Are all queries time-bound?
You can handle it by filtering queries on the primary __time column such that it never spans the periods that are getting aged out.
Hope this helps,
Sergio
I am making the assumption that the datasource has a __time column defined in the ingestion.
So assuming that you are discarding anything older than 365 days using a retention rule, your SQL query would be:
SELECT …
FROM …
WHERE __time > CURRENT_TIMESTAMP - ( 365 * INTERVAL ‘1’ DAY)
such that you are only querying data that within the retained 365 days.