Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jC6UX-0007ox-Bz for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2020 18:54:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jC6UU-0006lk-7X for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2020 18:54:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jC6UT-0006ld-NE for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2020 18:54:01 +0000 Received: from mail-yw1-xc43.google.com ([2607:f8b0:4864:20::c43]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jC6UP-0005MJ-Sh for pgsql-hackers@postgresql.org; Wed, 11 Mar 2020 18:54:00 +0000 Received: by mail-yw1-xc43.google.com with SMTP id p69so3028912ywh.10 for ; Wed, 11 Mar 2020 11:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6yLeH61mO6feGOF/IA6a8lkZ+sOCeEZr9RoADPozgBw=; b=OJ3IRrsDkQw/89MSfzQmD20WNk9sVCwS4HnnUCelOWj4XY3hHe9x9IKeTEfAJx99dH XBdiR5rESCbmA1YDngQ5InnCnqYB8x9M3G8c0hPMrH5xpCRbysOHEjZKKOBvzMjUq/XJ dPsDf5L5L6N/B9nN8WU9q8G6De6dzKEdcGNWudrHe3uqFZux+w6QBChUGFI3LCTl0Loa 5DtD+GnPgk+p9DAlSq3V1+/PYftiOpkftvI1rtEdE+vGL5czUe98DL5sP0fRga06Rz4U vrHQPMmpYeoRkCqvQ8MkAN/AGNEwpSfry56n4DuDKPakdPtzNVCned+xxv5Ock5Fhz/0 gDsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6yLeH61mO6feGOF/IA6a8lkZ+sOCeEZr9RoADPozgBw=; b=iALXF0CsZnWUecPZXYsCGUOLkGkYwGljijK+3rUIR6c/GVt6ehAClkojzDUG844ml5 lTtyMw8l3gBcQWiUId8IhDFHa5RbQ6z9/QgP8IFaocXhS5GaRCpXRMjMIJeMUV4sJ5tv Lt5oKecyU77qgQm6tmjpfePpecM4t8cMlr/StC+7QXGSCHZwZyWOYJPWkUNIPYqKrhVy JBTVblS0/UfNUJjOgOW2FM4JoohoxzagdbbeGFKLn/tj9/fDtTqhLRc1MIfoRcYL3AUt IS0ev8xqLTa/LkSJ67ehzzB7kal+4mJ6tznkuFeLplm/u4194uoMkMaew0W3TxEh7f5p 9wxA== X-Gm-Message-State: ANhLgQ33maJMBVeiZTmQpn0PsmhNk0Ign8eqbBLTddMgaiDhhbnO1aMC Kr+agHrmdaKu107mFyDB5nTxqg== X-Google-Smtp-Source: ADFU+vv8ixII3YS4ChqTNooQpcxFNVpVqEU70pT+UDbltmuTZ1itsHQ1RNBcN3rlucruztrL8N4hIg== X-Received: by 2002:a25:b7d1:: with SMTP id u17mr4730931ybj.372.1583952836483; Wed, 11 Mar 2020 11:53:56 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id i124sm14450330ywa.81.2020.03.11.11.53.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2020 11:53:55 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 5CA5C8007F2; Wed, 11 Mar 2020 13:53:54 -0500 (CDT) Date: Wed, 11 Mar 2020 13:53:54 -0500 From: Justin Pryzby To: Fujii Masao Cc: Julien Rouhaud , Peter Eisentraut , pgsql-hackers Subject: Re: backend type in log_line_prefix? Message-ID: <20200311185354.GW29065@telsasoft.com> References: <20200213091428.GA15600@nol> <20200310190142.GB29065@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200310190142.GB29065@telsasoft.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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