On Friday, 10 May 2024 at 20:17, Bruce Momjian <[email protected]> wrote:
>
> log_line_prefix supports application name --- why would you not use
> that?
>
log_line_prefix is effective in the server log. This change is mostly about
improving the message sent back to the client. While the server log is also
changed to reflect the client message, it doesn't need to be.
Additionally, with `%a` added to log_line_prefix, the server log would only
contain the application name of the client affected by the deadlock, not the
application names of all other clients involved in it.
Example server log with application names (here: a and b) added to the log
prefix:
2024-05-10 20:39:58.459 BST [197591] (a)ERROR: deadlock detected
2024-05-10 20:39:58.459 BST [197591] (a)DETAIL: Process 197591
(application_name: a) waits for ShareLock on transaction 782; blocked by
process 197586.
Process 197586 (application_name: b) waits for ShareLock on transaction
781; blocked by process 197591.
Process 197591, (application_name: a): SELECT * FROM q WHERE id = 2 FOR
UPDATE;
Process 197586, (application_name: b): SELECT * FROM q WHERE id = 1 FOR
UPDATE;
2024-05-10 20:39:58.459 BST [197591] (a)HINT: See server log for query details.
2024-05-10 20:39:58.459 BST [197591] (a)CONTEXT: while locking tuple (0,2) in
relation "q"
2024-05-10 20:39:58.459 BST [197591] (a)STATEMENT: SELECT * FROM q WHERE id =
2 FOR UPDATE;
All log line prefixes refer to the application a. The message has both a and b.
Anyway, the server log is not the important part here. The crucial UX feature
is the client getting application names back, so browsing through server logs
can be avoided.
Best,
Karoline