Fix 'too many LWLocks taken' error on partitioned tables#135
Merged
Conversation
0e71d61 to
7c65a0f
Compare
When creating a BM25 index on a partitioned table with many partitions (>140), the index creation would fail with "too many LWLocks taken" because: 1. Each partition index build acquires a per-index LWLock during document processing but doesn't release it until transaction end 2. Dynamic LWLock tranche IDs were allocated for each index, exhausting the available tranche IDs This fix: - Uses fixed tranche IDs (1001-1008) for all extension LWLocks instead of dynamically allocating new tranche IDs per index - Releases the per-index lock at the end of each index build, allowing locks to be reused between partition index builds within the same transaction Tested with 600 partitions successfully where previously it failed at partition ~142.
7c65a0f to
c36edaf
Compare
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 #134
Problem
When creating a BM25 index on a partitioned table, Postgres creates an index on each partition within a single transaction. The extension was:
This caused failures at around partition 142.
Solution
tp_build()so locks can be reusedTesting