Segfault when connecting during Apache startup with Apache::DBI - modperl

This is a discussion on Segfault when connecting during Apache startup with Apache::DBI - modperl ; On Tue, Jul 1, 2008 at 3:42 AM, Tobias Kremer wrote:
> Removing Apache: BI makes the errors go away.
Ok. First, check that you're on the latest version. Then, turn on
the debug flag and see if it thinks ...

This comes up a couple of times for every new process and afterwards
changes to "already connected" which is exactly the behaviour I expected in the
first place.

Do you have any idea what is going on? I'll check out how our real system
behaves with this change.

Thanks a lot, Perrin!

--Tobias

Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")

Quoting Tobias Kremer :
> Quoting Perrin Harkins :
> > How are you loading this? With a PerlModule call? Can you try
> > loading it from a Perl section like this?
> >
> > use MyModule;
> >
> Wow, it seems that this fixes the problem!
> Do you have any idea what is going on? I'll check out how our real system
> behaves with this change.

No more errors there either!

I don't know anything about the internals but to me the mod_perl source looks
like PerlModule is using "require" instead of "use" to load modules. I guess
that is making the difference?

Whatever the cause is, I think it should be documented somewhere. I'd happily
provide a doc-patch for whatever documentation is suitable

--Tobias

Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")

Great!
> I don't know anything about the internals but to me the mod_perl source looks
> like PerlModule is using "require" instead of "use" to load modules. I guess
> that is making the difference?

I don't know the details, but there is something about the way
PerlModule works in mod_perl 1 that causes it to load the module again
when apache restarts at startup (it runs yours conf file twice when
you start, as documented). Using an explicit use() puts an entry in
%INC and fixes the issue. This should happen with require() as well,
so I don't know what the problem is, but I've been told that mod_perl
2 doesn't have this problem.

There seems to be an additional bug in either Apache:BI or mod_perl
1, since $Apache::ServerStarting == 1 seems not to be true the second
time through. Can you have your Perl section print out the values of
$Apache::ServerStarting and $Apache::ServerReStarting?

- Perrin

Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")

> I don't know the details, but there is something about the way
> PerlModule works in mod_perl 1 that causes it to load the module again
> when apache restarts at startup (it runs yours conf file twice when
> you start, as documented). Using an explicit use() puts an entry in
> %INC and fixes the issue. This should happen with require() as well,
> so I don't know what the problem is, but I've been told that mod_perl
> 2 doesn't have this problem.

So, due to this being the mod_perl list there must be somebody here who knows
what's going on deep down in the guts of the beast
> There seems to be an additional bug in either Apache:BI or mod_perl
> 1, since $Apache::ServerStarting == 1 seems not to be true the second
> time through. Can you have your Perl section print out the values of
> $Apache::ServerStarting and $Apache::ServerReStarting?

This gives me:

Apache::ServerStarting = 1
Apache::ServerReStarting = 0

once(!) on server startup - no matter if I "use" my handler or load it via
PerlModule.