Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1epH1Q-0005hU-5k for pgsql-general@arkaria.postgresql.org; Fri, 23 Feb 2018 17:20:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1epH1O-00039p-CS for pgsql-general@arkaria.postgresql.org; Fri, 23 Feb 2018 17:20:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1epH1N-00039f-Uu for pgsql-general@lists.postgresql.org; Fri, 23 Feb 2018 17:20:34 +0000 Received: from [66.111.4.26] (helo=out2-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1epH1G-0006qI-QL for pgsql-general@postgresql.org; Fri, 23 Feb 2018 17:20:33 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id C45EE20E52; Fri, 23 Feb 2018 12:20:04 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Fri, 23 Feb 2018 12:20:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=aRPptmYRHj7l6WknBB3a132QXyCBU yTlNuZMbJziJ2E=; b=U2WbacclmngLmlDji5rc+sf8rv8lYccIPig94ffCJJi+T 5beSJ4LZczBmA8irrEMC8dwxr4nmPkdAjbAgqOGYMocTT+NajugQ5BzkQQ0HvQm1 mY5a0tUYtfXYy3LBYOz67XHfYPBdhbAK5tx6ZRM0CcP1I9HcIzfZ4jcdVVLBL3YW w5wgCGP6FahKzOOerEwSQVWQVLQEKPIHV7XaWZUsWBH/BiE0NERK4pUHaiRuFcxj EGLcOc5ytArl/wnDde6tIBxz0lGTQWL9qpmwocGH/i2tTtYgwBWKn2yrs0VQGmkj j1mTdChlSREFNx1KSgn0CMGXUw6CuPsvGXJ/0mgbg== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.189]) by mail.messagingengine.com (Postfix) with ESMTPA id 8D7EA7E188; Fri, 23 Feb 2018 12:20:04 -0500 (EST) Date: Fri, 23 Feb 2018 09:20:02 -0800 From: Andres Freund To: Andre Oliveira Freitas Cc: pgsql-general@postgresql.org Subject: Re: PQConsumeinput stuck on recv Message-ID: <20180223172002.p22upnnwz2imsiwo@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.26 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2018-02-23 13:33:18 -0300, Andre Oliveira Freitas wrote: > Since it's been happening for a few weeks now, every time it freezes we > take a gcore dump and check it in gdb... and after a lot of hair pulling > and learning about the innards of the VoIP software we see that most often > the software is stuck in this call trace: > > #0 in __libc_recv (fd=409, buf=0x7f2c4802e6c0, n=16384, flags=1898970523) > at ../sysdeps/unix/sysv/linux/x86_64/recv.c:33 > #1 in ?? () from /usr/lib/x86_64-linux-gnu/libpq.so.5 > #2 in ?? () from /usr/lib/x86_64-linux-gnu/libpq.so.5 > #3 in PQconsumeInput () from /usr/lib/x86_64-linux-gnu/libpq.so.5 So it's just receiving data from the network. Have you verified whether the connection is actually stable? Any chance it's just waiting for the network to time out. Might be worth configuring tcp timeouts, to make sure its unrelated to that. What is the server showing as activity while the client is waiting? Could you show the corresponding pg_stat_activity row? > The software shares a database connection between threads, and controls its > access through a mutex, so once one thread that acquires the mutex gets > stuck in the location above, all other threads starts pilling up behind the > mutex, and that's apparently the reason the software stops responding for > most of its functions (while other functions that do not depend on the > database works normally). Hm, have you compiled libpq with threading support? Or use a distribution that compiles it with that? While I don't see an obvious connection to that stacktrace it seems worthwhile to verify. A mutex protecting individual connection, while also necessary if connections are shared, doesn't achieve the same. > I wonder if anyone has any tip on what to look for next... Any chance you're occasionally forking and then interacting with the connection in the forked process? Greetings, Andres Freund