Re: [GENERAL] fork() bad

From: M Simms <grim(at)argh(dot)demon(dot)co(dot)uk>
To: richip(at)mozcom(dot)com (Richi Plana)
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] fork() bad
Date: 1999-03-22 14:08:51
Message-ID: 199903221408.OAA28600@argh.demon.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> Hi,
>
> I'm probably doing something wrong here.
>
> My process establishes a connection with a PostgreSQL backen and then
> fork()s (twice, actually). To make things even more complicated (though I
> don't know if it affects things), my connection handle is a global
> variable in a dynamically-loaded shared object.
>
> I tried PQreset()ing the connections after forking and then I'd try a
> begin but I'd get the ff.:
>
> NOTICE: BeginTransactionBlock and not in default state
>
> What does that mean?
>
>
> So, what's the deal with fork()ing and connections?
>

Well, Ive not looked at the code, but I should be right here.

If you fork, you will have two processes pumping data down the same
connection to the database, cos the fork() will simply duplicate the
file descriptor reference, not make you a new connection. If two
forked() processes try and send data or retrieve data at the same
time, everything will break, as the database obviously will not know
what the hell is going on and will get a mangled transmission

In response to

  • fork() bad at 1999-03-22 13:30:58 from Richi Plana

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richi Plana 1999-03-22 15:48:00 Re: [GENERAL] fork() bad
Previous Message Richi Plana 1999-03-22 13:30:58 fork() bad