X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A0E015E46D6 for ; Fri, 20 Aug 2004 07:04:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42611-02 for ; Fri, 20 Aug 2004 10:04:43 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 7B5915E40BB for ; Fri, 20 Aug 2004 07:04:41 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1By6GI-0001aF-00; Fri, 20 Aug 2004 22:04:42 +1200 Message-ID: <4125CCB8.10801@opencloud.com> Date: Fri, 20 Aug 2004 22:04:40 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Mikko T." Cc: pgsql-jdbc@postgresql.org Subject: Re: OutOfMemory when inserting stream of unknown length References: <41251B4C.9020205@opencloud.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/117 X-Sequence-Number: 10839 Mikko T. wrote: > I think that commiting to send very large data values that are not even > guaranteed to exist (or be available) makes it impossible to get the > protocol back to known state if for some reason the data cannot be sent > or the last command should be aborted. In the current solution the only > option seems to be to kill the whole connection but I find that quite an > extreme thing to do. I discussed some alternatives with Kris a while ago but no implementation has happened yet. The most promising approach was to pad out the parameter in the Bind message, then immediately Close the resulting portal without executing it and return an error to the application. > In my opinion the protocol level should support sending the data in > chunks (4K - 16K could be optimal). This way the jdbc driver only has to > buffer one chunk ahead and not the whole stream and it always knows > there won't be any IOExceptions or EOF occuring during the sending. > Supporting chunked sending would also allow the jdbc driver to support > cancel/rollback the streaming if it needs to or is asked to do so by the > database even if there would still be megabytes of data to send. Right -- something like HTTP/1.1's chunked transfer scheme. We would have to have some "partially bound portal" state floating around on the server side which seems ugly (and coordinating multiple parameters is going to get nasty). Is it worth it? I have a feeling that pgsql-hackers may take some convincing; sending data of unknown length doesn't seem like it would be widely used, and it'd be quite a lot of complexity to add. There's nothing much we can do about this with the current protocol unfortunately :( -O