Repository navigation
Release uncertain lexical leases that can no longer cover a request - #602
Merged
Merged
Conversation
An index-use lease turns uncertain when its holder loses track of an in-flight OpenSearch request, and nothing ever released it again. Until then its build stays pending cleanup, its namespace index cannot close as empty, and its revision's indexing input is retained. - Build cleanup now always releases its own lease. A delete with an unknown outcome can only remove the retired or failed build's records, and the build stays pending until a later delete verifies it is empty. - The hourly maintenance sweep first releases uncertain leases that expired more than 15 minutes ago. Writers check their lease before every batch, so after expiry at most one request is still in flight, and it ends within the 30-second request timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The failure transition records audit metadata through make_json_safe, which imports numpy and pandas on first use. When nothing earlier in the process had loaded them, that import (about half a second) landed inside the measured region and exceeded the 0.40-second bound. Run make_json_safe once before the timer starts so the test measures cancellation only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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
An index-use lease becomes
uncertainwhen its holder loses track of an in-flight OpenSearch request. No code ever released one again, and an unreleased lease blocks three things for good:Two sources produced them:
This PR also hardens
test_execution_timeout_stops_native_wait_and_returns_without_replay, which failed twice on this branch's CI at 0.72 s against its 0.40 s bound. Its timed region included the firstmake_json_safecall, which imports numpy and pandas lazily (about 0.5 s cold). The test now callsmake_json_safe({})before the timer starts. The bound stays the same.Writer leases (indexing and shadow backfill) still turn
uncertainon an unknown write outcome. The sweep releases them only after the grace period. Writers require anactivelease before every batch, so once the lease expires at most one request is still in flight, and it ends within the 30-second native request timeout.Evidence
uncertainleases: 55 from delete timeouts, 4 from indexing attempts that expired. Because of them, 4 failed builds were retried every hour without ever completing, and 3 empty namespace indexes stayed open.After (new contract tests, PostgreSQL 16):
mainand pass with this change. All 29 tests intest_lexical_maintenance_contract.pypass. Ruff and pyright report nothing on the changed files.Merge Danger
Door: two-way
Reverting restores the old behaviour. A lease released by the sweep is not set back to
uncertainby a revert, but it would have stayed blocked forever otherwise.Blast Radius: lexical-maintenance
Takes effect on the next worker release. The first hourly sweep after that releases the existing settled leases, then completes their builds and lets empty namespace indexes close. If a write somehow landed more than 15 minutes after its lease expired, that failed build's records could stay in the index. Retrieval reads only published builds, so they would not show up in results.
🤖 Generated with Claude Code