[BUG] PIT is not deleted when a Calcite query is rejected for memory at start
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 55/100
Research direction
Start in CalciteEnumerableIndexScan.enumerator(), where osIndex.buildRequest(...) runs as a constructor argument and creates the PIT before OpenSearchIndexEnumerator's constructor performs the memory check and may throw. Read that constructor and its close() method to see why the PIT is never deleted. Done means that a rejected query leaves no open PIT contexts, either because the memory check runs before buildRequest or because the PIT is deleted when the constructor throws, and a test covers that path.
Written by the indexing model from the issue text.
Description
Issue Summary:
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.
Steps to Reproduce:
- Index 200k docs into a 2-shard index.
- Bring heap above
plugins.query.memory_limit(default 85%). - 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_currentin_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.
Env Setup - OpenSearch Version:
3.10.0-SNAPSHOT, main @ 866dafcbd
- Dominant language
- Java
- Stars
- 176
- Forks
- 237
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 34
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from opensearch-project/sql
-
bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
opensearch-project/sql#5990 ·
Maintainers usually reply within 1 day
-
bug untriaged
Difficulty 1/5 Under an hour Newbie friendliness 85/100
opensearch-project/sql#5983 ·
Maintainers usually reply within 1 day
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"Possibly taken @nagendramohan claimed this 107 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
opensearch-project/sql#5684 · 4 comments ·
Maintainers usually reply within 1 day
-
[DOC] Calcite settings documentation missing examplesPossibly taken @AzazelSensei claimed this 64 days ago. Opendocumentation PPL
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
opensearch-project/sql#4806 · 1 comment ·
Maintainers usually reply within 1 day
-
calcite enhancement Meta performance PPL untriaged
Difficulty 5/5 Over a week Newbie friendliness 8/100
opensearch-project/sql#5991 ·
Maintainers usually reply within 1 day
All issues in opensearch-project/sql
Similar issues
-
chore
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
lugassawan/swe-workbench#841 ·
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
EndlessPixel-Studio/FakePlayer-CE#155 ·
Maintainers usually reply within 1 day
-
Document the isv:HDFGroup Linux package repositories and signing keyPossibly taken @brtnfld claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
checkstyle/checkstyle#23174 ·
Maintainers usually reply within 1 day