Re: libpq error codes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Denis Perchine <dyp(at)perchine(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: libpq error codes
Date: 2000-06-22 07:30:19
Message-ID: 7810.961659019@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

Denis Perchine <dyp(at)perchine(dot)com> writes:
>>>> db=> select count(*) from pg_class;
>>>> pqReadData() -- read() failed: errno=32
>>>>
>>
>> The two obvious questions about this are (a) what is errno 32 on
>> your system and (b) why is your strerror() yielding garbage instead
>> of an appropriate error message?

> a. It's broken pipe
> b. Sorry, it's (a) in russian.

Duh, should've figured it was something like that. Didn't show up
as anything much on my display...

>> On my system errno 32 is EPIPE, but surely read() should never
>> return EPIPE.

> That's right... But what should read return if connection is closed by
> other side?

EOF, no more and no less. It is not for the kernel to decide whether
the connection closure represents an application-level error or not.
Sounds like someone has managed to blow this badly in recent Linux TCP
stacks. Care to file a kernel bug report?

In the meantime, it's probably reasonable for libpq to treat EPIPE from
read() the same as EOF --- if I recall correctly, it already tests for
ECONNRESET instead of EOF from kernels that have that variety of
braindamage, so adding a defense against this variety is fair game.
If you look in src/interfaces/libpq/fe-misc.c the places to fix should
be obvious (but note there are two or three of them, not just one).
Please try it out and submit a patch after you've verified it fixes
your problem.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Denis Perchine 2000-06-22 08:05:34 Re: [GENERAL] libpq error codes
Previous Message Denis Perchine 2000-06-22 06:55:27 Re: libpq error codes

Browse pgsql-patches by date

  From Date Subject
Next Message Philip J. Warner 2000-06-22 07:50:15 Re: Big 7.1 open items
Previous Message Tom Lane 2000-06-22 07:17:45 Re: Big 7.1 open items