Fix for timestamp lag issue from emit_log_hook when GUC log_line_prefix has '%m'

From: Kambam Vinay <vinaykambam(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Fix for timestamp lag issue from emit_log_hook when GUC log_line_prefix has '%m'
Date: 2024-03-09 15:39:39
Message-ID: CANiRfmsK36A0i8mnQtzaxhSm3CUCimPwJPp4WQNq53OdSNkgWg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
0001-set-saved_timeval_set-to-false-before-executing-emit.patch application/octet-stream 797 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2024-03-09 17:56:19 Re: Improving contrib/tablefunc's error reporting
Previous Message Nathan Bossart 2024-03-09 14:50:28 Re: pg_column_toast_chunk_id: a function to get a chunk ID of a TOASTed value