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 1sr2IG-00F2T6-Qw for pgsql-general@arkaria.postgresql.org; Wed, 18 Sep 2024 21:33:01 +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 1sr2IF-00GAnT-JC for pgsql-general@arkaria.postgresql.org; Wed, 18 Sep 2024 21:32:59 +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 1sr2IE-00GAnK-13 for pgsql-general@lists.postgresql.org; Wed, 18 Sep 2024 21:32:59 +0000 Received: from fhigh6-smtp.messagingengine.com ([103.168.172.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sr2IA-001t4l-87 for pgsql-general@lists.postgresql.org; Wed, 18 Sep 2024 21:32:57 +0000 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 583CA1140171; Wed, 18 Sep 2024 17:32:51 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Wed, 18 Sep 2024 17:32:51 -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=fm3; t=1726695171; x=1726781571; bh=aoKB4xX59j3Jfp+yVx9LUcoJF97u1q3PN4wpieriSs4=; b= YdiMLTs2lc/m4hf/dS/sPBDY0wrDdncy5FQBFXEpgNAaANgwRPsEijPL55UqYfgq oCqiwz4bNHjIRiBKxuuqFQh94uCCFpwK6FFr7V5D5v+jplx/lj0VlxleskdLaAEQ YSjgWjp5el+2Ot7tHrloU82Bnh9uU2dEitD1xTIb0VkNdfYBMroQujPHylxdVi0W zpL0cOgl6BhmeyxPkz5Fuz+SxO6Ph4lcvRvLFsCXz+kFi2nfPeFGw2AK7zoPIGHT 783G5cUVeqjMYqvTRY0upZEvF0GDYfmRqwqfQB0/0ZS3dwpkmhGEvY6dRkHlLrx6 vYrwJPLkU1lxd3SRNRtc+g== 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=fm1; t=1726695171; x= 1726781571; bh=aoKB4xX59j3Jfp+yVx9LUcoJF97u1q3PN4wpieriSs4=; b=r GQLU8LBklsWOWVRzE5BI0f28PYPpZUP9oQ0W6GNl7rLaO78ZymA3L0gLMSoB1WaK Brg/kgJkQ941d+YFFYHCuQb8UEHI112a5lmAydKiQ9Zx/TDCH3zVrN6oP6bXaYAJ lfddo+YkuKFPMovL7x1hHNHII8oSKsPbin0P5Uqou8G7LKoCIqi1F7s2qVHUDOiZ e9hgoa+h1IjF0joJJBjVag15HcI7rzg/l3e2d1nxwgusMxjVbK+vOKafg0+Zx3o6 7m9KoE/rvoN7TDllgJE/lCY2MpEM5mp+SsmEi6+esvJF5nMN+5Hdda2ZcMofR1xc Vc1aEwQdU8ibLf8JcfHPQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeltdcutefuodetggdotefrodftvfcurf hrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffrtefo kffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsuc dlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfh rhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkh hlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeefgeefieeutdfggfetgefgheek jeehteeileeigfetieekjedvieeviefgheevtdenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghv vghrrdgtohhmpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtph htthhopehvvggvmhgrtddttddtsehgmhgrihhlrdgtohhmpdhrtghpthhtohephhhtrghm fhhiughssehgmhgrihhlrdgtohhmpdhrtghpthhtohepgihofhesthhhvggsuhhilhgurd gtohhmpdhrtghpthhtohepphhgshhqlhdqghgvnhgvrhgrlheslhhishhtshdrphhoshht ghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 18 Sep 2024 17:32:49 -0400 (EDT) Message-ID: <586d988d-978b-4b08-84b4-ef3ebb8736a8@aklaver.com> Date: Wed, 18 Sep 2024 14:32:48 -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> 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/18/24 1:40 PM, veem v wrote: > > You were spot on. When we turned off the "auto commit" we started > seeing less number of commits as per the number of batches. > > However we also started seeing deadlock issues. We have foreign key > relationships between the tables and during the batch we do insert > into the parent first and then to the child , but this does happen > from multiple sessions for different batches. So why do we see below > error, as we ensure in each batch we first insert into parent and > then into the child tables? > > caused by: org.postgresql.util.PSQLException: ERROR: deadlock detected >   Detail: Process 10443 waits for ShareLock on transaction > 220972157; blocked by process 10454. > Process 10454 waits for ShareLock on transaction 220972155; blocked > by process 10443. >   Hint: See server log for query details. >   Where: while inserting index tuple (88736,28) in relation > "TAB1_p2024_08_29" > > > As we are able to get hold of one session, we see "insert into partition table>" was blocked by "insert into ". > And the "insert into " was experiencing a > "client read" wait event. Still unable to understand why it's happening > and how to fix it? This needs clarification. 1) To be clear when you refer to parent and child that is: FK parent_tbl.fld <--> child_tbl.fld_fk not parent and child tables in partitioning scheme? 2) What are the table schemas? 3) What is the code that is generating the error? Overall it looks like this process needs a top to bottom audit to map out what is actually being done versus what needs to be done. -- Adrian Klaver adrian.klaver@aklaver.com