pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedlibpq++ in Apache Problem.
5+ messages / 2 participants
[nested] [flat]
* libpq++ in Apache Problem.
@ 2001-05-28 02:22 pgsql-interfaces@commandprompt.com
0 siblings, 0 replies; 5+ messages in thread
From: pgsql-interfaces@commandprompt.com @ 2001-05-28 02:22 UTC (permalink / raw)
To: pgsql-interfaces
Good day,
I'm experiencing a truly strange issue with the libpq++ interface when I
run it within an Apache process, and I was hoping that perhaps someone
else has run into this.
Inside of an Apache module I am developing, I need to make calls to
PostgreSQL, so I am building it with the libpq++ interface. It's worked
fine thus far, because the module is designed to keep a persistent
connection to PostgreSQL by having a PgDatabase* object that lives and
dies with each httpd process.
However, if I try to instantiate a PgDatabase* connection temporarily
within the httpd process, even though I delete the pointer to call the
destructor of the Object, the postmaster connection *continues to hang
around*, well after the request has finished processing, and well after
the call to its destructor is made.
I thought this might have something to do with the kind of convoluted way
that I'm linking my Apache module (which is written in C++, while Apache
is compiled in C) so I wrote a test case of a simple console application
that is written in C, but calls to object code compiled in C++ with
libpq++, and it behaved correctly. I was able to call destructors fine,
and memory was instantly returned and the connection closed.
So... I'm really at a loss here on what's going on, and wondering if
anyone has some insight? I can give more technical details if necessary,
that's just the gist of the problem.
Thanks, and Regards,
Jw.
--
John Worsley - Command Prompt, Inc.
jlx@commandprompt.com By way of pgsql-interfaces@commandprompt.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: libpq++ in Apache Problem.
@ 2001-05-28 17:25 pgsql-interfaces@commandprompt.com
0 siblings, 0 replies; 5+ messages in thread
From: pgsql-interfaces@commandprompt.com @ 2001-05-28 17:25 UTC (permalink / raw)
To: pgsql-interfaces; +Cc: J. T. Vermeulen <jtv@cistron.nl>
On Mon, 28 May 2001, J. T. Vermeulen wrote:
>On Sun, 27 May 2001, pgsql-interfaces@commandprompt.com wrote:
>>So... I'm really at a loss here on what's going on, and wondering if
>>anyone has some insight? I can give more technical details if necessary,
>>that's just the gist of the problem.
>Just a thought: You're not using exit(), are you?
Heh, nope. ;) I wish it were that simple.
The httpd process itself doesn't end, in fact. It just keeps on running,
which is the problem, because it accumulates postmaster connections with
each request until it's killed.
What is perplexing is why the destructor doesn't seem to be doing its job
when called from inside httpd, inexplicably. It is definitely reaching
that point in the code, but it just doesn't disconnect.
Further frustrating the matter, I tried not dynamically creating the
PgDatabase on the heap, and just made it a local variable on the stack.
Eg, PgDatabase foo(); instead of PgDatabase *foo = new PgDatabase.
Guess what? It still keeps the connection after leaving its scope. Grr.
This is easily the most frustrating programming problem I have experienced
in using PostgreSQL.
Jw.
--
John Worsley, Command Prompt, Inc.
jlx@commandprompt.com by way of pgsql-interfaces@commandprompt.com.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: libpq++ in Apache Problem.
@ 2001-05-29 14:42 pgsql-interfaces@commandprompt.com
0 siblings, 1 reply; 5+ messages in thread
From: pgsql-interfaces@commandprompt.com @ 2001-05-29 14:42 UTC (permalink / raw)
To: pgsql-interfaces
On Tue, 29 May 2001, jtv wrote:
>On Mon, May 28, 2001 at 10:25:31AM -0700, pgsql-interfaces@commandprompt.com wrote:
>>What is perplexing is why the destructor doesn't seem to be doing its job
>>when called from inside httpd, inexplicably. It is definitely reaching
>>that point in the code, but it just doesn't disconnect.
>Well, that's me stumped. The only other thing I can think of is that some
>query/command execution code forgets to clear up its result set structure
>pointer prior to replacing it with a new result set, thereby confusing the
>underlying C library with invalid pointers. Or something.
I thought that might be the case too, so I commented out all the code that
actually uses the PgDatabase *sqlDB variable, and it still happens. You
can imagine how frustrating this would be. ;)
I essentially have a block of code that creates a connection, does nothing
with it, SHOULD delete it when it hits the destructor, but either doesn't
destruct at all, or doesn't properly call CloseConnection, or something
more primitive goes wrong. At any rate, the connection, even unused, WILL
NOT GO AWAY! It's mind-boggling.
>>Guess what? It still keeps the connection after leaving its scope. Grr.
>How long-lived are these connections? I've been seeing my problems after
>leaving them idle for perhaps several seconds. Shortening their lifetimes
>happened to help in my case <shudder>.
Weird! Well, in my case, I'm just creating an open connection, and it just
hangs out indefinitely. I let it run a full day once just to check. They
hung around for a day or so before I re-started apache to clean up the
processes.
The next step in trouble-shooting this I suppose is to build the dummy
Apache module with libpq++ and see if it the same behavior is exhibited.
If not, it's got to be something deeper in the core of my module.
I'm not sure I like either outcome of that test.
Jw.
--
John Worsley at Command Prompt, Inc.
jlx@commandprompt.com by way of pgsql-interfaces@commandprompt.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: libpq++ in Apache Problem.
@ 2001-05-31 15:33 jtv <jtv@xs4all.nl>
parent: pgsql-interfaces@commandprompt.com
0 siblings, 1 reply; 5+ messages in thread
From: jtv @ 2001-05-31 15:33 UTC (permalink / raw)
To: pgsql-interfaces@commandprompt.com; +Cc: pgsql-interfaces
On Tue, May 29, 2001 at 07:42:46AM -0700, pgsql-interfaces@commandprompt.com wrote:
>
> The next step in trouble-shooting this I suppose is to build the dummy
> Apache module with libpq++ and see if it the same behavior is exhibited.
> If not, it's got to be something deeper in the core of my module.
Have you tried using just libpq, and just "inlining" the code that libpq++
*should* be executing based on your invocations? Sounds like you don't even
need the PQresult structure to reproduce the problem, so it should be doable.
Jeroen
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: libpq++ in Apache Problem.
@ 2001-06-05 18:17 pgsql-interfaces@commandprompt.com
parent: jtv <jtv@xs4all.nl>
0 siblings, 0 replies; 5+ messages in thread
From: pgsql-interfaces@commandprompt.com @ 2001-06-05 18:17 UTC (permalink / raw)
To: jtv <jtv@xs4all.nl>; +Cc: pgsql-interfaces
On Thu, 31 May 2001, jtv wrote:
>On Tue, May 29, 2001 at 07:42:46AM -0700, pgsql-interfaces@commandprompt.com wrote:
>>The next step in trouble-shooting this I suppose is to build the dummy
>>Apache module with libpq++ and see if it the same behavior is exhibited.
>>If not, it's got to be something deeper in the core of my module.
>Have you tried using just libpq, and just "inlining" the code that libpq++
>*should* be executing based on your invocations? Sounds like you don't even
>need the PQresult structure to reproduce the problem, so it should be doable.
Unfortunately, this is a kind of at a deep level in an application
utilizing libpq++, and it'd be somewhat nightmarish to refactor all the
libpq++ code into procedural libpq.
Theoretically I could use libpq for this one function, since my other
libpq++ objects live and die correctly with the httpd process, and have
the two different APIs co-existing, it's just not ideal.
Moreover, I want to know WHY this is happening! ;) This is truly bizarre.
Jw.
--
jlx@commandprompt.com by way of pgsql-interfaces@commandprompt.com
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2001-06-05 18:17 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-05-28 02:22 libpq++ in Apache Problem. pgsql-interfaces@commandprompt.com
2001-05-28 17:25 Re: libpq++ in Apache Problem. pgsql-interfaces@commandprompt.com
2001-05-29 14:42 Re: libpq++ in Apache Problem. pgsql-interfaces@commandprompt.com
2001-05-31 15:33 ` jtv <jtv@xs4all.nl>
2001-06-05 18:17 ` pgsql-interfaces@commandprompt.com
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox