From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> |
Cc: | Julien Rouhaud <rjuju123(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: backend type in log_line_prefix? |
Date: | 2020-03-11 18:53:54 |
Message-ID: | 20200311185354.GW29065@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Mar 10, 2020 at 02:01:42PM -0500, Justin Pryzby wrote:
> On Thu, Feb 13, 2020 at 06:43:32PM +0900, Fujii Masao wrote:
> > If we do this, backend type should be also included in csvlog?
>
> +1, I've been missing that
>
> Note, this patch seems to correspond to:
> b025f32e0b Add leader_pid to pg_stat_activity
>
> I had mentioned privately to Julien missing this info in CSV log.
>
> Should leader_pid be exposed instead (or in addition)? Or backend_type be a
I looked more closely and played with the patch.
Can I suggest:
$ git diff
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 3a6f7f9456..56e0a1437e 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2945,7 +2945,7 @@ write_csvlog(ErrorData *edata)
if (MyProcPid == PostmasterPid)
appendCSVLiteral(&buf, "postmaster");
else if (MyBackendType == B_BG_WORKER)
- appendCSVLiteral(&buf, MyBgworkerEntry->bgw_type);
+ appendCSVLiteral(&buf, MyBgworkerEntry->bgw_name);
else
appendCSVLiteral(&buf, pgstat_get_backend_desc(MyBackendType));
Then it logs the leader:
|2020-03-11 13:16:05.596 CDT,,,16289,,5e692ae3.3fa1,1,,2020-03-11 13:16:03 CDT,4/3,0,LOG,00000,"temporary file: path ""base/pgsql_tmp/pgsql_tmp16289.0"", size 4276224",,,,,,"explain analyze SELECT * FROM t a JOIN t b USING(i) WHERE i>999 GROUP BY 1;",,,"psql","parallel worker for PID 16210"
It'll be easy enough to extract the leader and join that ON leader=pid.
> I think this patch alone wouldn't provide that, and there'd need to either be a
> line logged for each worker. Maybe it'd log full query+details (ugh), or just
> log "parallel worker of pid...". Or maybe there'd be a new column with which
> the leader would log nworkers (workers planned vs workers launched - I would
> *not* want to get this out of autoexplain).
I'm still not sure how to do that, though.
I see I can get what's needed at DEBUG1:
|2020-03-11 13:50:58.304 CDT,,,16196,,5e692aa7.3f44,22,,2020-03-11 13:15:03 CDT,,0,DEBUG,00000,"registering background worker ""parallel worker for PID 16210""",,,,,,,,,"","postmaster"
But I don't think it's viable to run for very long with log_statement=all,
log_min_messages=DEBUG.
--
Justin
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-03-11 19:32:38 | Re: pg11+: pg_ls_*dir LIMIT 1: temporary files .. not closed at end-of-transaction |
Previous Message | Peter Eisentraut | 2020-03-11 18:01:45 | Re: User and Logical Replication |