Use TopTransactionContext lifetime for PGSM local data#656
Use TopTransactionContext lifetime for PGSM local data#656artemgavrilov wants to merge 1 commit into
Conversation
| if (MemoryContextIsValid(TopTransactionContext)) | ||
| { | ||
| MemoryContextRegisterResetCallback(MessageContext, &mem_cxt_reset_callback); | ||
| MemoryContextRegisterResetCallback(TopTransactionContext, &mem_cxt_reset_callback); |
There was a problem hiding this comment.
It seems that TopTransactionContext always exists, no matter how query was executed.
| BufferUsage bufusage_start = pgBufferUsage; | ||
| WalUsage walusage; | ||
| WalUsage walusage_start = pgWalUsage; | ||
| pgsmEntry *entry = pgsm_create_hash_entry(0, queryId, NULL); |
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.
| * 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); |
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.
| WalUsage walusage; | ||
| WalUsage walusage_start = pgWalUsage; | ||
| pgsmEntry *entry = pgsm_create_hash_entry(0, queryId, NULL); | ||
| int64 appid; |
There was a problem hiding this comment.
isn't an = 0 missing from here? otherwise it will remain uninitialized in the !pgsm_track_application_names case
There was a problem hiding this comment.
Yep, it is. This PR was just brief draft to present the idea, it doesn't worth to review it I think.
PG-0
Description
Links