Repository navigation
fix: keep probes independent of the database - #269
Merged
Merged
Conversation
Resume interrupted renames only before requests of the registry's operations, not before the Swagger UI (the probe path), the spec, the service info or FOCA's admin API. Log database errors in the hook instead of failing the request, and check for stale locks with a 2-second timeout instead of pymongo's 30-second server selection timeout. Correct the probe and rename docs. Closes #267 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use one filter of stale locks for the check before requests and for resuming renames. Test that exactly the registry's operations resume renames, that failures while resuming are logged, and that only the check runs with the short timeout. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR decouples probes and non-registry endpoints from MongoDB by limiting interrupted-rename recovery to registry operations, bounding only the stale-lock check, and handling database failures as logged, retryable conditions. It also centralizes stale-lock filtering, documents the behavior, and adds comprehensive route and failure regression tests. Sequence diagram for database-independent probe requestssequenceDiagram
participant Client
participant App
participant ProbeEndpoint
participant MongoDB
Client->>App: GET /ui/ or /service-info
App->>ProbeEndpoint: Handle request
ProbeEndpoint-->>Client: 200 response
Note over App,MongoDB: No resume_renames_periodically call
MongoDB--xApp: Unavailable
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #269 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 20 20
Lines 1976 1989 +13
=========================================
+ Hits 1976 1989 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
uniqueg
marked this pull request as ready for review
October 28, 2026 07:01
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/test_rename.py" line_range="1015-1020" />
<code_context>
+ original = pymongo.timeout
+
+ @contextmanager
+ def spy(seconds: float | None) -> Iterator[None]:
+ timeouts.append(seconds)
+ active.append(True)
+ with original(seconds):
+ yield
+ active.pop()
+
+ resumed: list[bool] = []
</code_context>
<issue_to_address>
**Timeout test misses an unbounded check**
When the implementation enters the timeout context but performs the stale-lock query after leaving it, `test_resume_before_requests_timeout` observes only that `pymongo.timeout` was entered and that resuming happened after it; it never observes whether `count_documents` ran inside the context, so the stale-lock check can run unbounded and the test still passes.
Spy on the stale-lock query and assert it runs while the timeout context is active.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: tests/test_rename.py:1020
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 28, 2026
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
Found in the pre-release review of 0.6.0 (M2): the rename resume hook from #262 ran before every request, so the probe path (
/ga4gh/registry/v1/ui/, also the image'sHEALTHCHECK), the spec and/service-infodepended on MongoDB. While MongoDB was unreachable, the first request per worker every 10 seconds waited 30 seconds (pymongo's server selection timeout) and then returned500, longer than the probes' 5-second timeout.cloud_registry.*operation IDs), not before the Swagger UI, the spec, the service info or FOCA's admin API.Interrupted renames not checked; tried again later: ...) instead of failing the request; the next check is due after the interval.pymongo.timeout(2.0); resuming itself, which takes several writes, is not limited. One filter of stale locks (locks.stale()) serves the check,resume_renames()andremove_stale_changes().docs/api.md(Renaming services) say which requests resume renames.Closes #267
Verification
Regression tests first (
tests/test_rename.py): withget_collectionfailing withServerSelectionTimeoutError,/ui/, the spec,/service-infoand the admin API returned500before the fix and don't now; API requests still resume renames, also after a failed check or resume; only the check runs under the short timeout; recent locks aren't resumed; every route of the app is classified correctly (operations vs. UI/spec/service info/admin API).Locally (Python 3.13):
coverage run -m pytest(mongomock): 1406 passed, 257 skipped (Helm not installed), coverage 100%pytestagainst MongoDB 7.0.34 (MONGODB_TEST_URI): 1408 passed, 255 skippedpre-commit run --all-files(ruff, semgrep, gitleaks, actionlint, ast-grep, mypy): passedmkdocs build --strict: passedDeclined review findings
checkcase of the failure test doesn't show that the timeout bounds a slow database (quality, low): mongomock ignorespymongo.timeout; the spy test checks that it is applied to the check only. The adversarial reviewer verified against an unreachable server thatcount_documentsunderpymongo.timeout(2.0)raises after 2 seconds.Open questions
None.
🤖 Generated with Claude Code