Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uFYhk-005pO8-0T for pgsql-performance@arkaria.postgresql.org; Thu, 15 May 2025 13:32:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uFYhj-00EhDz-3p for pgsql-performance@arkaria.postgresql.org; Thu, 15 May 2025 13:32:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uFYhi-00EhDr-Ox for pgsql-performance@lists.postgresql.org; Thu, 15 May 2025 13:32:54 +0000 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uFYhf-0022DK-2c for pgsql-performance@lists.postgresql.org; Thu, 15 May 2025 13:32:54 +0000 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-70825de932bso23034637b3.0 for ; Thu, 15 May 2025 06:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747315970; x=1747920770; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=oOKbsF78KEI01q6ThhO3UA8+JU4MBOjWzfYh/r/aJLo=; b=GCoUXZ6M7O1Fl2IUtGUbei6SwCZatI5AKE0gsXBOFQiSFR2ffKY+EYaa2qXb/Hu89+ vEUfny0ia0xDePmMn4PKXtKlFTbM/e3TCOTWi0BalTSAt/bcV0fWgayHzP+5sGS3wMsj CuuDrcgFDTe9iN6FDauJlelmPMicV5eOMvwx2yJ02EnyStpt04f2vh6vX21yiWfPSo6K SmuD5wXz9R/JM/V5FpibVQ+W0/DtLvbNmM9YOAMoCS1m0eFo2Ke4/WuWzBsVLoJ1rnUN yFrdoz3V2+IU+HbRRnL36YthTEmTajuVs5PWnKjRChzpXD33f3D0YH6avMqE+i7BFanb rjUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747315970; x=1747920770; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oOKbsF78KEI01q6ThhO3UA8+JU4MBOjWzfYh/r/aJLo=; b=e/dT5sPzIsmDRXzLdn8OiyoQQSDjCVZh/PFni+T9nVYCsGB52GnxsSjD6iSPWaYtQI qoLgVi94qe79qVN6t7ygu6HpvwCVnhI1qTve1jORMt5y57b0YxIfhxEEVW/p0kbYqD7Q xAc6GKyrPYMufrXUScYIAWdFr6oTThzHHVdfGHJfT5rB5Xrsnuyr3PIhaqq7UrbwglTU 3PSEiN7GslTuQEzUYgwy4UICjWfFoUmlVa2OzgRWbNFHiUASkZpY+VtM1AcsupYsBgBd wj2LZ/9OrpPujUlXhnbWxamuoy+hCV8jUJjOOOqwy0V9ZfHa8OK23TYDRksCy4ttozSX 5otw== X-Forwarded-Encrypted: i=1; AJvYcCVq7yt23TQHWpRKw2wvZXfaoaIzAzDPYv1r4TxUOU7vYeum2+NOSJfn095jISqqOTx1X3KNIS3z6PhB5mlAwJOSMA==@lists.postgresql.org X-Gm-Message-State: AOJu0YyVd3KUdSjyEWTLnXGS1mUXpIUhtVUKjvM2SPulz33S+QcLgfA+ jWqdrGBILBYT5U/DULnKvSaPyc0HuycD853fXjcgSd/CuHm0odCMWktHFcAbjg5H1pici/aljYP sJZ3ODJWQlxSbXCq968LR0v6tWjoYZ/BEM9yK X-Gm-Gg: ASbGnctRCmshxjAPvPRD0BenShFc5c+gLXpnYeQTWFG81XGRQc3U1XmiVBgExvWz4OD NG4t5dYMhNE6/nG/ZWo/H84Mn1QQNyqRPlpznbD8KKbDkTpII70sL7agI3tu0QPtDmOTZFF5WS4 tTeVVDfu9Zlp4W05pxf5dnF9QI4yIdXnIeZzsdqD2YJTRs X-Google-Smtp-Source: AGHT+IGbh1rkGxiFh+WxenJsodrlrL1qX+8th1+JGt1n7w+xn4w9pkmjk37p7hJotOvrh7pQA2Mmj2Fj/1ZbTiRWu1Y= X-Received: by 2002:a05:690c:dd3:b0:6f9:b027:1bfc with SMTP id 00721157ae682-70c8fcf7e15mr49340217b3.3.1747315969881; Thu, 15 May 2025 06:32:49 -0700 (PDT) MIME-Version: 1.0 References: <54994813530a36c0280fd8779e65ad1ad73d910a.camel@cybertec.at> <11465.1747315470@sss.pgh.pa.us> In-Reply-To: <11465.1747315470@sss.pgh.pa.us> From: James Pang Date: Thu, 15 May 2025 21:32:38 +0800 X-Gm-Features: AX0GCFthCqVwGi7ghoMFYLlUttuwZ3bLJDRyWK4IK5AqfAqCHPoTjmA52iU80-8 Message-ID: Subject: Re: a lot of session wait on lock relation To: Tom Lane Cc: Laurenz Albe , pgsql-performance@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000b2012b06352cb349" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b2012b06352cb349 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable thanks, we are checking partition maintain jobs ,that hold access exclusive lock. Tom Lane =E6=96=BC 2025=E5=B9=B45=E6=9C=8815=E6=97=A5= =E9=80=B1=E5=9B=9B =E4=B8=8B=E5=8D=889:24=E5=AF=AB=E9=81=93=EF=BC=9A > Laurenz Albe writes: > > On Thu, 2025-05-15 at 16:27 +0800, James Pang wrote: > >> why inserts into partition table cause "relation lock" ? > > > Something else does; use the pg_blocking_pids() function with the > process ID of > > a blocked backend to find out who is holding the lock. > > More specifically: the inserts are only trying to get a shared lock. > If they are blocked, it's because some other operation is already > holding an exclusive lock on the table and is not letting go. > Look for uncommitted DDL changes. > > More details about that at [1]. > > regards, tom lane > > [1] > https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TAB= LES > > > --000000000000b2012b06352cb349 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
thanks, we are checking=C2=A0 partition=C2=A0 =C2=A0mainta= in jobs ,that hold access exclusive lock.

Tom Lane <= ;tgl@sss.pgh.pa.us> =E6=96=BC 2= 025=E5=B9=B45=E6=9C=8815=E6=97=A5=E9=80=B1=E5=9B=9B =E4=B8=8B=E5=8D=889:24= =E5=AF=AB=E9=81=93=EF=BC=9A
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Thu, 2025-05-15 at 16:27 +0800, James Pang wrote:
>> why inserts into partition table cause "relation lock" ?=

> Something else does; use the pg_blocking_pids() function with the proc= ess ID of
> a blocked backend to find out who is holding the lock.

More specifically: the inserts are only trying to get a shared lock.
If they are blocked, it's because some other operation is already
holding an exclusive lock on the table and is not letting go.
Look for uncommitted DDL changes.

More details about that at [1].

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane

[1] https://www.postgres= ql.org/docs/current/explicit-locking.html#LOCKING-TABLES


--000000000000b2012b06352cb349--