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 1qnNtz-00AmgM-J5 for pgsql-general@arkaria.postgresql.org; Mon, 02 Oct 2023 18:44:19 +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 1qnNtx-00GlOC-98 for pgsql-general@arkaria.postgresql.org; Mon, 02 Oct 2023 18:44:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qnJWb-00FStn-Uc for pgsql-general@lists.postgresql.org; Mon, 02 Oct 2023 14:03:53 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qnJWZ-007nPB-HE for pgsql-general@lists.postgresql.org; Mon, 02 Oct 2023 14:03:52 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9ae75ece209so2167666066b.3 for ; Mon, 02 Oct 2023 07:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1696255310; x=1696860110; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=S67pKaVMefIR6beMrr8pwIVmfUpNyiDxn5/fHdpMcFg=; b=qQbWg7cJIK03ngEnWSqxT9Qkzg/JbdYrRVKHqEETXYemnt63mZXMxrMWklv2MXTtfy llWx2DXTcSCxqmpQkVFlUSGVSGKf+ekvLiI5dLMRuiH1svWJiTiEFSq8WA9M6yLa1x3Z yqr8NZMNZ1zRSoQlXozfSDEGmbqWXdrB7G9DIy2mCLoztLjDEIY9ffeyi6sN7cBGiY9a JN/iGM6jIIvH52L5VS1BZBFsh5q2puLQG4RIm7Y6DzxkictGLSK8xZCbtstah4hyPUNS k6EdXsEL7VAdavAYMBWl2Votsug350k4ZnTmIxRfduLWPuuwWybcnyu17Es34ET9TFI9 lFNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696255310; x=1696860110; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=S67pKaVMefIR6beMrr8pwIVmfUpNyiDxn5/fHdpMcFg=; b=d4fWH8wM1BjtGlYIdc4M7Zh+j0aIDD8yjLZmQCutx/SCWM6x+gG4RRJS43jqMnQUk8 afE75Jq4ItpeCKFtcG85F+OVcPdtji6kxgIGaeOh13FXYAspv2lcybD8fy38MJW6Jkrg XZgOjPM2tY4zDSk3n3JW9LMpVAGbkphQ2aqCMqb+y7LQp7jHb3o+dInl0+pUC3vEydSR FIF8S2e0bANKJdBhxarIX0LMTZgM9yWYxZ6qae77p4nOd2BzL1+nYb6VM6Y8cV0iP/yC roLlxvQhCLM3W99xIiV1QYnrpNvAsLnCx/2ia95WajTIDPd6vkdlVgcySBg+X4SMIg7a h6lA== X-Gm-Message-State: AOJu0YzM4C9dHuM9d4s0Gu/d3lk6bmCD5Z1Ss4AhLO4RBJbHAEZxsD5p 8bAH9DQcEzDXA/2Re4qhyPu90OfbfxH4SE46rWc= X-Google-Smtp-Source: AGHT+IHdiJ5/lW097kw9Us092StXd1va2xd3C1KUmY/A0vo2Kpxna9OHdLNCuI6TNUEjCfcBwJ3FjA== X-Received: by 2002:a17:906:5393:b0:9a1:f73b:90ce with SMTP id g19-20020a170906539300b009a1f73b90cemr10656131ejo.54.1696255309251; Mon, 02 Oct 2023 07:01:49 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:6cf4:1982:ecd7:8449:ce90]) by smtp.gmail.com with ESMTPSA id lt2-20020a170906fa8200b00992e265495csm17112421ejb.212.2023.10.02.07.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 07:01:48 -0700 (PDT) Message-ID: Subject: Re: How to investigate deadlocks From: Laurenz Albe To: Matthias Apitz , pgsql-general@lists.postgresql.org Date: Mon, 02 Oct 2023 16:01:48 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2023-10-02 at 13:27 +0200, Matthias Apitz wrote: > One of our clients running our LMS on top of PostgreSQL 13.1 created a > ticket with these messages: >=20 > 2023-09-30 16:50:50.951 CEST [18117] ERROR:=C2=A0 deadlock detected > 2023-09-30 16:50:50.951 CEST [18117] DETAIL:=C2=A0 Process 18117 waits fo= r ShareLock on transaction 150396154; blocked by process 18187. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0Process 18187 waits for S= hareLock on transaction 150396155; blocked by process 18117. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0Process 18117: fetch hc_d= 03geb > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0Process 18187: fetch hc_d= 02ben > 2023-09-30 16:50:50.951 CEST [18117] HINT:=C2=A0 See server log for query= details. > 2023-09-30 16:50:50.951 CEST [18117] CONTEXT:=C2=A0 while locking tuple (= 38,57) in relation "d03geb" > 2023-09-30 16:50:50.951 CEST [18117] STATEMENT:=C2=A0 fetch hc_d03geb >=20 > The shown PIDs for sure are the ones of the Pos backend proc (on Linux). > Is there any chance to investigate it further? See the line: HINT: See server log for query details. Other than that, it is difficult to figure out the exact cause of a deadloc= k. You need to know all the statements that were run in these transactions, which probably requires deeper knowledge of the application. Yours, Laurenz Albe