Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id B3DAB6372FB for ; Tue, 25 Aug 2009 12:25:52 -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 41552-03 for ; Tue, 25 Aug 2009 15:25:41 +0000 (UTC) X-Greylist: delayed 00:06:00.994028 by SQLgrey-1.7.6 Received: from mail-ew0-f216.google.com (mail-ew0-f216.google.com [209.85.219.216]) by mail.postgresql.org (Postfix) with ESMTP id 1AA4363641E for ; Tue, 25 Aug 2009 12:21:37 -0300 (ADT) Received: by ewy12 with SMTP id 12so3828560ewy.24 for ; Tue, 25 Aug 2009 08:21:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.211.200.7 with SMTP id c7mr6756970ebq.54.1251213335321; Tue, 25 Aug 2009 08:15:35 -0700 (PDT) In-Reply-To: <4A9334C4.2060503@opencloud.com> References: <895e58dd0908241736q3575cdc2v461d879c5b5f9dcb@mail.gmail.com> <4A9334C4.2060503@opencloud.com> Date: Tue, 25 Aug 2009 08:15:35 -0700 Message-ID: <895e58dd0908250815m1a8aada0qc9d3f0bde9c7a303@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/58 X-Sequence-Number: 19907 The jdbc spec seems vague on that (as on all multi-threaded behavior) and can probably be interpreted either way. I'm not sure what other jdbc drivers do. I can take a look at the MySQL driver. Our concern is that even if the close *should* interrupt the current operation, it should do so cleanly instead of causing a protocol violation. I haven't been able to craft anything worse than an error on close, but just looking at the code, there's definitely a lack of synchronization on the shared PGStream object there that could potentially lead to worse problems. On Mon, Aug 24, 2009 at 5:48 PM, Oliver Jowett wrote: > Maciek Sakrejda wrote: >> We've found some synchronization issues around PGStream in >> QueryExecutorImpl and ProtocolConnectionImpl. Specifically, while >> QueryExecutorImpl synchronizes all its uses off PGStream, >> ProtocolConnectionImpl uses the same PGStream directly when close() is >> called. This can easily cause protocol-level errors and, >> theoretically, at least, bad data shoved into a COPY IN query while >> the actual Connection.close() is ignored. This doesn't just affect >> COPY, though--anything that causes writes to the QueryExecutorImpl's >> pgStream could be affected. >> >> The only thing I've achieved so far is protocol-level errors, but >> that's a serious enough issue on its own. >> >> It's not immediately clear how to fix this, since we don't want to >> synchronize PGStream itself. Should ProtocolConnectionImpl just >> delegate to QueryExecutorImpl on close() perhaps, with >> QueryExecutorImpl handling the actual writes to PGStream? > > What's the expected behaviour when Connection.close() is called > concurrently with other work happening on the connection - should the > close interrupt the current operation? > > -O > -- Maciek Sakrejda | Software Engineer | Truviso (650) 242-3500 Main (650) 242-3501 F msakrejda@truviso.com www.truviso.com