Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZNkiC-0002A8-Aw for pgsql-bugs@arkaria.postgresql.org; Fri, 07 Aug 2015 16:41:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZNkiB-0001ww-TL for pgsql-bugs@arkaria.postgresql.org; Fri, 07 Aug 2015 16:41:39 +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) (envelope-from ) id 1ZNftF-0001nw-7I for pgsql-bugs@postgresql.org; Fri, 07 Aug 2015 11:32:45 +0000 Received: from smarthost01b.mail.zen.net.uk ([212.23.1.3]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZNftB-0007bQ-6p for pgsql-bugs@postgresql.org; Fri, 07 Aug 2015 11:32:44 +0000 Received: from [88.96.211.230] (helo=ash.forest) by smarthost01b.mail.zen.net.uk with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1ZNft6-0009am-Id for pgsql-bugs@postgresql.org; Fri, 07 Aug 2015 11:32:36 +0000 Received: from [10.0.0.39] by ash.forest with esmtpa (Exim 4.84) (envelope-from ) id 1ZNft4-0006qd-Jv for pgsql-bugs@postgresql.org; Fri, 07 Aug 2015 12:32:36 +0100 To: "pgsql-bugs@postgresql.org" From: Mark Simonetti Subject: Hang on NOTIFY Message-ID: <55C49756.70505@opalsoftware.co.uk> Date: Fri, 7 Aug 2015 12:32:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam_score: -1.0 X-Spam_score_int: -9 X-Spam_bar: - X-Spam_report: Spam detection software, running on the system "ash.forest", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The system I am developing makes extensive use of the async NOTIFY/LISTEN system. I am currently experiencing a problem on 2 production servers: Server 1: Virtual Windows Server 2008 R2 (VMWare) PostgreSQL 9.3.5 [...] Content analysis details: (-1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP X-Originating-smarthost01b-IP: [88.96.211.230] X-Pg-Spam-Score: -2.6 (--) 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 The system I am developing makes extensive use of the async NOTIFY/LISTEN system. I am currently experiencing a problem on 2 production servers: Server 1: Virtual Windows Server 2008 R2 (VMWare) PostgreSQL 9.3.5 Server 2: Virtual Windows Server 2008 R2 (VMWare) PostgreSQL 9.4.2 After the system has been running for a period of time, sometimes a few days sometimes a few weeks, any calls to NOTIFY will hang. After in depth investigation it appears to happen when a listening backend has been connected for some time (days). Any other backend trying to inform that backend will hang on "CallNamedPipe" in pgkill (kill.c). Here is a stack trace from the hung SENDING backend, main thread : - ntdll.dll!_NtFsControlFile@40() + 0x15 bytes ntdll.dll!_NtFsControlFile@40() + 0x15 bytes kernel32.dll!_CallNamedPipeW@28() + 0xf4 bytes postgres.exe!pgkill(int pid, int sig) Line 43 + 0x2b bytes C postgres.exe!SendProcSignal(int pid, ProcSignalReason reason, int backendId) Line 198 + 0x10 bytes C postgres.exe!SignalBackends() Line 1497 + 0xe bytes C > postgres.exe!ProcessCompletedNotifies() Line 1092 C postgres.exe!PostgresMain(int argc, char * * argv, const char * dbname, const char * username) Line 3947 C postgres.exe!BackendRun(Port * port) Line 4011 + 0x21 bytes C postgres.exe!SubPostmasterMain(int argc, char * * argv) Line 4515 + 0x8 bytes C postgres.exe!main(int argc, char * * argv) Line 203 + 0x7 bytes C postgres.exe!__tmainCRTStartup() Line 555 + 0x17 bytes C kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes ntdll.dll!___RtlUserThreadStart@8() + 0x27 bytes ntdll.dll!__RtlUserThreadStart@8() + 0x1b bytes Here is a stack trace from the signalling thread (I know its irrelevent as this is for incomming signals) : - ntdll.dll!_NtFsControlFile@40() + 0x15 bytes ntdll.dll!_NtFsControlFile@40() + 0x15 bytes > postgres.exe!pg_signal_thread(void * param) Line 279 + 0x9 bytes C Now for the RECIPIENT backend : - ntdll.dll!_ZwWaitForMultipleObjects@20() + 0x15 bytes ntdll.dll!_ZwWaitForMultipleObjects@20() + 0x15 bytes KERNELBASE.dll!_WaitForMultipleObjectsEx@20() + 0x36 bytes kernel32.dll!_WaitForMultipleObjectsExImplementation@20() + 0x8e bytes > postgres.exe!pgwin32_waitforsinglesocket(unsigned int s, int what, int timeout) Line 216 + 0x14 bytes C postgres.exe!pgwin32_recv(unsigned int s, char * buf, int len, int f) Line 352 + 0xa bytes C postgres.exe!secure_read(Port * port, void * ptr, unsigned int len) Line 304 + 0x12 bytes C postgres.exe!pq_getbyte() Line 895 + 0x67 bytes C postgres.exe!SocketBackend(StringInfoData * inBuf) Line 344 + 0x5 bytes C postgres.exe!PostgresMain(int argc, char * * argv, const char * dbname, const char * username) Line 3968 + 0x1c bytes C postgres.exe!BackendRun(Port * port) Line 4011 + 0x21 bytes C postgres.exe!SubPostmasterMain(int argc, char * * argv) Line 4515 + 0x8 bytes C postgres.exe!main(int argc, char * * argv) Line 203 + 0x7 bytes C postgres.exe!__tmainCRTStartup() Line 555 + 0x17 bytes C kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes ntdll.dll!___RtlUserThreadStart@8() + 0x27 bytes ntdll.dll!__RtlUserThreadStart@8() + 0x1b bytes This is the usual place for it to wait, so this seems okay. ntdll.dll!_NtFsControlFile@40() + 0x15 bytes ntdll.dll!_NtFsControlFile@40() + 0x15 bytes > postgres.exe!pg_signal_thread(void * param) Line 279 + 0x9 bytes C Also looks fine. This seems like a possible Windows bug, as the call to CallNamedPipe has a timeout of 1000 milliseconds, but it is clearly not timing out. It only seems to exit if I exit the backend it is trying to signal. NOTE: it is trying to send to many backends, but on all the stuck backends I checked, they all were stuck sending to the same recipient. Closing that particular recipient DOES free everything up and signals start flowing again. I've searched around and cannot find a similar bug report. Is it possibly something I'm doing wrong? Thanks, Mark. -- -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs