Isolate SQL Server plan lookup failures - #25091
Draft
jasonmp85 wants to merge 3 commits into
Draft
Conversation
evalya-impact-summaryevalya impact analysis |
Contributor
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 529fdaa | Docs | View more details | Give us feedback! |
Two review points from the first pass. The plan-lookup guard reimplemented RateLimitingTTLCache.acquire's admission rules at the call site, reaching into `maxsize` and `__contains__`, so the policy now lived in two places. Give the cache a `would_acquire` method that answers the question without storing the key, and have acquire share it. The expected-database-exception set was defined identically in statements.py and data_observability.py. Move it next to SQLConnectionError in connection_errors.py, which already imports both drivers, and have both jobs use it.
Contributor
Validation ReportAll 21 validations passed. Show details
|
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.
What does this PR do?
Isolates each SQL Server execution-plan lookup so a timeout or other lookup error only skips that row. Customers now see a debug log and a dd.sqlserver.statements.error count tagged with the exception class instead of a query-metrics job-loop crash; collection continues with the remaining plan rows.
The plan rate limiter is acquired only after a successful lookup, so a failed plan is eligible for collection again on the next pass instead of being suppressed for the cache TTL. Cancellation is rechecked after lookup errors and still aborts collection.
The query-metrics job now uses the established SQL Server expected database exception set: SQLConnectionError, pyodbc.Error, and adodbapi.DatabaseError. Database errors that escape elsewhere are therefore reported as expected database warnings rather than crashes.
Validation: ddev test --lint sqlserver passed, and all unit tests in tests/test_statements.py passed in every compatible configured environment. The requested unfiltered ddev --no-interactive test sqlserver command was also attempted, but integration tests require SQL Server services that are not running in this worktree environment.
Motivation
On busy SQL Server instances, PLAN_LOOKUP_QUERY can time out. A single timeout currently escapes plan collection, terminates the query-metrics job loop until the next check run, and marks the failed plan as seen even though no plan event was collected. Per-row isolation preserves job liveness and makes the failed plan retryable.
Review checklist (to be filled by reviewers)