powa-team / powa-archivist

powa-archivist: the powa PostgreSQL extension
http://powa.readthedocs.io/
PostgreSQL License
51 stars 20 forks source link

Modify bgworker initialization to prevent showing garbage in pg_stat_activity #20

Closed ppetrov91 closed 5 years ago

ppetrov91 commented 5 years ago

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

marco44 commented 5 years ago

Seems great to me. rjuju ?

rjuju commented 5 years ago

Indeed, good catch!

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

ppetrov91 commented 5 years ago

Hello!

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

rjuju commented 5 years ago

Thanks a lot!

ppetrov91 commented 5 years ago

Thank you!

jpargudo commented 5 years ago

Kudos guys this project is amazing ;-)