PG-2395 Make it clear we do not do any catcache looksups in ExecutorEnd - #811
Draft
jeltz wants to merge 2 commits into
Draft
PG-2395 Make it clear we do not do any catcache looksups in ExecutorEnd#811jeltz wants to merge 2 commits into
jeltz wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #811 +/- ##
==========================================
+ Coverage 88.47% 88.50% +0.03%
==========================================
Files 3 3
Lines 1301 1305 +4
Branches 180 181 +1
==========================================
+ Hits 1151 1155 +4
Misses 75 75
Partials 75 75 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jeltz
force-pushed
the
catcache-in-exectorend
branch
2 times, most recently
from
August 3, 2026 23:24
6649865 to
d22cc56
Compare
jeltz
marked this pull request as ready for review
August 3, 2026 23:24
As the query stats object is now guaranteed, since commit d25da64, to have been created in the ExecutorStart hook there is no need to also try to create it in the ExecutorEnd hook. This makes to code clearer for the reader, plus makes it obvious that we no longer can do any catcache updates before accessing the totaltime object.
One of our users reported a likely use after free bug on Amazon RDS that we could not reproduce where queryDesc->totaltime was freed when we accessed it. And while we failed to reproduce the bug a theory of ours is that in some cases a catalog cache lookup in ExecutorEnd could cause interrupts to be processed which then would for unknown reasons cause the totaltime object to be freed. If this theory is correct then as we no longer do any catalog cache lookups in the ExecutorEnd hook then the bug should be gone. This is of course all very speculative. Bug report: percona#651
jeltz
force-pushed
the
catcache-in-exectorend
branch
from
August 3, 2026 23:44
d22cc56 to
85ce181
Compare
jeltz
commented
Aug 4, 2026
| stats = pgsm_get_query_stats(queryId, planid, queryDesc->sourceText, queryDesc->operation); | ||
| /* We know at least pgsm_ExecutorStart() has created query stats */ | ||
| stats = pgsm_get_query_stats(queryId); | ||
| Assert(stats != NULL); |
Contributor
Author
There was a problem hiding this comment.
Note: this is likely wrong. We should probably move to a stack instead.
jeltz
marked this pull request as draft
August 5, 2026 10:55
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.
We may have potentially fixed #651 in d25da64.
One of our users reported a likely use after free bug on Amazon RDS that we could not reproduce where
queryDesc->totaltimewas freed when we accessed it. And while we failed to reproduce the bug a theory of ours is that in some cases a catalog cache lookup inExecutorEndcould cause interrupts to be processed which then would for unknown reasons cause thetotaltimeobject to be freed.If this theory is correct then as we no longer do any catalog cache lookups in the
ExecutorEndhook then the bug should be gone. This is of course all very speculative.Additionally this PR changes the code to make it 100% clear that no lookups can happen even though d25da64 should already have solved that,