Re: Bug in ecpg lib ?

From: leif(at)crysberg(dot)dk
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Bug in ecpg lib ?
Date: 2009-07-08 07:41:42
Message-ID: 15766316.150101247038902135.JavaMail.root@quick
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Laurenz,

Thank you for your effort. I appreciate it very much.

I have been trying to figure this thing out myself too, breakpointing and single stepping my way through some of the ecpg code, but without much clarification. (More that I learned new things about pthread). I have been trying to figure out whether this is a real thing or more a mudflapth "mis-judgement". Also on most (the faster ones) machines mudflap complains either about "invalid pointer in free()" or "double free() or corruption". I haven't been able to verify this yet. Specifically on one (slower) machine, I have only seen this mudflapth complaint once, though I have been both running and debugging it on that many times.

Are you sure what you suggest is nonsense ? In the light of the sqlca struct being "local" to each thread ? I tried to put the open and close connection within the thread, but I was still able to get the mudflap complaint. Theoretically, I guess one could use just 1 connection for all db access in all threads just having them enclosed within pthread_mutex_[un]lock()s !? (Not what I do, though.)

And for your previous mail: Yes, I know that my example does not make the connection, but are still doing the select ... It doesn't matter, however, if it does make a connection, it still bumps out.
And yes, I am aware that I open the connection in the "main thread" and use it another. This is the way real daemon program was designed.

Once again, thank you,

Leif

----- "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> wrote:

> I wrote:
> > What I notice about your program is that you connect to the
> database
> > in the main thread, then start a new thread and use the connection
> in that
> > new thread.
> >
> > I don't know, but I'd expect that since ecpg keeps a
> thread-specific
> > sqlca, this could cause problems. Indeed I find with the debugger
> that in
> > your sample sqlca is allocated and initialized twice, once when the
> > catabase connection is attempted, and once when the SQL statement is
> run.
> >
> > I think that the "good" way to do it would be:
> > - start a thread
> > - connect to the database
> > - do work
> > - disconnect from the database
> > - terminate the thread
>
> I thought some more about that, and it is obvioisly nonsense.
> Why shouldn't you use a connection object in a different thread?
>
> I'll try to come up with some more findings to help figure out
> what's going on.
>
> Yours,
> Laurenz Albe

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lizzy M 2009-07-08 08:08:44 pqSocketCheck() didn't return, hung in poll()? Is it a bug?
Previous Message Albe Laurenz 2009-07-08 07:02:19 Re: Bug in ecpg lib ?