Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pr3dX-00083H-Vg for psycopg@arkaria.postgresql.org; Mon, 24 Apr 2023 21:22:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pr3dW-0002L1-Ii for psycopg@arkaria.postgresql.org; Mon, 24 Apr 2023 21:22:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pr3dV-0002Ks-Jg for psycopg@lists.postgresql.org; Mon, 24 Apr 2023 21:22:14 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pr3dS-001h8M-Bm for psycopg@postgresql.org; Mon, 24 Apr 2023 21:22:12 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 54DAA3200947; Mon, 24 Apr 2023 17:22:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 24 Apr 2023 17:22:08 -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:sender:subject:subject:to:to; s=fm2; t= 1682371327; x=1682457727; bh=x3ghGbq4dx3MarZ6dtlPi1+bKEd8A/+d/Uq 5cfMHnss=; b=DDCmxeyYHD54sCcd5Vpzs61pFWmD7hxFrbZ9iX7rQekJzHh/1GA ARs2zkiMj0o4LraQ7BHSFt7ryd0oB2U+Sbvi4ttGA5SnZIEzGTseH/mXkM5CGbzP 9UhCRdY3kUnHQsT4wg/P+6r1cq/ppG05qJ4CYGPYKNGEELGAaGpASARk14xa+9yx RHNv9hG4PY4lKulR1vLyLEvRSuI0LSje8pKLZx617oZ/6/EXYhI4q+PA+/ZwTX7C LgZ186KVVlAgAKSx5by2ihLk5taJouOQk+UiJ4GHxIQ2PPekYhDQi+iINRm1arI6 j3U8+BVnEnhZdxvUGjU3xNZcSvK9T1vDgBw== 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:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1682371327; x=1682457727; bh=x3ghGbq4dx3MarZ6dtlPi1+bKEd8A/+d/Uq 5cfMHnss=; b=ac+OslTD+sxvwFRH4wiHPdW80TylRr0X1pgrOtyDstoSzGX4taK hQ2Ec+43hGxnSyyS8ixVgDjYLZrTYt0PEOL5ryvCYCzGGcjNjhTA+IJBF7wJjHHK 5FSNkC7l1TgEGKHzlfRXRO8yl7rG4ONiB87n0PQI7t5eGmQbMH7IOj2VjK2lBo+1 KZ7altFYJOrD8OcWORayRrzZeMkVld+175Xn+JEdm1kImV/z8kDAhiXz2CaKiRw1 LQqCYpCT7DTraTgv1uCNxA+hoawTvJqV+clFAfYEgXAyaPFCdNXbfAqaAIl2nv1h qJagMUjhRid8IyMAHcxsxaoDKLul5S8chbw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedutddgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvvehfhfgjtgfgse htkeertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhephfegve ekfeelffdvgfdvfefftdeujeehheeuieffhfefiefhvdfhgfetgfdvuefgnecuffhomhgr ihhnpehpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghr rdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 24 Apr 2023 17:22:07 -0400 (EDT) Message-ID: <2d7af6b8-fb04-6aed-2397-6557b09a64db@aklaver.com> Date: Mon, 24 Apr 2023 14:22:06 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: Consecutive Inserts Freeze Execution of Psycopg3 To: "Michael P. McDonnell" Cc: psycopg@postgresql.org References: <237c1e3f-4118-6ffc-6e0b-ddce824f1f55@aklaver.com> <04fea413-8776-dd4e-7f0e-4b235b454f19@aklaver.com> <021e900b-53d0-c5a0-2750-a0fe60230e68@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 4/24/23 14:16, Michael P. McDonnell wrote: > Hey Adrian - > Just wanted to say thank you again for helping me with getting the > session stuff structured appropriately. I actually found my issue and it > turns out that while my code is suboptimal in a lot of ways - it was > actually a separate database issue as a whole that I'm just now tracking > down. > Just thought you'd like to know that it was not a psycopg(3 or 2) issue, > not a sqlalchemy issue, and it has something to do with how the queries > seem to work. > > And the technical info (not an ask, just an inform) > The queries are just an ETL from one table to another based on how the > data needs to be accessed. If I trunc all the tables, and load the > originating table - the first ETL works fine (table1 -> table2). > However - when I then call the 2nd ETL from table2 to table3 - the query > "freezes". I'm still looking into what that means and how to find what's > going on. Look at: https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW and https://www.postgresql.org/docs/current/view-pg-locks.html > If I cancel the execution of that query and re-run the 2nd ETL (table2 > to table3) - it runs in the amount of time I expected (2-3 seconds). > > So this fundamentally was never about a session, or commits, or anything > else; those were working as expected - the query itself was just hung up > in the server doing its "thing". > > Anywho - hopefully someone is googling and this pops up and helps them > look at the problem differently. Have a great day. > -Mike > -- Adrian Klaver adrian.klaver@aklaver.com