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.89) (envelope-from ) id 1iwRHs-0004XT-Qd for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Jan 2020 13:52:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iwRHr-00048B-Bf for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Jan 2020 13:52:15 +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 1iwRHq-000483-Vo for pgsql-hackers@lists.postgresql.org; Tue, 28 Jan 2020 13:52:15 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iwRHo-0000o2-4m for pgsql-hackers@lists.postgresql.org; Tue, 28 Jan 2020 13:52:13 +0000 Received: by mail-wm1-x342.google.com with SMTP id g1so2587542wmh.4 for ; Tue, 28 Jan 2020 05:52:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8ml94zISwxPzA4MdkgIv75SQPP/jLRVC0Edfs/bW34w=; b=vk0O/qUx+j9KfnReSyJHnHXRqK8dr3UZwBXJVevfXZmH5f60yUTyWG6vAWNdPsLELZ 7+GQ5PnYFsAhdFc9Eo3ZIuaTW2hWZAs/1pvcGdjOYjlUO2u8YspLq0wsK/7RagqyPKY3 g3f/i1pt6BuLs1mNz5nuRTFNx6xBSMU/6tlcRtfOxe3vMmV7AnLhOErIPInzu4qEU5AG fRmOwu7qeHYp6Pw3xyS365qkkxP8DYajt7OzQp3nbuLhOrWWrWFx3dWzpTs7k89VrVM3 nFHZb/BOWj4Xc3ofNQwuyyfzX1aSmtSPySMZt8huCSrPQCDOu4QWmxsh6ZzrLqt85NtS 2ymw== 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=8ml94zISwxPzA4MdkgIv75SQPP/jLRVC0Edfs/bW34w=; b=NNNh2ZLwT0O4qFEgXxOB2IlK4FfD1kHVxl+H8I5sK6Rr28kL0WYX9MyVAgCZZl8Idi tO4y3dvV0iT+V88x3dNTgK0hH1F4nRHhc5jOLaJXySxHmKM44Dp5pcfvXuupbHKt/FHq cn/sA568TuGyOhwoxlPirswoFleF8tWMvbhCifirfa8EKPknr+LaoQfJ3uA6mkBlD4VC 6NU/yGGQRTz8vzrM96MCc5QLLqHJL2D3+zVL7yQQl53mZmlKLtXs4poJzuyioLV0EYts z4YYvp0a51LJ6gqjmItwbK+cBxlDbdOALibYB29mVnXb9XOp23z8vVDXHdN1gX1kVJ2p MTYA== X-Gm-Message-State: APjAAAVVnPO5zlPne4OBnEtUkpQ+XWC9Ymp5HcdASEe06kxzLb8f+ErO V1VSS3ERokdX8icsxbcm0WVhNA== X-Google-Smtp-Source: APXvYqwVIMFIW4nvi9+ceBIvo7VcmokDcZtedcOKuUF+dSfmyvE95o0FhAg+FO45kuF0xhnqh8duGQ== X-Received: by 2002:a1c:6246:: with SMTP id w67mr5084957wmb.141.1580219530690; Tue, 28 Jan 2020 05:52:10 -0800 (PST) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id w7sm2977842wmi.9.2020.01.28.05.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2020 05:52:10 -0800 (PST) Date: Tue, 28 Jan 2020 14:52:08 +0100 From: Tomas Vondra To: Julien Rouhaud Cc: Michael Paquier , Sergei Kornilov , Guillaume Lelarge , PostgreSQL Hackers Subject: Re: Expose lock group leader pid in pg_stat_activity Message-ID: <20200128135208.6tnr72gamv2dr262@development> References: <2519941577437281@vla3-985002032993.qloud-c.yandex.net> <20200116072727.GI3117@paquier.xyz> <20200116074912.GA98418@paquier.xyz> <20200118025102.GB230692@paquier.xyz> <20200128130910.anay3mlhaminob6w@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Jan 28, 2020 at 02:26:34PM +0100, Julien Rouhaud wrote: >On Tue, Jan 28, 2020 at 2:09 PM Tomas Vondra > wrote: >> >> I agree a separate "leader_id" column is easier to work with, as it does >> not require unnesting and so on. >> >> As for the consistency, I agree we probably can't make this perfect, as >> we're fetching and processing the PGPROC records one by one. Fixing that >> would require acquiring a much stronger lock on PGPROC, and perhaps some >> other locks. That's pre-existing behavior, of course, it's just not very >> obvious as we don't have any dependencies between the rows, I think. >> Adding the leader_id will change, that, of course. But I think it's >> still mostly OK, even with the possible inconsistency. > >There were already some dependencies between the rows since parallel >queries were added, as you could see eg. a parallel worker while no >query is currently active. This patch will make those corner cases >more obvious. Yeah, sure. I mean explicit dependencies, e.g. a column referencing values from another row, like leader_id does. >Should I document the possible inconsistencies? I think it's worth mentioning that as a comment in the code, say before the pg_stat_get_activity function. IMO we don't need to document all possible inconsistencies, a generic explanation is enough. Not sure about the user docs. Does it currently say anything about this topic - consistency with stat catalogs? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services