-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify bgworker initialization to prevent showing garbage in pg_stat_activity #20
Merged
Conversation
This file contains 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
…pe by filling bgw_type in BackgroundWorker structure. If bgw_type is empty string then we copy bgw_name into bgw_type. But in _PG_init BackgroundWorker structure is not fully initialized, so it can be garbage in bgw_type field. And this garbage will be shown in backend_type column in pg_stat_activity. We can bypass it by setting bgw_type. We can also use memset to zero our structure. Then bgw_name value will be copied into bgw_type
Seems great to me. rjuju ? |
Indeed, good catch! Minor nitpicking, could you use tab instead of spaces for the indentation, and remove the trailing whitespace? |
Hello! Thank you for your reply. Yes, I'll do that |
remove trailing whitespace and use tab instead of spaces for identation
Thanks a lot! |
Thank you! |
Kudos guys this project is amazing ;-) |
blogh
added a commit
to blogh/pg_activity
that referenced
this pull request
Apr 9, 2020
* This commit attenpts to solve issue : dalibo#130 [1]. * PoWA has a bug where backend_type is not correctly filled [2]. it was fixed but it's not in the stable version yet. * Since [3], we queried for the `backend_type` and filtered `parallel workers` in the Python code. The test is now done in SQL, which avoids the problems all together. * The `parallel worker` detection was not working for pg 11+ because it uses the 'parallel worker' backend_type. It's now fixed. [1] dalibo#130 [2] powa-team/powa-archivist#20 [3] dalibo@6a180d8
blogh
added a commit
to blogh/pg_activity
that referenced
this pull request
Apr 9, 2020
* This commit attempts to solve the issue : dalibo#130 [1]. * PoWA has a bug where `backend_type` is not correctly filled [2]. it was fixed but it's not in the stable version yet. * Since [3], we queried for the `backend_type` and filtered `parallel workers` in the Python code. The test is now done in SQL, which avoids the problems all together. * The `parallel worker` detection was not working for pg 11+ because it uses the 'parallel worker' backend_type. It's now fixed. [1] dalibo#130 [2] powa-team/powa-archivist#20 [3] dalibo@6a180d8
This was referenced Apr 9, 2020
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.
Hello, team
From postgres 11 there is opportunity to specify background worker type by filling bgw_type in BackgroundWorker structure. If bgw_type is empty string then we copy bgw_name into bgw_type. But in _PG_init BackgroundWorker structure is not fully initialized, so it can be garbage in bgw_type field. And this garbage will be shown in backend_type column in pg_stat_activity. We can bypass it by setting bgw_type. We can also use memset to zero BackgroundWorker structure. Then bgw_name value will be copied into bgw_type