Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WOB9w-0005lO-Sw for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Mar 2014 19:19:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WOB9w-0002Ua-Bt for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Mar 2014 19:19:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WOB9v-0002Th-GG for pgsql-bugs@postgresql.org; Thu, 13 Mar 2014 19:19:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WOB9t-0007qh-7h for pgsql-bugs@postgresql.org; Thu, 13 Mar 2014 19:19:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s2DJJBXs007088; Thu, 13 Mar 2014 15:19:11 -0400 From: Tom Lane To: jmorton@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #9551: Hang in State "authentication" Prevents Vacuum from Freeing Dead Rows In-reply-to: <20140312232810.634.7997@wrigleys.postgresql.org> References: <20140312232810.634.7997@wrigleys.postgresql.org> Comments: In-reply-to jmorton@gmail.com message dated "Wed, 12 Mar 2014 23:28:10 -0000" Date: Thu, 13 Mar 2014 15:19:11 -0400 Message-ID: <7087.1394738351@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org jmorton@gmail.com writes: > (gdb) bt > #0 0x00000030820e104e in __lll_lock_wait_private () from /lib64/libc.so.6 > #1 0x00000030820d1bf7 in _L_lock_646 () from /lib64/libc.so.6 > #2 0x00000030820d168a in __vsyslog_chk () from /lib64/libc.so.6 > #3 0x00000030820d1a73 in __syslog_chk () from /lib64/libc.so.6 > #4 0x00000000006dd6f1 in EmitErrorReport () > #5 0x00000000006ddaf5 in errfinish () > #6 0x0000000000623f6a in ProcessInterrupts () > #7 0x000000000062439c in StatementCancelHandler () > #8 > #9 0x00000030820306f7 in kill () from /lib64/libc.so.6 > #10 0x0000000000616d01 in ?? () > #11 0x0000000000616e3f in handle_sig_alarm () > #12 > #13 0x00000030820d5eb5 in send () from /lib64/libc.so.6 > #14 0x00000030820d1750 in __vsyslog_chk () from /lib64/libc.so.6 > #15 0x00000030820d1a73 in __syslog_chk () from /lib64/libc.so.6 > #16 0x00000000006dd6f1 in EmitErrorReport () > #17 0x00000000006ddaf5 in errfinish () > #18 0x0000000000583c57 in ?? () > #19 0x0000000000583c81 in ?? () > #20 0x00000000005858af in ClientAuthentication () > #21 0x00000000006e9bb6 in InitPostgres () > #22 0x000000000062609d in PostgresMain () > #23 0x00000000005e9dfc in ?? () > #24 0x00000000005eab81 in PostmasterMain () > #25 0x000000000058e38e in main () Interesting stack trace. Evidently, syslog() on your platform has some internal mutex. What seems to have happened is that SIGALRM interrupted an attempt to log a client-authentication-related message, and then the error message that it attempted to print resulted in recursive entry to syslog(), causing a hang since the outer invocation already had the mutex. This pathway would be impossible if the error level were ERROR, because errfinish() clears ImmediateInterruptOK in that case, which would prevent the SIGALRM interrupt handler from doing anything much. A likely bet though is that the error level in the outer call was FATAL (ie, authentication failure); or it might've been just a LOG message. I'm thinking the most robust solution to this is to have errfinish() do this at entry: bool save_ImmediateInterruptOK = ImmediateInterruptOK; ImmediateInterruptOK = false; and then, *if* it decides to return to caller, do this just before returning: ImmediateInterruptOK = save_ImmediateInterruptOK; if (save_ImmediateInterruptOK) CHECK_FOR_INTERRUPTS(); This should make the error reporting logic safe against interrupts even if invoked while ImmediateInterruptOK is true; which probably shouldn't happen during normal backend operation but is definitely possible during client authentication. BTW, are you using an unusually short value for authentication_timeout? This case doesn't seem likely to arise with normal values, since the timeout isn't expected to occur unless something's totally wedged. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs