Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WcbAB-0003Do-Lh for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Apr 2014 13:55:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WcbAA-0006x9-Uq for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Apr 2014 13:55:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WcbA9-0006x0-Fw for pgsql-hackers@postgresql.org; Tue, 22 Apr 2014 13:55:05 +0000 Received: from moutng.kundenserver.de ([212.227.17.10]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WcbA6-00014o-C1 for pgsql-hackers@postgresql.org; Tue, 22 Apr 2014 13:55:05 +0000 Received: from [10.1.3.40] (fw.node5.cz [89.22.65.200]) by mrelayeu.kundenserver.de (node=mreue104) with ESMTP (Nemesis) id 0MLyNI-1WZHlx3XmG-007oLq; Tue, 22 Apr 2014 15:55:01 +0200 Message-ID: <535674B4.2040706@2ndquadrant.com> Date: Tue, 22 Apr 2014 15:55:00 +0200 From: Petr Jelinek User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: PostgreSQL-development Subject: shm_mq inconsistent behavior of SHM_MQ_DETACHED Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:Qmn0srAEkZtJm0We93P6QzycZi2C3Nl3asL2T6ZtVFi thmTf7Ph0ADbwlKGiokvxCpkgpfdJPhBKFdez970Yb20KQxLgC tDJwyJeejSjRQjpOMKXCBpKKJcHHIto9F0oZ2AKluMvrqFarf4 AIxWN7JqTMVTxpOEsz3rwIjyhEIyKfWANn5swZKYhXc/TIPvyI fTrybQ5orHRdH2lf2834tXvwwa0euqdb7s3HVdT/B2zYQGWbYm r4HIjDRSG6BMyO5Qlz25gHUpI9lrAA68hZ77L93Oh2eDkvCnHi /zkhKHbN2CxUpcSvuSQUl8Np9JxK3AZ3bByWfzgEoeZgYNp6pD brQx/EWVxpCw6DyamDI0= X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Hi, I was playing with shm_mq and found a little odd behavior with detaching after sending messages. Following sequence behaves as expected (receiver gets 2 messages): P1 -> set_sender P1 -> attach P2 -> set_receiver P2 -> attach P1 -> send P2 -> receive P1 -> send P1 -> detach P2 -> receive P2 -> detach But if I do first receive after detach like in this sequence: P1 -> set_sender P1 -> attach P2 -> set_receiver P2 -> attach P1 -> send P1 -> send P1 -> detach P2 -> receive I get SHM_MQ_DETACHED on the receiver even though there are messages in the ring buffer. The reason for this behavior is that mqh_counterparty_attached is only set by shm_mq_receive. This does not seem to be consistent - I would either expect to get SHM_MQ_DETACHED always when other party has detached or always get all remaining messages that are in queue (and I would strongly prefer the latter). Maybe the shm_mq_get_bytes_written should be used to determine if there is something left for us to read in the receiver if we hit the !mqh_counterparty_attached code path with detached sender? -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers