Re: Copy_from gets stuck with bigger input file
Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Organization | initd.org |
| Message-ID | <[email protected]> |
I just commited to the trunk a change that allows psycopg to raise an
error instead of locking when there is an error during the COPY
operation. There is definitely something bad going on here:
The call to PQputCopyData() returns -1 (error) and calling
PQerrorMessage prints the following error:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Uh?! Anyway that explains why any successive send operation fails and
trying to get something from the server just hangs forever. The problem
is that PQstatus() returns CONNECTION_OK and PQtransactionStatus()
returns PQTRANS_ACTIVE, so there is no way to cleanup cleanly. So the
fix is to simply mark any connection that fails in COPY as
"bad" (closed) forcing the client code to cope with the exception and
re-open it.
Someone with more time than me should really write to PostgreSQL devel
mailing list asking:
1. Why if the server says "server closed the connection
unexpectedly" the connection is not marked as CONNECTION_BAD?
2. Why the COPY fails in the first place?
Comments?
federico
--
Federico Di Gregorio http://people.initd.org/fog
Debian GNU/Linux Developer [email protected]
INIT.D Developer fog-NGVKUo/i/[email protected]
Credo fermamente che da qualche parte, in una scatola ci sia un gatto
che non è vivo ne morto. Credo anche che se i fisici non si sbrigano
a dargli una scatoletta, ben presto sarà solo morto.
-- adattato da una frase di Sam Black Crow
_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBIPC6mvcCgrgZGjesRAlOSAJ9+hpZ6r/xlb7pLsEbkMfK2yqZ7gwCePrx0 GZbecOXhEfTr0csRSPLDHik= =QZ/a -----END PGP SIGNATURE-----