Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jtuiV-0001fC-5b for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jul 2020 15:13:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jtuiU-0005Dl-2D for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jul 2020 15:13:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jtuiT-0005BH-RZ for pgsql-hackers@lists.postgresql.org; Fri, 10 Jul 2020 15:13:33 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jtuiR-0001jm-Dw for pgsql-hackers@postgresql.org; Fri, 10 Jul 2020 15:13:33 +0000 Received: by mail-wr1-x444.google.com with SMTP id z15so6321398wrl.8 for ; Fri, 10 Jul 2020 08:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Zg9koj4pVeETLbYwQyKu7aadfOmnEmqtSS/6OhqkibY=; b=EzNneCzxwyTof4IryvbabazR3ZoywrzPAb+P1b1akWKan9Mud23teg87cEKq/4DPMG mOrlbjGKRmkEvLpqG1BWjIOZwh1T+m15CfmIq0eS6BZTGnf0SMQ7oWlnY2x/86/5ezeh sVQM22r932UV8yySk27KLahRPpXnCg+rYgAs/qFmFo2KjZ/yuGLtZvVpnL7JnfbtaEIu +DEB+0l7zqVJLVJlWmz8Ld7ehobpH5bsGzAze9usr6HnJref9DrwHJ0R5qTTylQl8gCT 8TmaU4RK/uWyTVJ5/jMB5BHqmtH3rLAw10VHGysmDMgqhGzSgT4sQZmkVzzn8ACCde1x /RDg== 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; bh=Zg9koj4pVeETLbYwQyKu7aadfOmnEmqtSS/6OhqkibY=; b=F8RpaJtZbWfmKAv8qiJol/dI6udlo7scxS75/GO28V+nH0+J0vq3KjiVscc4O+7Cf1 5RzoKjzLYm/G8jlzVGjuyyf2GSxQvOmUaqroyCg9t+JzSGX9bIgqpi2L5zNebO7FNZNV pS3rFa+p9l5ZvV6n3YO2+Bls3WQDBMjhAgUzSSl+vhadHqYa4zOAAnFJmdHbLew8rE2H gXNAD8zpOu28ul9jEYKLxTWT2AXFyHNucMkcVDh1kPGIJ4ZTI5bxAIu8Vy4iC1NugQFI JUFnCc7SvwlwFrmqaqbnAUbS3aUlyQ5qMJXvhWEvUzQV2pmGapzvqeXAGuQOs/LABHGg yK1Q== X-Gm-Message-State: AOAM531Dz3VCcK0jqgFCPgMxQKxFgobWJ4mzefEBiMqBxFO96wiXKN0q uOeRD6VbYibtt6MSseJrc5RJVMQRAxQ= X-Google-Smtp-Source: ABdhPJz89A45UqZJCObdnhp4r6qrJFd+VwGzmxg/q9f0da6LcL/F/79VSvKKqGvi1MHE9dIfChSIYA== X-Received: by 2002:a5d:55c9:: with SMTP id i9mr67144316wrw.404.1594394010381; Fri, 10 Jul 2020 08:13:30 -0700 (PDT) Received: from nol (82-64-124-11.subs.proxad.net. [82.64.124.11]) by smtp.gmail.com with ESMTPSA id f197sm10738841wme.33.2020.07.10.08.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 08:13:29 -0700 (PDT) Date: Fri, 10 Jul 2020 17:13:26 +0200 From: Julien Rouhaud To: Justin Pryzby Cc: Michael Paquier , Daniel Gustafsson , pgsql-hackers@postgresql.org Subject: Re: expose parallel leader in CSV and log_line_prefix Message-ID: <20200710151326.fics6czbbvloplsk@nol> References: <20200315111831.GA21492@telsasoft.com> <20200315114933.udjdx5wcgwkjnw45@nol> <20200318212511.GN26184@telsasoft.com> <8EC64544-2EAA-48B1-8B69-85158CA3EAE9@yesql.se> <20200710020940.GJ11153@paquier.xyz> <20200710022023.GE26220@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200710022023.GE26220@telsasoft.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jul 09, 2020 at 09:20:23PM -0500, Justin Pryzby wrote: > On Fri, Jul 10, 2020 at 11:09:40AM +0900, Michael Paquier wrote: > > On Thu, Jul 09, 2020 at 01:53:39PM +0200, Julien Rouhaud wrote: > > > Sure! I've been quite busy with internal work duties recently but > > > I'll review this patch shortly. Thanks for the reminder! > > > > Hmm. In which cases would it be useful to have this information in > > the logs knowing that pg_stat_activity lets us know the link between > > both the leader and its workers? > > PSA is an instantaneous view whereas the logs are a record. That's important > for shortlived processes (like background workers) or in the case of an ERROR > or later crash. > > Right now, the logs fail to include that information, which is deficient. Half > the utility is in showing *that* the log is for a parallel worker, which is > otherwise not apparent. Yes, I agree that this is a nice thing to have and another smell step toward parallel query monitoring. About the patch: + case 'k': + if (MyProc) + { + PGPROC *leader = MyProc->lockGroupLeader; + if (leader == NULL) + /* padding only */ + appendStringInfoSpaces(buf, + padding > 0 ? padding : -padding); + else if (padding != 0) + appendStringInfo(buf, "%*d", padding, leader->pid); + else + appendStringInfo(buf, "%d", leader->pid); + } + break; There's a thinko in the padding handling. It should be dones whether MyProc and/or lockGroupLeader is NULL or not, and only if padding was asked, like it's done for case 'd' for instance. Also, the '%k' escape sounds a bit random. Is there any reason why we don't use any uppercase character for log_line_prefix? %P could be a better alternative, otherwise maybe %g, as GroupLeader/Gather?