Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id EA5366327BE for ; Sun, 25 Jul 2010 12:01:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 27211-02; Sun, 25 Jul 2010 15:01:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by mail.postgresql.org (Postfix) with ESMTP id 711EB62D46C; Sun, 25 Jul 2010 12:01:50 -0300 (ADT) Received: from mail63.csoft.net (localhost [127.0.0.1]) by mail63.csoft.net (Postfix) with ESMTP id 9E73728429; Sun, 25 Jul 2010 11:01:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=csoft.net; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sel1; bh=ItRLf4A4/6MJQ9yOmR04JZdNAD8=; b=wfLFLd /MUt+8nUG1ARmpLMtVVgWxUjYs/xFI0KQSyOgAELpYhfGuJipwB7LQ75Q55SmalS 0fh2x03SPaJ+E1W+/7OvbuA4JqkTInqo4qnwG81sD1x+fHm2+On7eXRNExm766E7 JKK4UbJj/VypVGx2Wq8gU/F5GeyvHpwlZ32ko= Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail63.csoft.net (Postfix) with ESMTP id 9101C28426; Sun, 25 Jul 2010 11:01:48 -0400 (EDT) Received: by leary.csoft.net (Postfix, from userid 1112) id 83FB5A206; Sun, 25 Jul 2010 11:01:48 -0400 (EDT) Date: Sun, 25 Jul 2010 11:01:48 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: James William Pye cc: Tom Lane , pgsql-hackers@postgresql.org, Matthew Wakeling , Kevin Grittner , Maciek Sakrejda , Samuel Gendler , pgsql-jdbc@postgresql.org Subject: Re: [HACKERS] Trouble with COPY IN In-Reply-To: <7E743A09-D012-4BBB-9B87-24CA1DF51015@jwp.name> Message-ID: References: <4C4562C50200002500033951@gw.wicourts.gov> <9143.1279892435@sss.pgh.pa.us> <4C499E26.4060307@ejurka.com> <9653.1279894296@sss.pgh.pa.us> <7E743A09-D012-4BBB-9B87-24CA1DF51015@jwp.name> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/99 X-Sequence-Number: 20764 On Sat, 24 Jul 2010, James William Pye wrote: > On Jul 23, 2010, at 7:11 AM, Tom Lane wrote: >> I can't help thinking that the JDBC driver must be being overly cute >> if this breaks it ... > > I was wondering the same thing when I first saw Kris' message. However, > iff I understand what JDBC is trying to achieve, I don't think I would > call it "overly". > > Is this a problem because JDBC is trying to detect failures as early as > possible during a COPY IN? Or, is it just JDBC's normal MO to always be > reading? The JDBC driver reads server messages for multiple reasons. One of them is indeed to do early failure detection. Another is to pickup NoticeResponse messages to avoid a network buffer deadlock. If someone puts a trigger on the table you're copying data into that does RAISE NOTICE 'received row X' for each row, to avoid a full network buffer deadlock, the client must regularly read from the backend. So as we are reading along, supposing that we're still mid-copy, we get a command complete message. So this is possible to work around driver side by peeking into the network stream and delaying processing of the end of copy until the driver agrees that the copy is done, but I still maintain that this is a server bug. It is not OK for the server to assume that the client is done and move on, the client must tell the server what it wants done. Kris Jurka