Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hrWNU-0003qI-Gc for pgsql-hackers@arkaria.postgresql.org; Sat, 27 Jul 2019 23:45:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hrWNT-0007gQ-4D for pgsql-hackers@arkaria.postgresql.org; Sat, 27 Jul 2019 23:45:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hrWNS-0007gJ-PP for pgsql-hackers@lists.postgresql.org; Sat, 27 Jul 2019 23:45:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hrWNM-0000gc-9H for pgsql-hackers@lists.postgresql.org; Sat, 27 Jul 2019 23:45:25 +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 x6RNjFkj013590; Sat, 27 Jul 2019 19:45:15 -0400 From: Tom Lane To: Andres Freund cc: pgsql-hackers@lists.postgresql.org Subject: Re: Testing LISTEN/NOTIFY more effectively In-reply-to: <10166.1564270037@sss.pgh.pa.us> References: <31304.1564246011@sss.pgh.pa.us> <20190727174202.jiwr4jgp3x7gvp22@alap3.anarazel.de> <5720.1564249986@sss.pgh.pa.us> <29162.1564266052@sss.pgh.pa.us> <20190727231826.g34yqkzj53ey46tl@alap3.anarazel.de> <10166.1564270037@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 27 Jul 2019 19:27:17 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <13330.1564271066.0@sss.pgh.pa.us> Date: Sat, 27 Jul 2019 19:45:15 -0400 Message-ID: <13589.1564271115@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13330.1564271066.1@sss.pgh.pa.us> I wrote: > Andres Freund writes: >> Hm. I wonder if all that's happening with prairedog is that the notice >> is sent a bit later. I think that could e.g. conceivably happen because >> it TCP_NODELAY isn't supported on prariedog? Or just because the machine >> is very slow? > The notices (not notifies) are coming out in the opposite order from > expected. I haven't really thought hard about what's causing that; > it seems odd, because isolationtester isn't supposed to give up waiting > for a session until it's visibly blocked according to pg_locks. Maybe > it needs to recheck for incoming data once more after seeing that? Ah-hah, that seems to be the answer. With the attached patch I'm getting reliable-seeming passes on prairiedog. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="fix-notice-before-waiting.patch"; charset="us-ascii" Content-ID: <13330.1564271066.2@sss.pgh.pa.us> Content-Description: fix-notice-before-waiting.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/iso= lationtester.c index 6ab19b1..e97fef1 100644 *** a/src/test/isolation/isolationtester.c --- b/src/test/isolation/isolationtester.c *************** try_complete_step(Step *step, int flags) *** 752,757 **** --- 752,777 ---- = if (waiting) /* waiting to acquire a lock */ { + /* + * Since it takes time to perform the lock-check query, + * some data --- notably, NOTICE messages --- might have + * arrived since we looked. We should do PQconsumeInput + * to process any such messages, and we might as well then + * check PQisBusy, though it's unlikely to succeed. + */ + if (!PQconsumeInput(conn)) + { + fprintf(stderr, "PQconsumeInput failed: %s\n", + PQerrorMessage(conn)); + exit(1); + } + if (!PQisBusy(conn)) + break; + = + /* + * conn is still busy, so conclude that the step really is + * waiting. + */ if (!(flags & STEP_RETRY)) printf("step %s: %s \n", step->name, step->sql); ------- =_aaaaaaaaaa0--