pgauditlogtofile icon indicating copy to clipboard operation
pgauditlogtofile copied to clipboard

Initialize background worker with zero

Open df7cb opened this issue 1 year ago • 3 comments

Particularly, this sets bgw_type to empty which would otherwise print uninitialized data in the "background worker started" log message. (The PG log machinery will fall back to printing bgw_name instead.) We could instead just initialize bgw_type, but it seems safer to initialize all fields.

df7cb avatar Aug 15 '24 09:08 df7cb

Example of a corrupted log message:

2024-08-15 11:43:49.196 CEST,,,575619,,66bdcdd5.8c883,1,,2024-08-15 11:43:49 CEST,,0,LOG,00000,"pgauditlogtofile worker started",,,,,,,,,"","@��3�",,0

df7cb avatar Aug 15 '24 09:08 df7cb

Thank you for finding this. Indeed it could be possible. I'm not able to reproduce it, your log message looks like a pgaudit line that should not appear. Can you share your settings?

I think it would be better to use MemSet as in other parts of PostgreSQL code (ie. autoprewarm)

fmbiete avatar Aug 15 '24 17:08 fmbiete

You need csvlog enabled to see the borked bgw_type field. Besides that, no special settings besides enabling pgaudit.log=all.

It's a static struct so = {0} will fully initialize it, no need for memset or other dynamic features.

df7cb avatar Aug 15 '24 20:08 df7cb