Fix 'too many LWLocks taken' error when scanning hypertables#167
Merged
tjgreen42 merged 3 commits intorelease/0.4.1from Jan 23, 2026
Merged
Fix 'too many LWLocks taken' error when scanning hypertables#167tjgreen42 merged 3 commits intorelease/0.4.1from
tjgreen42 merged 3 commits intorelease/0.4.1from
Conversation
Release the per-index LWLock after tp_memtable_search() completes in tp_execute_scoring_query(). The lock was being acquired but never released, causing locks to accumulate when querying hypertables with many chunks (e.g., 587 chunks). This is the scan-path equivalent of the build-path fix in b7f6539.
The lock upgrade warning no longer occurs because we release the per-index lock after tp_memtable_search() completes.
tjgreen42
commented
Jan 22, 2026
Collaborator
Author
tjgreen42
left a comment
There was a problem hiding this comment.
Trivial change to trigger CI
Signed-off-by: Todd J. Green <tj@timescale.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes "too many LWLocks taken" error when querying BM25 indexes on hypertables with many chunks.
Problem
When scanning a hypertable with many chunks (e.g., 587), each chunk's BM25 index scan acquires a per-index LWLock but never releases it until transaction end, exceeding Postgres's ~200 lock limit.
Solution
Release the lock immediately after
tp_memtable_search()returns, since we've already extracted all CTIDs into memory.This is the scan-path equivalent of the build-path fix in b7f6539.
Testing