Skip to content

fix: When sql explain plan generation fails, don't attempt to generate an explain plan on future invocations of the same query.#3075

Merged
tippmar-nr merged 20 commits intomainfrom
fix/failed-explain-plan-caching
Apr 3, 2025
Merged

fix: When sql explain plan generation fails, don't attempt to generate an explain plan on future invocations of the same query.#3075
tippmar-nr merged 20 commits intomainfrom
fix/failed-explain-plan-caching

Conversation

@tippmar-nr
Copy link
Copy Markdown
Member

@tippmar-nr tippmar-nr commented Apr 1, 2025

Adds a cache for tracking queries where explain plan generation attempt throws an exception, so that future execution of the same query will not attempt to generate an explain plan. This fix will help ensure database performance doesn't suffer due to repeated, failed explain plan generation attempts.

Cache capacity is configured to 1000 queries, which should be far more than we ever experience in the wild - it is anticipated that explain plan failures are a very rare occurrence.

Includes unit and integration tests.

@tippmar-nr tippmar-nr requested a review from a team as a code owner April 1, 2025 18:54
@tippmar-nr tippmar-nr marked this pull request as draft April 1, 2025 18:54
@tippmar-nr tippmar-nr changed the title **DRAFT** fix: When sql explain plan generation fails, cache the query and don't attempt to generate an explain plan on future invocations. fix: When sql explain plan generation fails, cache the query and don't attempt to generate an explain plan on future invocations. Apr 1, 2025
@tippmar-nr tippmar-nr marked this pull request as ready for review April 1, 2025 19:51
Comment thread src/Agent/NewRelic/Agent/Core/Segments/DatastoreSegmentData.cs
Comment thread src/Agent/NewRelic/Agent/Core/Segments/DatastoreSegmentData.cs Outdated
@tippmar-nr tippmar-nr enabled auto-merge (squash) April 3, 2025 16:32
@tippmar-nr tippmar-nr changed the title fix: When sql explain plan generation fails, cache the query and don't attempt to generate an explain plan on future invocations. fix-this-broken-prefix: When sql explain plan generation fails, cache the query and don't attempt to generate an explain plan on future invocations. Apr 3, 2025
@tippmar-nr tippmar-nr changed the title fix-this-broken-prefix: When sql explain plan generation fails, cache the query and don't attempt to generate an explain plan on future invocations. fixture: When sql explain plan generation fails, cache the query and don't attempt to generate an explain plan on future invocations. Apr 3, 2025
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 97.36842% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.29%. Comparing base (121c6b8) to head (fab571a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...wRelic/Agent/Core/Segments/DatastoreSegmentData.cs 95.23% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3075      +/-   ##
==========================================
+ Coverage   82.22%   82.29%   +0.07%     
==========================================
  Files         477      477              
  Lines       30627    30659      +32     
  Branches     3426     3429       +3     
==========================================
+ Hits        25182    25232      +50     
+ Misses       4644     4627      -17     
+ Partials      801      800       -1     
Flag Coverage Δ
Agent 83.36% <97.36%> (+0.08%) ⬆️
Profiler 72.51% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...elic/Agent/Core/Database/CacheByDatastoreVendor.cs 100.00% <100.00%> (ø)
...s/NewRelic.Agent.Extensions/Caching/SimpleCache.cs 98.50% <100.00%> (+11.20%) ⬆️
...wRelic/Agent/Core/Segments/DatastoreSegmentData.cs 92.81% <95.23%> (+10.69%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tippmar-nr tippmar-nr changed the title fixture: When sql explain plan generation fails, cache the query and don't attempt to generate an explain plan on future invocations. fix: When sql explain plan generation fails, cache the query and don't attempt to generate an explain plan on future invocations. Apr 3, 2025
@tippmar-nr tippmar-nr changed the title fix: When sql explain plan generation fails, cache the query and don't attempt to generate an explain plan on future invocations. fix: When sql explain plan generation fails, don't attempt to generate an explain plan on future invocations of the same query. Apr 3, 2025
@tippmar-nr tippmar-nr disabled auto-merge April 3, 2025 17:15
@tippmar-nr tippmar-nr enabled auto-merge (squash) April 3, 2025 17:15
@tippmar-nr tippmar-nr disabled auto-merge April 3, 2025 19:04
@tippmar-nr tippmar-nr merged commit 12e1743 into main Apr 3, 2025
99 of 101 checks passed
@tippmar-nr tippmar-nr deleted the fix/failed-explain-plan-caching branch April 3, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants