Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 13E6A634D7E for ; Tue, 25 Aug 2009 13:52:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 59952-02 for ; Tue, 25 Aug 2009 16:52:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.26]) by mail.postgresql.org (Postfix) with ESMTP id BDF706327F2 for ; Tue, 25 Aug 2009 13:52:00 -0300 (ADT) Received: by ey-out-2122.google.com with SMTP id 25so7896969eya.33 for ; Tue, 25 Aug 2009 09:51:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.211.195.14 with SMTP id x14mr5816011ebp.3.1251219118399; Tue, 25 Aug 2009 09:51:58 -0700 (PDT) In-Reply-To: <895e58dd0908250815m1a8aada0qc9d3f0bde9c7a303@mail.gmail.com> References: <895e58dd0908241736q3575cdc2v461d879c5b5f9dcb@mail.gmail.com> <4A9334C4.2060503@opencloud.com> <895e58dd0908250815m1a8aada0qc9d3f0bde9c7a303@mail.gmail.com> Date: Tue, 25 Aug 2009 09:51:58 -0700 Message-ID: <895e58dd0908250951m1aa4baabnf1695c9e681aa278@mail.gmail.com> Subject: Re: PGStream synchronization From: Maciek Sakrejda To: Oliver Jowett Cc: pgsql-jdbc@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200908/59 X-Sequence-Number: 19908 Ok, so it looks like MySQL at least *intends to* wait for all statements to finish executing before closing the connection. I don't believe this is actually accomplished, since some things synchronize on the MySQL Connection object itself, whereas some synchronize on a separate mutex Object it exposes through a getMutex() method, but that's sort of irrelevant to this discussion. I'm not quite sure what the right behavior with respect to close() should be. If we wait for all statements to finish executing, we could be waiting for a very long time (especially in the case of an open COPY or something silly like "SELECT pg_sleep(1000000)"). If, on the other hand, we cancel all still-executing queries and in-progress COPY operations, the burden of coordinating this falls to the user, which is somewhat unfortunate. The second choice is probably more reasonable--the jdbc API says that close() "Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released." and it would be tough to interpret "immediately" as "block until everything currently executing is done". I'm not that familiar with the FEBE protocol (I'll look into this as well), but we don't need to cancel regular queries explicitly, right? The Terminate message is always valid, except in COPY mode? If that's the case, we only need to ensure that the various PGStream messages are sent atomically (which is currently *not* the case in the case of Terminate), and handle COPY specially (by issuing CopyFail followed by Terminate). I'm happy to start work on a patch if we find an approach we agree on. Thanks, -- Maciek Sakrejda | Software Engineer | Truviso (650) 242-3500 Main (650) 242-3501 F msakrejda@truviso.com www.truviso.com