Thread: Strange Bug in exim4 postgresql lookup code or libpq?

Strange Bug in exim4 postgresql lookup code or libpq?

From
Alexander Neumann
Date:
Hi,

I'm using exim4 together with postgresql.  Sometimes, data lookups fail
mysteriously and on the exim side nobody was able to help.

In short terms: The result code is PGRES_FATAL_ERROR, but the error message
is an empty string.

I opened up a bug in the exim bugzilla:
http://www.exim.org/bugzilla/show_bug.cgi?id=45

The complete description is there and possibly too long for this mailing
list...

Can someone please look at this?  I really need help here :)

Please CC: me on replies, as I'm not subscribed to this list.

Regards,
- Alexander

Attachment

Re: Strange Bug in exim4 postgresql lookup code or libpq?

From
Alvaro Herrera
Date:
On Thu, Sep 15, 2005 at 03:14:10PM +0200, Alexander Neumann wrote:

> I'm using exim4 together with postgresql.  Sometimes, data lookups fail
> mysteriously and on the exim side nobody was able to help.
>
> In short terms: The result code is PGRES_FATAL_ERROR, but the error message
> is an empty string.
>
> I opened up a bug in the exim bugzilla:
> http://www.exim.org/bugzilla/show_bug.cgi?id=45

Notice this part of the Postgres log:

2005-09-01 18:19:01 [5462] LOG:  statement: SELECT sa_tempreject_score FROM
exim_virtual_addresses WHERE domain = 'xxxx.org' AND (mailbox = 'xxxxxxxxx' OR
mailbox = '*') ORDER BY mailbox DESC LIMIT 1
2005-09-01 18:19:01 [5462] LOG:  unexpected EOF on client connection


Why is the client closing the connection?  This seems to be a bug in the
client.  Notice that the last query registered for process 5462 is
against table sa_tempreject_score, but your first log snippet shows, on
line 2, a query against table sa_reject_score which is failing.  The
first line says something about a tempreject_score, which probably comes
from the last query Postgres received.

The connection cache code needs some looking at, apparently ...

--
Alvaro Herrera -- Valdivia, Chile         Architect, www.EnterpriseDB.com
"Hay que recordar que la existencia en el cosmos, y particularmente la
elaboración de civilizaciones dentre de él no son, por desgracia,
nada idílicas" (Ijon Tichy)

Re: Strange Bug in exim4 postgresql lookup code or libpq?

From
Martijn van Oosterhout
Date:
On Thu, Sep 15, 2005 at 03:14:10PM +0200, Alexander Neumann wrote:
> Hi,
>
> I'm using exim4 together with postgresql.  Sometimes, data lookups fail
> mysteriously and on the exim side nobody was able to help.
>
<snip>
> I opened up a bug in the exim bugzilla:
> http://www.exim.org/bugzilla/show_bug.cgi?id=45

The server log said:
2005-09-01 18:19:01 [5462] LOG:  statement: SELECT sa_tempreject_score FROM
exim_virtual_addresses WHERE domain = 'xxxx.org' AND (mailbox = 'xxxxxxxxx' OR
mailbox = '*') ORDER BY mailbox DESC LIMIT 1
2005-09-01 18:19:01 [5462] LOG:  unexpected EOF on client connection

It's not clear if the EOF was caused by exim not closing down properly
or something else. There's nothing special about the domains you've x'd
out?

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

Re: Strange Bug in exim4 postgresql lookup code or libpq?

From
Tom Lane
Date:
Alexander Neumann <alexander@bumpern.de> writes:
> In short terms: The result code is PGRES_FATAL_ERROR, but the error message
> is an empty string.

AFAIK that shouldn't happen, unless perhaps you are completely out of
memory in the client-side process.  What shows up in the postmaster
error log when this occurs?

            regards, tom lane

Re: Strange Bug in exim4 postgresql lookup code or libpq?

From
Alexander Neumann
Date:
Hi,

* Martijn van Oosterhout <kleptog@svana.org> wrote:
> On Thu, Sep 15, 2005 at 03:14:10PM +0200, Alexander Neumann wrote:
> > I'm using exim4 together with postgresql.  Sometimes, data lookups fail
> > mysteriously and on the exim side nobody was able to help.
>
> The server log said:
> 2005-09-01 18:19:01 [5462] LOG:  statement: SELECT sa_tempreject_score FROM
> exim_virtual_addresses WHERE domain = 'xxxx.org' AND (mailbox = 'xxxxxxxxx' OR
> mailbox = '*') ORDER BY mailbox DESC LIMIT 1
> 2005-09-01 18:19:01 [5462] LOG:  unexpected EOF on client connection
>
> It's not clear if the EOF was caused by exim not closing down properly
> or something else. There's nothing special about the domains you've x'd
> out?

Nop. The query works and returns the expected results when cut&pasted from
the logs (either exim or postgresql). I even sniffed the smtp dialogue and
tried to reproduce it, without any success (it just works if i'm trying it).

So this is either caused by a strange (but reproduceable) race-condition or
it somehow depends on the connecting ip address of the other side's server.

Thanks for reading,
- Alexander

Attachment

Re: Strange Bug in exim4 postgresql lookup code or libpq?

From
Alexander Neumann
Date:
Hi,

* Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Alexander Neumann <alexander@bumpern.de> writes:
> > In short terms: The result code is PGRES_FATAL_ERROR, but the error message
> > is an empty string.
> AFAIK that shouldn't happen, unless perhaps you are completely out of
> memory in the client-side process.  What shows up in the postmaster
> error log when this occurs?

=================<snip>========================
2005-09-01 18:19:01 [5462] LOG:  connection received: host=127.0.0.1 port=41446
2005-09-01 18:19:01 [5462] LOG:  connection authorized: user=exim database=pfauadmin
2005-09-01 18:19:01 [5462] LOG:  statement: SELECT domain || ' : ' FROM exim_virtual_domains
2005-09-01 18:19:01 [5462] LOG:  statement: SELECT sa_enable FROM exim_virtual_addresses WHERE domain = 'xxxx.org' AND
(mailbox= 'xxxxxxxxx' OR mailbox = '*') ORDER BY mailbox DESC LIMIT 1 
2005-09-01 18:19:01 [5462] LOG:  statement: SELECT sa_tempreject_score FROM exim_virtual_addresses WHERE domain =
'xxxx.org'AND (mailbox = 'xxxxxxxxx' OR mailbox = '*') ORDER BY mailbox DESC LIMIT 1 
2005-09-01 18:19:01 [5462] LOG:  unexpected EOF on client connection
=================<snip>========================

The first query succeeds, the second fails. Both work and deliver exactly
the results as expected, when cut&pasted from the logs (either exim or
postgresql)...

Thanks for reading,
- Alexander


Attachment

Re: Strange Bug in exim4 postgresql lookup code or libpq?

From
Tom Lane
Date:
Alexander Neumann <alexander@bumpern.de> writes:
>> 2005-09-01 18:19:01 [5462] LOG:  unexpected EOF on client connection

> So this is either caused by a strange (but reproduceable) race-condition or
> it somehow depends on the connecting ip address of the other side's server.

The "unexpected EOF" indicates pretty clearly that the problem is on the
client side.

            regards, tom lane