Use TopTransactionContext lifetime for PGSM local data#656
Draft
artemgavrilov wants to merge 1 commit into
Draft
Use TopTransactionContext lifetime for PGSM local data#656artemgavrilov wants to merge 1 commit into
artemgavrilov wants to merge 1 commit into
Conversation
artemgavrilov
commented
May 15, 2026
Comment on lines
+394
to
+396
| if (MemoryContextIsValid(TopTransactionContext)) | ||
| { | ||
| MemoryContextRegisterResetCallback(MessageContext, &mem_cxt_reset_callback); | ||
| MemoryContextRegisterResetCallback(TopTransactionContext, &mem_cxt_reset_callback); |
Contributor
Author
There was a problem hiding this comment.
It seems that TopTransactionContext always exists, no matter how query was executed.
artemgavrilov
commented
May 15, 2026
| BufferUsage bufusage_start = pgBufferUsage; | ||
| WalUsage walusage; | ||
| WalUsage walusage_start = pgWalUsage; | ||
| pgsmEntry *entry = pgsm_create_hash_entry(0, queryId, NULL); |
Contributor
Author
There was a problem hiding this comment.
We cannot invoke this function here anymore, as some utility queries create and finish multiple transactions during its processing. Vacuum for example. But we still need username and application name that triggered the query. Without this SET application_name = new app will log new app as query tirgger.
artemgavrilov
commented
May 15, 2026
| * because at this point app name may be changed by the query itself | ||
|
|
||
| /* Get the application name and set appid */ | ||
| app_name_len = pg_get_application_name(app_name, APPLICATIONNAME_LEN); |
Contributor
Author
There was a problem hiding this comment.
This line updates global variable app_name, we shouldn't do it here as it affects what app name will be logged for SET application_name = new app query.
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.
PG-0
Description
Links