public inbox for [email protected]
help / color / mirror / Atom feedFrom: Kambam Vinay <[email protected]>
To: [email protected]
Subject: Fix for timestamp lag issue from emit_log_hook when GUC log_line_prefix has '%m'
Date: Sat, 9 Mar 2024 21:09:39 +0530
Message-ID: <CANiRfmsK36A0i8mnQtzaxhSm3CUCimPwJPp4WQNq53OdSNkgWg@mail.gmail.com> (raw)
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
Attachments:
[application/octet-stream] 0001-set-saved_timeval_set-to-false-before-executing-emit.patch (797B, ../CANiRfmsK36A0i8mnQtzaxhSm3CUCimPwJPp4WQNq53OdSNkgWg@mail.gmail.com/3-0001-set-saved_timeval_set-to-false-before-executing-emit.patch)
download | inline diff:
From c8ecea2375ee3ec46117ac06b384f39da560670e Mon Sep 17 00:00:00 2001
From: Vinay Kambam <[email protected]>
Date: Sat, 9 Mar 2024 19:52:10 +0530
Subject: [PATCH] set saved_timeval_set to false before executing
emit_log_hook()
---
src/backend/utils/error/elog.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index ed8aa5c9fa..e735f51207 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -1697,6 +1697,7 @@ EmitErrorReport(void)
* message identifier. Note that the original text is not available for
* detail, detail_log, hint and context text elements.
*/
+ saved_timeval_set = false;
if (edata->output_to_server && emit_log_hook)
(*emit_log_hook) (edata);
--
2.34.1
view thread (6+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: Fix for timestamp lag issue from emit_log_hook when GUC log_line_prefix has '%m'
In-Reply-To: <CANiRfmsK36A0i8mnQtzaxhSm3CUCimPwJPp4WQNq53OdSNkgWg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox