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 1pP3bB-0008HZ-CC for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Feb 2023 15:40:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pP3bA-000323-5u for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Feb 2023 15:40:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pP3b9-00031u-Tu for pgsql-bugs@lists.postgresql.org; Mon, 06 Feb 2023 15:40:03 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pP3b7-0002X5-TB for pgsql-bugs@lists.postgresql.org; Mon, 06 Feb 2023 15:40:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 316Fdxb72665711; Mon, 6 Feb 2023 10:39:59 -0500 From: Tom Lane To: fran.tm213@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17776: Connections are terminated unexpectedly sometimes In-reply-to: <17776-36d858c9afa20043@postgresql.org> References: <17776-36d858c9afa20043@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 06 Feb 2023 11:17:13 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2665709.1675697999.1@sss.pgh.pa.us> Date: Mon, 06 Feb 2023 10:39:59 -0500 Message-ID: <2665710.1675697999@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > I am running Ruby on Rails app with postgresql 14.6 on ubuntu 20. > For some reason, the connections are terminated unexpectedly while running a > background job. > Regarding background job, it requires around 100~200 connections over > 6~7hrs. > I've checked postgresql log around that time. > 2023-02-06 06:45:41.702 UTC [341438] user@db_production LOG: could not > receive data from client: Connection reset by peer > 2023-02-06 08:26:56.134 UTC [352190] user@db_production LOG: could not > receive data from client: Connection reset by peer > 2023-02-06 08:26:56.134 UTC [352191] user@db_production LOG: could not > receive data from client: Connection reset by peer Looks like something in your network infrastructure is timing out and dropping idle connections too quickly. If you can't fix the actual problem, Postgres' TCP-timeout settings might provide a workaround by maintaining an illusion that the connection is busy. See tcp_keepalives_count tcp_keepalives_idle tcp_keepalives_interval tcp_user_timeout regards, tom lane