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 1srkur-004FZE-C9 for pgsql-general@arkaria.postgresql.org; Fri, 20 Sep 2024 21:11:50 +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 1srkup-00CfAz-6T for pgsql-general@arkaria.postgresql.org; Fri, 20 Sep 2024 21:11:48 +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 1srkun-00CfA3-FT for pgsql-general@lists.postgresql.org; Fri, 20 Sep 2024 21:11:48 +0000 Received: from fout6-smtp.messagingengine.com ([103.168.172.149]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1srkul-000Ec2-KO for pgsql-general@lists.postgresql.org; Fri, 20 Sep 2024 21:11:45 +0000 Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id 0F77D138008E; Fri, 20 Sep 2024 17:11:42 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Fri, 20 Sep 2024 17:11:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1726866702; x=1726953102; bh=0QOSuLl8WmQEizit/Kvog3NaF1bZB8Qq4+vXtnryU1o=; b= DcblYA7Vz8ntmSBQRjqEMSzvXyvNoNrUuK9XvipVSCoFxHUJkzPvGgu26RUSqxh1 t8VzUcrHqJtBiAZ15AjVQzA39Z1cKX7j4RrApoD16eZjmQyKGR+cLpceZC3jGVf0 46qy+hDmUiDw0wqLB8k4/HcCvLM1bk/ZTuQ6EvjcLuNGQ+72N1J/gLSIzOGb2wDp Qhc74JB+cOzA/KE+UdbvzveBKENEBJGAg0+4J5Czz3Xclhzgil8gceD56OQeS2o3 MqAzZHmX7Fa/TvCoQAINIpGdY1ULGddQAR4fpNHYO5i/FH3kEWWAy7NRCoSuZ3oD 4EAnkGj3dqWfJea/M1mp4Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1726866702; x= 1726953102; bh=0QOSuLl8WmQEizit/Kvog3NaF1bZB8Qq4+vXtnryU1o=; b=X d0M9Pn7MrJsXXs52fck3gofDO+hycF1x1HnWoy7ruuFxGcmDzIabNNKEhpdP+yxj sOVPDqDsTAvrTVptC3qHjFIo3YmlXFu7rQYcmStQkCwBKTgztb/SCVl+O5rlbHlX FMZV02tIIqB1HMGJnXOIGh1frfSfObuQGMryXEdlFVWWOYoNNBqwFqvl9qk+mt+Q nf7PxxWY/UlqbaYiBdbd+cIkV+f08rNymmBah9kqVFGdPeyt/QLoPXUs884bFHK6 DZAyUjJMT+94MaQEuKX/WcoXeEIa4rVlR5qzMmfPrh6H7xkAX+c2s6q0W4Co/STx TTnhkjURsYJUCunGT+o7g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudelfedgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddv jeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvg hrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpefgudefkefhveefleev ieeuveehvdduudekuddvvdelhfeuueeijedtuedvvedvueenucffohhmrghinhepphhosh htghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnh gspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepvhgvvghm rgdttddttdesghhmrghilhdrtghomhdprhgtphhtthhopehhthgrmhhfihgushesghhmrg hilhdrtghomhdprhgtphhtthhopeigohhfsehthhgvsghuihhlugdrtghomhdprhgtphht thhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdroh hrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 20 Sep 2024 17:11:39 -0400 (EDT) Message-ID: <4cfe720e-4283-43fc-8d72-8fa11e2f741a@aklaver.com> Date: Fri, 20 Sep 2024 14:11:38 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: IO related waits To: veem v Cc: Greg Sabino Mullane , Christophe Pettus , pgsql-general References: <3dddea5e-52ab-4075-970d-a87b0c921ae7@aklaver.com> <225d1bc1-5117-4c72-85a1-bac6355fb659@aklaver.com> <586d988d-978b-4b08-84b4-ef3ebb8736a8@aklaver.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/20/24 1:01 PM, veem v wrote: > > On Thu, 19 Sept, 2024, 8:40 pm Adrian Klaver, > wrote: > > On 9/19/24 05:24, Greg Sabino Mullane wrote: > > On Thu, Sep 19, 2024 at 5:17 AM veem v > > > This is really difficult to diagnose from afar with only snippets of > > logs and half-complete descriptions of your business logic. Pull > > everyone involved into a room with a whiteboard, and produce a > document > > describing exactly what your application does, and how it is > doing it. > > Switch from reactive to proactive. > > > Able to reproduce this deadlock graph as below.  Now my question is , > this is a legitimate scenario in which the same ID can get inserted from > multiple sessions and in such cases it's expected to skip that (thus "On > conflict Do nothing" is used) row. But as we see it's breaking the code Yeah, as I see it that would not work with concurrent uncommitted sessions as it would be unresolved whether a conflict actually exists until at least one of the sessions completes. > with deadlock error during race conditions where a lot of parallel > threads are operating. So how should we handle this scenario? Will > setting the "lock_timeout" parameter at session level will help us > anyway here? Serializable transaction?: https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE Or change the application code to not have this: "... legitimate scenario in which the same ID can get inserted from multiple sessions ..." -- Adrian Klaver adrian.klaver@aklaver.com