Fix for timestamp lag issue from emit_log_hook when GUC log_line_prefix has '%m' - Mailing list pgsql-hackers

From Kambam Vinay
Subject Fix for timestamp lag issue from emit_log_hook when GUC log_line_prefix has '%m'
Date
Msg-id CANiRfmsK36A0i8mnQtzaxhSm3CUCimPwJPp4WQNq53OdSNkgWg@mail.gmail.com
Whole thread Raw
Responses Re: Fix for timestamp lag issue from emit_log_hook when GUC log_line_prefix has '%m'
List pgsql-hackers
Hi, 

We observed a slight lag in timestamp for a few logs from the emit_log_hook hook implementation when the log_line_prefix GUC has '%m'.

Upon debugging, we found that the saved_timeval_set variable is set to 'true' in get_formatted_log_time() but is not reset to 'false' until the next call to send_message_to_server_log(). Due to this, saved_timeval_set will be true during the execution of hook emit_log_hook() which prefixes the saved timestamp 'saved_timeval' from the previous log line (our hook implementation calls log_line_prefix()).

Attached patch sets the saved_timeval_set to false before executing the emit_log_hook()

Thanks,
Vinay
Attachment

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: pg_column_toast_chunk_id: a function to get a chunk ID of a TOASTed value
Next
From: Joe Conway
Date:
Subject: Re: Improving contrib/tablefunc's error reporting