Re: [HACKERS] [JDBC] Trouble with COPY IN

2010-07-29 Thread Matthew Wakeling
(Yes, I know I'm not on the hackers list. Most interested parties should 
get this directly anyway.)


Additionally the interface exposed by the JDBC driver lets the user 
write arbitrary CopyData bytes to the server, so without parsing all of 
that we don't know whether they've issued CopyData(EOF) or not.


Okay, so you can't know with absolute certainty without parsing the 
data, but the usual case would be handled by holding onto the last-N 
bytes or so. Enough to fit the EOF and perhaps a little more for 
paranoia's sake.


That's not to say that I'm missing the problem. When (not if, when) 
the user feeds data past a CopyData(EOF), it's going to get interesting.


This is the reason why the patch to the JDBC driver that I sent in is very 
fragile. In the case where a user provides a binary copy with lots of data 
after the EOF, the processCopyData method *will* get called after the 
CommandComplete and ReadyForQuery messages have been received, even if we 
try to delay processing of the ReadyForQuery message.


[Thinking about the logic necessary to handle such a case and avoid 
network buffer deadlock...] I would think the least invasive way to 
handle it would be to set the CommandComplete and ReadyForQuery messages 
aside when they are received if CopyDone hasn't been sent, continue the 
COPY operation as usual until it is shutdown, send CopyDone and, 
finally, reinstate CommandComplete and RFQ as if they were just 
received..


Basically, yes. We need to introduce a little more state into the JDBC 
driver. Currently, the driver is in one of two states:


1. In the middle of a copy.
2. Not in a copy.

These states are recorded in the lock system. We need to introduce a new 
state, where the copy is still locked, but we know that the 
CommandComplete and ReadyForQuery messages have been received. We can no 
longer unlock the copy in processCopyData - we need to do that in endCopy 
instead, after calling processCopyData to ensure that we wait for a valid 
CommandComplete and ReadyForQuery message first.


Matthew

--
Terrorists evolve but security is intelligently designed?  -- Jake von Slatt

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] CREATE DATABASE vs delayed table unlink

2008-10-10 Thread Matthew Wakeling


The error on createdb happened again this morning. However, this time an 
abandoned directory was not created. The full error message was:


$ createdb -E SQL_ASCII -U flyminebuild -h brian.flymine.org -T 
production-flyminebuild production-flyminebuild:uniprot
createdb: database creation failed: ERROR:  could not stat file 
base/33049747/33269704: No such file or directory

However, my colleagues promptly dropped the database that was being 
copied and restarted the build process, so I can't diagnose anything. 
Suffice to say that there is no abandoned directory, and the directory 
33049747 no longer exists either.


I'll try again to get some details next time it happens.

Matthew

--
$ rm core
Segmentation Fault (core dumped)

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] CREATE DATABASE vs delayed table unlink

2008-10-09 Thread Matthew Wakeling

On Thu, 9 Oct 2008, Tom Lane wrote:

So I'm mystified
how Matthew could have seen the expected error and yet had the
destination tree (or at least large chunks of it) left behind.


Remember I was running 8.3.0, and you mentioned a few changes after that 
version which would have made sure the destination tree was cleaned up 
properly.



[ thinks for a bit... ]  We know there were multiple occurrences.
Matthew, is it possible that you had other createdb failures that
did *not* report file does not exist?  For instance, a createdb
interrupted by a fast database shutdown might have left things this
way.


Well, we didn't have any fast database shutdowns or power failures. I 
don't think so.


Matthew

--
Heat is work, and work's a curse. All the heat in the universe, it's
going to cool down, because it can't increase, then there'll be no
more work, and there'll be perfect peace.  -- Michael Flanders

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] CREATE DATABASE vs delayed table unlink

2008-10-09 Thread Matthew Wakeling

Heikki Linnakangas [EMAIL PROTECTED] writes:

Another thought is to ignore ENOENT in copydir.


On Wed, 8 Oct 2008, Tom Lane wrote:

Yeah, I thought about that too, but it seems extremely dangerous ...


I agree. If a file randomly goes missing, that's not an error to ignore, 
even if you think the only way that could happen is safe.


I could be wrong - but couldn't other bad things happen too? If you're 
copying the files before the checkpoint has completed, couldn't the new 
database end up with some of the recent changes going missing? Or is that 
prevented by FlushDatabaseBuffers?


Matthew

--
Isn't Microsoft Works something of a contradiction?

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers