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] PIT is not deleted when a Calcite query is rejected for memory at start #5860
When a query is rejected with Insufficient resources to start query, the PIT it already created is never deleted. It stays open until plugins.sql.cursor.keep_alive (1m) expires.
In CalciteEnumerableIndexScan.enumerator(), osIndex.buildRequest(...) is passed as a constructor argument, so it runs first and creates the PIT. The OpenSearchIndexEnumerator constructor then fails its memory check and throws, so no enumerator exists and close() never runs to delete the PIT.
Run a full-scan query 20 times, e.g. source=big | eval z=concat(s, cast(k as string)) | eventstats count() as c by g | sort - z | head 5.
Check point_in_time_current in _nodes/stats/indices/search.
###Expected Result:
no open PIT contexts after the queries fail.
Actual Result:
every "start query" rejection leaves 2 open PIT contexts (one per shard) until they expire. Queries rejected mid-scan ("continue processing") don't leak, and neither do successful ones.
Impact:
under memory pressure, rejected queries pile up open PIT contexts toward search.max_open_pit_context (300). New queries can keep failing for up to a minute after memory recovers. Async submits make this easier to hit.
Suggested fix:
check the resource monitor before calling buildRequest, or delete the PIT if the constructor throws.
A rejected query leaking its PIT turns backpressure into slow resource exhaustion. Deleting the PIT in the rejection path, or tying PIT lifetime to the request that created it, closes the leak. A test that rejects queries in a loop and asserts the open PIT count stays flat would lock in the fix.
Activity
cc-bb-aa commentedon Oct 10, 2026
A rejected query leaking its PIT turns backpressure into slow resource exhaustion. Deleting the PIT in the rejection path, or tying PIT lifetime to the request that created it, closes the leak. A test that rejects queries in a loop and asserts the open PIT count stays flat would lock in the fix.
test(async-ppl): disable flaky PIT-closure assertion in assertStopped