Skip to content
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
merged 2 commits into from
Jan 24, 2019

Conversation

ppetrov91
Copy link
Contributor

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

…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
@marco44
Copy link
Contributor

marco44 commented Jan 24, 2019

Seems great to me. rjuju ?

@rjuju
Copy link
Member

rjuju commented Jan 24, 2019

Indeed, good catch!

Minor nitpicking, could you use tab instead of spaces for the indentation, and remove the trailing whitespace?

@ppetrov91
Copy link
Contributor Author

Hello!

Thank you for your reply. Yes, I'll do that

remove trailing whitespace and use tab instead of spaces for identation
@rjuju rjuju merged commit 5abdc23 into powa-team:master Jan 24, 2019
@rjuju
Copy link
Member

rjuju commented Jan 24, 2019

Thanks a lot!

@ppetrov91
Copy link
Contributor Author

Thank you!

@jpargudo
Copy link

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
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