You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Xinhuan Zheng <xz...@christianbook.com> on 2013/05/29 21:24:26 UTC

Apache::DBI "connection lost contact" error

Hi,

I have apache 2.2.23 statically compiled with mod_perl2 (prefork). perl binary is 5.10.1. In startup.pl<http://startup.pl/> file there is call Apache::DBI->connect_on_init.

<code>
use Apache::DBI;
Apache::DBI->connect_on_init( $DB_DRIVER, $DB_USER, $DB_PASSWORD );

use DBI;
</code>

I need to call DBI->connect to load some data during server startup stage. There is problem with this setup. Whenever apachectl startup/shutdown, we got connection error like this:

DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
Process ID: 0
Session ID: 3252 Serial number: 15131 (DBD ERROR: OCISessionEnd) at /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 228.

I am trying to fix this error. I think it's related to DBI->connect in startup.pl<http://startup.pl/>. My question is:

  1.  How do I accomplish loading data into database during server startup using Apache::DBI?
  2.  Once data is loaded during server startup, how do I safely destroy this database handle but not affect the children instantiate their database handles?

Thanks in advance,

Xinhuan

Re: Apache::DBI "connection lost contact" error

Posted by Xinhuan Zheng <xz...@christianbook.com>.
Yes. It's the same way using it. There is database handle created in startup.pl. The startup.pl file is configured in <Perl> block. The "connection lost contact" error only happens when either in "apachectl stop" or when a child process exits.

- xinhuan

From: Perrin Harkins <ph...@gmail.com>>
Date: Thursday, June 13, 2013 11:03 AM
To: Xinhuan Zheng <xz...@christianbook.com>>
Cc: "modperl@perl.apache.org<ma...@perl.apache.org>" <mo...@perl.apache.org>>
Subject: Re: Apache::DBI "connection lost contact" error

That's unfortunate.  Are you using it the same way, with a DBI connection in a <Perl> block?  I haven't seen anyone else mention a problem with it in Apache 1.

- Perrin


On Wed, Jun 12, 2013 at 5:05 PM, Xinhuan Zheng <xz...@christianbook.com>> wrote:
Hi Perrin,

Today I tested the Apache-DBI 1.12 with Apache 1.3.42 and mod_perl 1. We have to use mod_perl 1 in some situations. There is same issue when startup.pl<http://startup.pl> has created database handle. This database handle gets cached and forked across child processes. With debugging turned on, there isn't "skipping connection during server startup, read the docu !!" message at all. It appears this new version only works with Apache2 but not Apache1. Is that possible to fix it with Apache1?

Thanks,
- xinhuan

From: Perrin Harkins <ph...@gmail.com>>
Date: Wednesday, June 12, 2013 5:53 AM
To: Fred Moyer <fr...@redhotpenguin.com>>
Cc: Xinhuan Zheng <xz...@christianbook.com>>, "modperl@perl.apache.org<ma...@perl.apache.org>" <mo...@perl.apache.org>>

Subject: Re: Apache::DBI "connection lost contact" error

Thanks Fred!


On Wed, Jun 12, 2013 at 3:29 AM, Fred Moyer <fr...@redhotpenguin.com>> wrote:
Apache-DBI 1.12 was just pushed to CPAN with this update. Thanks for
the great work on the fix Perrin.

On Thu, Jun 6, 2013 at 2:53 PM, Perrin Harkins <ph...@gmail.com>> wrote:
> That's great!  I'll commit the patch and see about getting a new release out
> to CPAN.
>
> - Perrin
>
>
> On Thu, Jun 6, 2013 at 5:02 PM, Xinhuan Zheng <xz...@christianbook.com>>
> wrote:
>>
>> Hi Perrin,
>>
>> I did a testing with debugging. I don't see the "connection lost contact"
>> error anymore. The patch looks good to me.
>>
>> Thanks,
>> - xinhuan
>>
>> From: Perrin Harkins <ph...@gmail.com>>
>> Date: Thursday, June 6, 2013 3:02 PM
>> To: Xinhuan Zheng <xz...@christianbook.com>>
>> Cc: "modperl@perl.apache.org<ma...@perl.apache.org>" <mo...@perl.apache.org>>
>>
>> Subject: Re: Apache::DBI "connection lost contact" error
>>
>> On Thu, Jun 6, 2013 at 12:22 PM, Xinhuan Zheng <xz...@christianbook.com>>
>> wrote:
>> > The database handle that is created in startup.pl<http://startup.pl> needs to be really
>> > disconnected (not overloaded disconnect) so that won't leave an idle server
>> > process running on the database side. Once it's really disconnected, the
>> > server process can be cleaned up on the server side.
>>
>> Right, that's what the bug is preventing.
>>
>> Because my flight was delayed last night, I had time to make a patch.
>> Please try this on your system and send the debug, like you did before.
>>
>> - Perrin
>>
>



Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
That's unfortunate.  Are you using it the same way, with a DBI connection
in a <Perl> block?  I haven't seen anyone else mention a problem with it in
Apache 1.

- Perrin


On Wed, Jun 12, 2013 at 5:05 PM, Xinhuan Zheng <xz...@christianbook.com>wrote:

>  Hi Perrin,
>
>  Today I tested the Apache-DBI 1.12 with Apache 1.3.42 and mod_perl 1. We
> have to use mod_perl 1 in some situations. There is same issue when
> startup.pl has created database handle. This database handle gets cached
> and forked across child processes. With debugging turned on, there isn't
> "skipping connection during server startup, read the docu !!" message at
> all. It appears this new version only works with Apache2 but not Apache1.
> Is that possible to fix it with Apache1?
>
>  Thanks,
> - xinhuan
>
>   From: Perrin Harkins <ph...@gmail.com>
> Date: Wednesday, June 12, 2013 5:53 AM
> To: Fred Moyer <fr...@redhotpenguin.com>
> Cc: Xinhuan Zheng <xz...@christianbook.com>, "modperl@perl.apache.org" <
> modperl@perl.apache.org>
>
> Subject: Re: Apache::DBI "connection lost contact" error
>
>   Thanks Fred!
>
>
> On Wed, Jun 12, 2013 at 3:29 AM, Fred Moyer <fr...@redhotpenguin.com>wrote:
>
>> Apache-DBI 1.12 was just pushed to CPAN with this update. Thanks for
>> the great work on the fix Perrin.
>>
>> On Thu, Jun 6, 2013 at 2:53 PM, Perrin Harkins <ph...@gmail.com>
>> wrote:
>> > That's great!  I'll commit the patch and see about getting a new
>> release out
>> > to CPAN.
>> >
>> > - Perrin
>> >
>> >
>> > On Thu, Jun 6, 2013 at 5:02 PM, Xinhuan Zheng <xzheng@christianbook.com
>> >
>> > wrote:
>> >>
>> >> Hi Perrin,
>> >>
>> >> I did a testing with debugging. I don't see the "connection lost
>> contact"
>> >> error anymore. The patch looks good to me.
>> >>
>> >> Thanks,
>> >> - xinhuan
>> >>
>> >> From: Perrin Harkins <ph...@gmail.com>
>> >> Date: Thursday, June 6, 2013 3:02 PM
>> >> To: Xinhuan Zheng <xz...@christianbook.com>
>> >> Cc: "modperl@perl.apache.org" <mo...@perl.apache.org>
>> >>
>> >> Subject: Re: Apache::DBI "connection lost contact" error
>> >>
>> >> On Thu, Jun 6, 2013 at 12:22 PM, Xinhuan Zheng <
>> xzheng@christianbook.com>
>> >> wrote:
>> >> > The database handle that is created in startup.pl needs to be really
>> >> > disconnected (not overloaded disconnect) so that won't leave an idle
>> server
>> >> > process running on the database side. Once it's really disconnected,
>> the
>> >> > server process can be cleaned up on the server side.
>> >>
>> >> Right, that's what the bug is preventing.
>> >>
>> >> Because my flight was delayed last night, I had time to make a patch.
>> >> Please try this on your system and send the debug, like you did before.
>> >>
>> >> - Perrin
>> >>
>> >
>>
>
>

Re: Apache::DBI "connection lost contact" error

Posted by Xinhuan Zheng <xz...@christianbook.com>.
Hi Perrin,

Today I tested the Apache-DBI 1.12 with Apache 1.3.42 and mod_perl 1. We have to use mod_perl 1 in some situations. There is same issue when startup.pl has created database handle. This database handle gets cached and forked across child processes. With debugging turned on, there isn't "skipping connection during server startup, read the docu !!" message at all. It appears this new version only works with Apache2 but not Apache1. Is that possible to fix it with Apache1?

Thanks,
- xinhuan

From: Perrin Harkins <ph...@gmail.com>>
Date: Wednesday, June 12, 2013 5:53 AM
To: Fred Moyer <fr...@redhotpenguin.com>>
Cc: Xinhuan Zheng <xz...@christianbook.com>>, "modperl@perl.apache.org<ma...@perl.apache.org>" <mo...@perl.apache.org>>
Subject: Re: Apache::DBI "connection lost contact" error

Thanks Fred!


On Wed, Jun 12, 2013 at 3:29 AM, Fred Moyer <fr...@redhotpenguin.com>> wrote:
Apache-DBI 1.12 was just pushed to CPAN with this update. Thanks for
the great work on the fix Perrin.

On Thu, Jun 6, 2013 at 2:53 PM, Perrin Harkins <ph...@gmail.com>> wrote:
> That's great!  I'll commit the patch and see about getting a new release out
> to CPAN.
>
> - Perrin
>
>
> On Thu, Jun 6, 2013 at 5:02 PM, Xinhuan Zheng <xz...@christianbook.com>>
> wrote:
>>
>> Hi Perrin,
>>
>> I did a testing with debugging. I don't see the "connection lost contact"
>> error anymore. The patch looks good to me.
>>
>> Thanks,
>> - xinhuan
>>
>> From: Perrin Harkins <ph...@gmail.com>>
>> Date: Thursday, June 6, 2013 3:02 PM
>> To: Xinhuan Zheng <xz...@christianbook.com>>
>> Cc: "modperl@perl.apache.org<ma...@perl.apache.org>" <mo...@perl.apache.org>>
>>
>> Subject: Re: Apache::DBI "connection lost contact" error
>>
>> On Thu, Jun 6, 2013 at 12:22 PM, Xinhuan Zheng <xz...@christianbook.com>>
>> wrote:
>> > The database handle that is created in startup.pl<http://startup.pl> needs to be really
>> > disconnected (not overloaded disconnect) so that won't leave an idle server
>> > process running on the database side. Once it's really disconnected, the
>> > server process can be cleaned up on the server side.
>>
>> Right, that's what the bug is preventing.
>>
>> Because my flight was delayed last night, I had time to make a patch.
>> Please try this on your system and send the debug, like you did before.
>>
>> - Perrin
>>
>


Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
Thanks Fred!


On Wed, Jun 12, 2013 at 3:29 AM, Fred Moyer <fr...@redhotpenguin.com> wrote:

> Apache-DBI 1.12 was just pushed to CPAN with this update. Thanks for
> the great work on the fix Perrin.
>
> On Thu, Jun 6, 2013 at 2:53 PM, Perrin Harkins <ph...@gmail.com> wrote:
> > That's great!  I'll commit the patch and see about getting a new release
> out
> > to CPAN.
> >
> > - Perrin
> >
> >
> > On Thu, Jun 6, 2013 at 5:02 PM, Xinhuan Zheng <xz...@christianbook.com>
> > wrote:
> >>
> >> Hi Perrin,
> >>
> >> I did a testing with debugging. I don't see the "connection lost
> contact"
> >> error anymore. The patch looks good to me.
> >>
> >> Thanks,
> >> - xinhuan
> >>
> >> From: Perrin Harkins <ph...@gmail.com>
> >> Date: Thursday, June 6, 2013 3:02 PM
> >> To: Xinhuan Zheng <xz...@christianbook.com>
> >> Cc: "modperl@perl.apache.org" <mo...@perl.apache.org>
> >>
> >> Subject: Re: Apache::DBI "connection lost contact" error
> >>
> >> On Thu, Jun 6, 2013 at 12:22 PM, Xinhuan Zheng <
> xzheng@christianbook.com>
> >> wrote:
> >> > The database handle that is created in startup.pl needs to be really
> >> > disconnected (not overloaded disconnect) so that won't leave an idle
> server
> >> > process running on the database side. Once it's really disconnected,
> the
> >> > server process can be cleaned up on the server side.
> >>
> >> Right, that's what the bug is preventing.
> >>
> >> Because my flight was delayed last night, I had time to make a patch.
> >> Please try this on your system and send the debug, like you did before.
> >>
> >> - Perrin
> >>
> >
>

Re: Apache::DBI "connection lost contact" error

Posted by Fred Moyer <fr...@redhotpenguin.com>.
Apache-DBI 1.12 was just pushed to CPAN with this update. Thanks for
the great work on the fix Perrin.

On Thu, Jun 6, 2013 at 2:53 PM, Perrin Harkins <ph...@gmail.com> wrote:
> That's great!  I'll commit the patch and see about getting a new release out
> to CPAN.
>
> - Perrin
>
>
> On Thu, Jun 6, 2013 at 5:02 PM, Xinhuan Zheng <xz...@christianbook.com>
> wrote:
>>
>> Hi Perrin,
>>
>> I did a testing with debugging. I don't see the "connection lost contact"
>> error anymore. The patch looks good to me.
>>
>> Thanks,
>> - xinhuan
>>
>> From: Perrin Harkins <ph...@gmail.com>
>> Date: Thursday, June 6, 2013 3:02 PM
>> To: Xinhuan Zheng <xz...@christianbook.com>
>> Cc: "modperl@perl.apache.org" <mo...@perl.apache.org>
>>
>> Subject: Re: Apache::DBI "connection lost contact" error
>>
>> On Thu, Jun 6, 2013 at 12:22 PM, Xinhuan Zheng <xz...@christianbook.com>
>> wrote:
>> > The database handle that is created in startup.pl needs to be really
>> > disconnected (not overloaded disconnect) so that won't leave an idle server
>> > process running on the database side. Once it's really disconnected, the
>> > server process can be cleaned up on the server side.
>>
>> Right, that's what the bug is preventing.
>>
>> Because my flight was delayed last night, I had time to make a patch.
>> Please try this on your system and send the debug, like you did before.
>>
>> - Perrin
>>
>

Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
That's great!  I'll commit the patch and see about getting a new release
out to CPAN.

- Perrin


On Thu, Jun 6, 2013 at 5:02 PM, Xinhuan Zheng <xz...@christianbook.com>wrote:

>  Hi Perrin,
>
>  I did a testing with debugging. I don't see the "connection lost
> contact" error anymore. The patch looks good to me.
>
>  Thanks,
> - xinhuan
>
>   From: Perrin Harkins <ph...@gmail.com>
> Date: Thursday, June 6, 2013 3:02 PM
> To: Xinhuan Zheng <xz...@christianbook.com>
> Cc: "modperl@perl.apache.org" <mo...@perl.apache.org>
>
> Subject: Re: Apache::DBI "connection lost contact" error
>
>   On Thu, Jun 6, 2013 at 12:22 PM, Xinhuan Zheng <xz...@christianbook.com>
> wrote:
> > The database handle that is created in startup.pl needs to be really
> disconnected (not overloaded disconnect) so that won't leave an idle server
> > process running on the database side. Once it's really disconnected, the
> server process can be cleaned up on the server side.
>
>  Right, that's what the bug is preventing.
>
>  Because my flight was delayed last night, I had time to make a patch.
>  Please try this on your system and send the debug, like you did before.
>
>  - Perrin
>
>

Re: Apache::DBI "connection lost contact" error

Posted by Xinhuan Zheng <xz...@christianbook.com>.
Hi Perrin,

I did a testing with debugging. I don't see the "connection lost contact" error anymore. The patch looks good to me.

Thanks,
- xinhuan

From: Perrin Harkins <ph...@gmail.com>>
Date: Thursday, June 6, 2013 3:02 PM
To: Xinhuan Zheng <xz...@christianbook.com>>
Cc: "modperl@perl.apache.org<ma...@perl.apache.org>" <mo...@perl.apache.org>>
Subject: Re: Apache::DBI "connection lost contact" error

On Thu, Jun 6, 2013 at 12:22 PM, Xinhuan Zheng <xz...@christianbook.com>> wrote:
> The database handle that is created in startup.pl<http://startup.pl> needs to be really disconnected (not overloaded disconnect) so that won't leave an idle server
> process running on the database side. Once it's really disconnected, the server process can be cleaned up on the server side.

Right, that's what the bug is preventing.

Because my flight was delayed last night, I had time to make a patch.  Please try this on your system and send the debug, like you did before.

- Perrin


Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
On Thu, Jun 6, 2013 at 12:22 PM, Xinhuan Zheng <xz...@christianbook.com>
wrote:
> The database handle that is created in startup.pl needs to be really
disconnected (not overloaded disconnect) so that won't leave an idle server
> process running on the database side. Once it's really disconnected, the
server process can be cleaned up on the server side.

Right, that's what the bug is preventing.

Because my flight was delayed last night, I had time to make a patch.
 Please try this on your system and send the debug, like you did before.

- Perrin

Re: Apache::DBI "connection lost contact" error

Posted by Xinhuan Zheng <xz...@christianbook.com>.
Hi Perrin,

I think I have one more request.

The database handle that is created in startup.pl needs to be really disconnected (not overloaded disconnect) so that won't leave an idle server process running on the database side. Once it's really disconnected, the server process can be cleaned up on the server side.

For child processes, I guess they don't need to really disconnect until the time the child exits.

Thanks,
- xinhuan

From: Perrin Harkins <ph...@gmail.com>>
Date: Wednesday, June 5, 2013 12:08 PM
To: Xinhuan Zheng <xz...@christianbook.com>>
Cc: Jim Schueler <js...@eloquency.com>>, "modperl@perl.apache.org<ma...@perl.apache.org>" <mo...@perl.apache.org>>
Subject: Re: Apache::DBI "connection lost contact" error

On Tue, Jun 4, 2013 at 2:32 PM, Xinhuan Zheng <xz...@christianbook.com>> wrote:
> I have seen in other web servers when apachectl starts, there is no "connect lost contact" error but it did happen when apachectl stops.

If your server does not receive constant requests, you may see this error on shutdown because cached database handles are being destroyed but the connection to the database has already timed out.

> If child process uses ping the inherited database handle and it is ping-able, then the child process may use it. That'll be a problem.

The debugging log you showed us makes me think that won't happen.  It looks like the handle fails immediately when used after a fork.

> When child process exits, it calls rollback if AutoCommit is off, but when another new child process is just born and uses its connection to send
> database updates, will that rollback interfere with new child process attempt to update database?

If the same connection was being used in multiple processes, many things could go wrong, including that.  However, Since the connections die immediately when you use them after a fork, this won't happen.

> Is the rollback necessary?

It's very necessary.  Otherwise, if your code throws an uncaught exception in the middle of some database work, the next request would reuse the same handle with uncommitted changes left on it.  In my opinion, this is the most important thing about Apache::DBI.

I understand you're worried about it.  I should be able to send you a patch to try within a few days, so you can wait for that if you want.  Or you can try to fix it yourself.  My plan is to replace that line of code I showed with some code that checks current_callback() to make sure we're not in a startup phase.

- Perrin

Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
On Tue, Jun 4, 2013 at 2:32 PM, Xinhuan Zheng <xz...@christianbook.com>
wrote:
> I have seen in other web servers when apachectl starts, there is no
"connect lost contact" error but it did happen when apachectl stops.

If your server does not receive constant requests, you may see this error
on shutdown because cached database handles are being destroyed but the
connection to the database has already timed out.

> If child process uses ping the inherited database handle and it is
ping-able, then the child process may use it. That'll be a problem.

The debugging log you showed us makes me think that won't happen.  It looks
like the handle fails immediately when used after a fork.

> When child process exits, it calls rollback if AutoCommit is off, but
when another new child process is just born and uses its connection to send
> database updates, will that rollback interfere with new child process
attempt to update database?

If the same connection was being used in multiple processes, many things
could go wrong, including that.  However, Since the connections die
immediately when you use them after a fork, this won't happen.

> Is the rollback necessary?

It's very necessary.  Otherwise, if your code throws an uncaught exception
in the middle of some database work, the next request would reuse the same
handle with uncommitted changes left on it.  In my opinion, this is the
most important thing about Apache::DBI.

I understand you're worried about it.  I should be able to send you a patch
to try within a few days, so you can wait for that if you want.  Or you can
try to fix it yourself.  My plan is to replace that line of code I showed
with some code that checks current_callback() to make sure we're not in a
startup phase.

- Perrin

Re: Apache::DBI "connection lost contact" error

Posted by Xinhuan Zheng <xz...@christianbook.com>.
Hi Perrin,

I have seen in other web servers when apachectl starts, there is no "connect lost contact" error but it did happen when apachectl stops. If child process uses ping the inherited database handle and it is ping-able, then the child process may use it. That'll be a problem.

When child process exits, it calls rollback if AutoCommit is off, but when another new child process is just born and uses its connection to send database updates, will that rollback interfere with new child process attempt to update database? Is the rollback necessary?

Thanks,
- xinhuan

From: Perrin Harkins <ph...@gmail.com>>
Date: Tuesday, June 4, 2013 12:18 PM
To: Xinhuan Zheng <xz...@christianbook.com>>
Cc: Jim Schueler <js...@eloquency.com>>, "modperl@perl.apache.org<ma...@perl.apache.org>" <mo...@perl.apache.org>>
Subject: Re: Apache::DBI "connection lost contact" error

On Tue, Jun 4, 2013 at 9:59 AM, Xinhuan Zheng <xz...@christianbook.com>> wrote:
> Will the new connection that's created be cached after then and the connection that's not ping-able will be discarded?

Yes.

> Will this cached the new connection last until the child process exit?

Yes, unless it times out on the Oracle side due to inactivity.

> Will rollback be called when child process discovers the connection handle not ping-able?

No, the connection is already closed at that point.

> Will rollback be called when child process exit?

Yes.

Also, I think I see how to fix this, so when I have a few minutes I'll send you a patch to try.

- Perrin


Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
On Tue, Jun 4, 2013 at 9:59 AM, Xinhuan Zheng <xz...@christianbook.com>
wrote:
> Will the new connection that's created be cached after then and the
connection that's not ping-able will be discarded?

Yes.

> Will this cached the new connection last until the child process exit?

Yes, unless it times out on the Oracle side due to inactivity.

> Will rollback be called when child process discovers the connection
handle not ping-able?

No, the connection is already closed at that point.

> Will rollback be called when child process exit?

Yes.

Also, I think I see how to fix this, so when I have a few minutes I'll send
you a patch to try.

- Perrin

Re: Apache::DBI "connection lost contact" error

Posted by Xinhuan Zheng <xz...@christianbook.com>.
Hi Perrin,

> It looks to me like there's no danger here, just an annoying error message.  Your connection from the parent process is being passed across the fork, but then when each child process tries to check it with ping() it fails and a new connection is opened to replace it.

It looks like we still can use the way we do with Apache::DBI safely. The child process creates the new connection and replaces the one that's inherited but not ping-able. Will the new connection that's created be cached after then and the connection that's not ping-able will be discarded? Will this cached the new connection last until the child process exit?

Will rollback be called when child process discovers the connection handle not ping-able?

Will rollback be called when child process exit?

Thanks,
- xinhuan

From: Perrin Harkins <ph...@gmail.com>>
Date: Monday, June 3, 2013 5:14 PM
To: Xinhuan Zheng <xz...@christianbook.com>>
Cc: Jim Schueler <js...@eloquency.com>>, "modperl@perl.apache.org<ma...@perl.apache.org>" <mo...@perl.apache.org>>
Subject: Apache::DBI "connection lost contact" error

On Monday, June 3, 2013, Xinhuan Zheng wrote:
> What is the check to see if the server is restarting? Is that new child processes spawning?

It's a test for whether or not we're running in the parent process, used to skip caching connections during startup. It's this, line 128:
if (Apache2::ServerUtil::restart_count() == 1) {

> If there is a bug in how it checks to see if the server is restarting, does it affect putting it into production use?

It looks to me like there's no danger here, just an annoying error message.  Your connection from the parent process is being passed across the fork, but then when each child process tries to check it with ping() it fails and a new connection is opened to replace it.

I'll investigate the possible bug further when I get back from the conference I'm at right now (YAPC::NA in Austin).

- Perrin


Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
On Mon, Jun 3, 2013 at 4:36 PM, Dave Morgan <da...@1001111.com> wrote:
> As an administrator I still rely and depend on Apache::DBI, even if it is
unsupported.

Can we kill this rumor please?  Apache::DBI is supported.

- Perrin

Re: Apache::DBI "connection lost contact" error

Posted by Fred Moyer <fr...@redhotpenguin.com>.
On Mon, Jun 3, 2013 at 2:36 PM, Dave Morgan <da...@1001111.com> wrote:
> On 06/03/2013 03:14 PM, Perrin Harkins wrote:
>
> DO NOT USE Apache::DBI with DBI::Connector or any other database caching
> technique. This requires
> knowledge of the code!!!

DBIx::Class monkey patches Apache::DBI so that the caching behavior of
Apache::DBI is overriden. I don't think the best approach, but you can
safely use DBIx::Class with mod_perl and have it handle the database
connections. Enable the verbose debug setting in Apache::DBI to verify
that.

Re: Apache::DBI "connection lost contact" error

Posted by Dave Morgan <da...@1001111.com>.
On 06/03/2013 03:14 PM, Perrin Harkins wrote:
> On Monday, June 3, 2013, Xinhuan Zheng wrote:
>  > What is the check to see if the server is restarting? Is that new child processes spawning?

I always found the best way to run/test Apache::DBI was to run a mod-perl enabled http server without Apache::DBI.
Test, let the webserver go idle, do not shutdown, check for live connections to the database. If any, you are doing it wrong :)
Each request should create and destroy 1 database connection (or less)

Once there are no hanging connections, ever, implement Apache::DBI as a simple use statement.
You have accomplished 90% of what is possible.

In today's modern world there are better solutions that can be controlled by the developer.
DBIx::Connector being the most common I believe

DO NOT USE Apache::DBI with DBI::Connector or any other database caching technique. This requires
knowledge of the code!!!

As an administrator I still rely and depend on Apache::DBI, even if it is unsupported.
The only issue I have ever encountered is needing a specific version to talk to an Oracle 8 database
Or where it is caching a cached handle I think is in the cache, I think, please let us not do this anymore.......

YMMV
Dave

-- 
Dave Morgan
Senior Consultant, 1001111 Alberta Limited
dave.morgan@1001111.com
403 399 2442

Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
On Monday, June 3, 2013, Xinhuan Zheng wrote:
> What is the check to see if the server is restarting? Is that new child
processes spawning?

It's a test for whether or not we're running in the parent process, used to
skip caching connections during startup. It's this, line 128:
if (Apache2::ServerUtil::restart_count() == 1) {

> If there is a bug in how it checks to see if the server is restarting,
does it affect putting it into production use?

It looks to me like there's no danger here, just an annoying error message.
 Your connection from the parent process is being passed across the fork,
but then when each child process tries to check it with ping() it fails and
a new connection is opened to replace it.

I'll investigate the possible bug further when I get back from the
conference I'm at right now (YAPC::NA in Austin).

- Perrin

Re: Apache::DBI "connection lost contact" error

Posted by Xinhuan Zheng <xz...@christianbook.com>.
Hi Perrin,

> Does Apache::DBI work right with Apache2+mod_perl2?

Yes, but there may be a bug in how it checks to see if the server is restarting.

What is the check to see if the server is restarting? Is that new child processes spawning?

If there is a bug in how it checks to see if the server is restarting, does it affect putting it into production use?

Thanks,
- xinhuan



Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
On Fri, May 31, 2013 at 5:45 PM, Xinhuan Zheng <xz...@christianbook.com>
wrote:
> 2520 Apache::DBI             skipping connection during server startup,
read the docu !!
> 2520 Apache::DBI             skipping connection during server startup,
read the docu !!

That's good.

> 2521 Apache::DBI             push PerlChildExitHandler
> 2521 Apache::DBI             need ping: yes
> 2521 Apache::DBI             new connect to '….'
> 2521 Apache::DBI             disconnect (overloaded)
> 2521 Apache::DBI             need ping: yes
> 2521 Apache::DBI             already connected to '….'
> 2521 Apache::DBI             disconnect (overloaded)

That's not good.  If this is still part of the startup process, that
shouldn't be caching the database handle.

If you don't use Apache::DBI, do you still see these Oracle errors?

> Are children using same Database Handle?

It looks like that first handle is being copied across the fork from the
parent process.  They don't really use it, because it fails the ping test
and they just open new handles.  It should not cause any real problems,
just the error in your log.

> Does Apache::DBI work right with Apache2+mod_perl2?

Yes, but there may be a bug in how it checks to see if the server is
restarting.

- Perrin

Re: Apache::DBI "connection lost contact" error

Posted by Xinhuan Zheng <xz...@christianbook.com>.
I set this DEBUG in Apache::DBI module. Here is the debugging error it produces at 'apachectl start':

2520 Apache::DBI             skipping connection during server startup, read the docu !!
2520 Apache::DBI             skipping connection during server startup, read the docu !!

2521 Apache::DBI             push PerlChildExitHandler
2521 Apache::DBI             need ping: yes
2521 Apache::DBI             new connect to '….'
2521 Apache::DBI             disconnect (overloaded)
2521 Apache::DBI             need ping: yes
2521 Apache::DBI             already connected to '….'
2521 Apache::DBI             disconnect (overloaded)

2522 Apache::DBI             PerlChildInitHandler
2522 Apache::DBI             need ping: yes
2523 Apache::DBI             PerlChildInitHandler
DBD::Oracle::db DESTROY failed: ORA-03113: end-of-file on communication channel
Process ID: 0
Session ID: 5471 Serial number: 19146 (DBD ERROR: OCISessionEnd) at /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 229.
2524 Apache::DBI             PerlChildInitHandler
2523 Apache::DBI             need ping: yes
DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
Process ID: 0
Session ID: 5471 Serial number: 19146 (DBD ERROR: OCISessionEnd) at /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 229.
2525 Apache::DBI             PerlChildInitHandler
2524 Apache::DBI             need ping: yes
DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
Process ID: 0
Session ID: 5471 Serial number: 19146 (DBD ERROR: OCISessionEnd) at /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 229.
2525 Apache::DBI             need ping: yes
2526 Apache::DBI             PerlChildInitHandler
DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
Process ID: 0
Session ID: 5471 Serial number: 19146 (DBD ERROR: OCISessionEnd) at /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 229.
2526 Apache::DBI             need ping: yes
2527 Apache::DBI             PerlChildInitHandler
[Fri May 31 20:27:36 2013] [notice] Apache/2.2.23 (Unix) mod_perl/2.0.5 Perl/v5.10.1 configured -- resuming normal operations
[Fri May 31 20:27:36 2013] [info] Server built: Jan 14 2013 20:41:03
[Fri May 31 20:27:36 2013] [debug] prefork.c(1023): AcceptMutex: sysvsem (default: sysvsem)
DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
Process ID: 0
Session ID: 5471 Serial number: 19146 (DBD ERROR: OCISessionEnd) at /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 229.
2527 Apache::DBI             need ping: yes
2529 Apache::DBI             PerlChildInitHandler
2528 Apache::DBI             PerlChildInitHandler
2530 Apache::DBI             PerlChildInitHandler
2531 Apache::DBI             PerlChildInitHandler
DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
Process ID: 0
Session ID: 5471 Serial number: 19146 (DBD ERROR: OCISessionEnd) at /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 229.
2530 Apache::DBI             need ping: yes
DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
Process ID: 0
Session ID: 5471 Serial number: 19146 (DBD ERROR: OCISessionEnd) at /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 229.
2528 Apache::DBI             need ping: yes
DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
Process ID: 0
Session ID: 5471 Serial number: 19146 (DBD ERROR: OCISessionEnd) at /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 229.
DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
Process ID: 0
Session ID: 5471 Serial number: 19146 (DBD ERROR: OCISessionEnd) at /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 229.
2522 Apache::DBI             new connect to '….'
2529 Apache::DBI             need ping: yes
2531 Apache::DBI             need ping: yes
2523 Apache::DBI             new connect to '….'
2525 Apache::DBI             new connect to '….'
2524 Apache::DBI             new connect to '….'
2527 Apache::DBI             new connect to '….'
2526 Apache::DBI             new connect to '….'
2530 Apache::DBI             new connect to '….'
2528 Apache::DBI             new connect to '….'
2529 Apache::DBI             new connect to '….'
2531 Apache::DBI             new connect to '….'

PID 2520 is the very first ancestor. He died shortly after initialization.

PID 2521 is the second ancestor. He became the parent process.

PID 2522 to 2531 are children.

Here is the error at 'apachectl stop':

2531 Apache::DBI             PerlChildExitHandler
2528 Apache::DBI             PerlChildExitHandler
2530 Apache::DBI             PerlChildExitHandler
2529 Apache::DBI             PerlChildExitHandler
2527 Apache::DBI             PerlChildExitHandler
2525 Apache::DBI             PerlChildExitHandler
2526 Apache::DBI             PerlChildExitHandler
2522 Apache::DBI             PerlChildExitHandler
2524 Apache::DBI             PerlChildExitHandler
2523 Apache::DBI             PerlChildExitHandler
[Fri May 31 20:37:16 2013] [info] removed PID file httpd.pid (pid=2521)
[Fri May 31 20:37:16 2013] [notice] caught SIGTERM, shutting down
DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
Process ID: 0
Session ID: 5471 Serial number: 19146 (DBD ERROR: OCISessionEnd) during global destruction.

Are children using same Database Handle?

Does Apache::DBI work right with Apache2+mod_perl2?

Thanks,
- xinhuan

From: Perrin Harkins <ph...@gmail.com>>
Date: Friday, May 31, 2013 10:54 AM
To: Jim Schueler <js...@eloquency.com>>
Cc: Xinhuan Zheng <xz...@christianbook.com>>, "modperl@perl.apache.org<ma...@perl.apache.org>" <mo...@perl.apache.org>>
Subject: Re: Apache::DBI "connection lost contact" error

$Apache::DBI::DEBUG = 2

Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
Well, you are on the modperl list, so that means you. :)

Xinhuan, the error is harmless, but if you're concerned about it I would
try turning on debugging to make sure the connection is not being cached.
 Do this:
$Apache::DBI::DEBUG = 2;

And then watch for a message like this in your log:
skipping connection during server startup

- Perrin


On Fri, May 31, 2013 at 10:33 AM, Jim Schueler <js...@eloquency.com>wrote:

> I'm afraid I'm out of my league.  I just noticed the following comment on
> the Apache::DBI man page:
>
>   Edmund Mergl was the original author of Apache::DBI. It is now supported
>   and maintained by the modperl mailinglist, see the mod_perl documentation
>   for instructions on how to subscribe.
>
>  -Jim
>
>
> On Fri, 31 May 2013, Xinhuan Zheng wrote:
>
>  I believe I am using "my" declaration rather than "local". I also tried
>> explicitly disconnect but still have same issue. Since it only happens in
>> parent/child processes, I don't know a good way to debug parent/child, nor
>> reproducing the same error using a simple program. Can you guys help me
>> with that?
>>
>> Thanks,
>> - xinhuan
>>
>> On 5/31/13 9:02 AM, "Jim Schueler" <js...@eloquency.com> wrote:
>>
>>  Perrin is right.  But fundamentally, I'd say that you're confusing
>>> 'local' and 'my' variable scoping:
>>>
>>>    http://www.perlmonks.org/?**node_id=94007<http://www.perlmonks.org/?node_id=94007>
>>>
>>>  -Jim
>>>
>>> On Fri, 31 May 2013, Perrin Harkins wrote:
>>>
>>>  Try an explicit disconnect() call.
>>>> - Perrin
>>>>
>>>>
>>>> On Thu, May 30, 2013 at 7:46 PM, Xinhuan Zheng
>>>> <xz...@christianbook.com>
>>>> wrote:
>>>>       The db handle is declared local and once it's out of scope, the
>>>>       destroy
>>>>       call will disconnect. But it appears even though variable is out
>>>>       of scope,
>>>>       we still get that error. Don't know why.
>>>>       - xinhuan
>>>>
>>>>       On 5/30/13 8:31 AM, "Jim Schueler" <js...@eloquency.com>
>>>>       wrote:
>>>>
>>>>      >Did this solve your problem?
>>>>      >
>>>>      >  -Jim
>>>>      >
>>>>      >On Wed, 29 May 2013, Perrin Harkins wrote:
>>>>      >
>>>>      >> Hi,
>>>>      >> Apache::DBI is supposed to skip caching if you connect during
>>>>       startup.
>>>>      >>You
>>>>      >> should just need to disconnect your database handle after you
>>>>       finish
>>>>      >>with
>>>>      >> it.  It sounds like you're opening it and then leaving it
>>>>       open.
>>>>      >>
>>>>      >> - Perrin
>>>>      >>
>>>>      >>
>>>>      >> On Wed, May 29, 2013 at 3:24 PM, Xinhuan Zheng
>>>>      >><xz...@christianbook.com>
>>>>      >> wrote:
>>>>      >>       Hi,
>>>>      >>
>>>>      >> I have apache 2.2.23 statically compiled with mod_perl2
>>>>       (prefork).
>>>>      >> perl binary is 5.10.1. In startup.pl file there is call
>>>>      >> Apache::DBI->connect_on_init.
>>>>      >>
>>>>      >> <code>
>>>>      >> use Apache::DBI;
>>>>      >> Apache::DBI->connect_on_init( $DB_DRIVER, $DB_USER,
>>>>       $DB_PASSWORD );
>>>>      >>
>>>>      >> use DBI;
>>>>      >> </code>
>>>>      >>
>>>>      >> I need to call DBI->connect to load some data during server
>>>>       startup
>>>>      >> stage. There is problem with this setup. Whenever apachectl
>>>>      >> startup/shutdown, we got connection error like this:
>>>>      >>
>>>>      >> DBD::Oracle::db DESTROY failed: ORA-03135: connection lost
>>>>       contact
>>>>      >> Process ID: 0
>>>>      >> Session ID: 3252 Serial number: 15131 (DBD ERROR:
>>>>       OCISessionEnd) at
>>>>      >> /usr/local/lib/perl5/site_**perl/5.10.1/Apache/DBI.pm line 228.
>>>>      >>
>>>>      >> I am trying to fix this error. I think it's related to
>>>>       DBI->connect
>>>>      >> in startup.pl. My question is:
>>>>      >>  1. How do I accomplish loading data into database during
>>>>       server
>>>>      >>     startup using Apache::DBI?
>>>>      >>  2. Once data is loaded during server startup, how do I
>>>>       safely destroy
>>>>      >>     this database handle but not affect the children
>>>>       instantiate their
>>>>      >>     database handles?
>>>>      >> Thanks in advance,
>>>>      >>
>>>>      >> Xinhuan
>>>>      >>
>>>>      >>
>>>>      >>
>>>>
>>>>
>>>>
>>>>
>>
>>

Re: Apache::DBI "connection lost contact" error

Posted by Jim Schueler <js...@eloquency.com>.
I'm afraid I'm out of my league.  I just noticed the following comment on 
the Apache::DBI man page:

   Edmund Mergl was the original author of Apache::DBI. It is now supported
   and maintained by the modperl mailinglist, see the mod_perl documentation
   for instructions on how to subscribe.

  -Jim

On Fri, 31 May 2013, Xinhuan Zheng wrote:

> I believe I am using "my" declaration rather than "local". I also tried
> explicitly disconnect but still have same issue. Since it only happens in
> parent/child processes, I don't know a good way to debug parent/child, nor
> reproducing the same error using a simple program. Can you guys help me
> with that?
>
> Thanks,
> - xinhuan
>
> On 5/31/13 9:02 AM, "Jim Schueler" <js...@eloquency.com> wrote:
>
>> Perrin is right.  But fundamentally, I'd say that you're confusing
>> 'local' and 'my' variable scoping:
>>
>>    http://www.perlmonks.org/?node_id=94007
>>
>>  -Jim
>>
>> On Fri, 31 May 2013, Perrin Harkins wrote:
>>
>>> Try an explicit disconnect() call.
>>> - Perrin
>>>
>>>
>>> On Thu, May 30, 2013 at 7:46 PM, Xinhuan Zheng
>>> <xz...@christianbook.com>
>>> wrote:
>>>       The db handle is declared local and once it's out of scope, the
>>>       destroy
>>>       call will disconnect. But it appears even though variable is out
>>>       of scope,
>>>       we still get that error. Don't know why.
>>>       - xinhuan
>>>
>>>       On 5/30/13 8:31 AM, "Jim Schueler" <js...@eloquency.com>
>>>       wrote:
>>>
>>>      >Did this solve your problem?
>>>      >
>>>      >  -Jim
>>>      >
>>>      >On Wed, 29 May 2013, Perrin Harkins wrote:
>>>      >
>>>      >> Hi,
>>>      >> Apache::DBI is supposed to skip caching if you connect during
>>>       startup.
>>>      >>You
>>>      >> should just need to disconnect your database handle after you
>>>       finish
>>>      >>with
>>>      >> it.  It sounds like you're opening it and then leaving it
>>>       open.
>>>      >>
>>>      >> - Perrin
>>>      >>
>>>      >>
>>>      >> On Wed, May 29, 2013 at 3:24 PM, Xinhuan Zheng
>>>      >><xz...@christianbook.com>
>>>      >> wrote:
>>>      >>       Hi,
>>>      >>
>>>      >> I have apache 2.2.23 statically compiled with mod_perl2
>>>       (prefork).
>>>      >> perl binary is 5.10.1. In startup.pl file there is call
>>>      >> Apache::DBI->connect_on_init.
>>>      >>
>>>      >> <code>
>>>      >> use Apache::DBI;
>>>      >> Apache::DBI->connect_on_init( $DB_DRIVER, $DB_USER,
>>>       $DB_PASSWORD );
>>>      >>
>>>      >> use DBI;
>>>      >> </code>
>>>      >>
>>>      >> I need to call DBI->connect to load some data during server
>>>       startup
>>>      >> stage. There is problem with this setup. Whenever apachectl
>>>      >> startup/shutdown, we got connection error like this:
>>>      >>
>>>      >> DBD::Oracle::db DESTROY failed: ORA-03135: connection lost
>>>       contact
>>>      >> Process ID: 0
>>>      >> Session ID: 3252 Serial number: 15131 (DBD ERROR:
>>>       OCISessionEnd) at
>>>      >> /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 228.
>>>      >>
>>>      >> I am trying to fix this error. I think it's related to
>>>       DBI->connect
>>>      >> in startup.pl. My question is:
>>>      >>  1. How do I accomplish loading data into database during
>>>       server
>>>      >>     startup using Apache::DBI?
>>>      >>  2. Once data is loaded during server startup, how do I
>>>       safely destroy
>>>      >>     this database handle but not affect the children
>>>       instantiate their
>>>      >>     database handles?
>>>      >> Thanks in advance,
>>>      >>
>>>      >> Xinhuan
>>>      >>
>>>      >>
>>>      >>
>>>
>>>
>>>
>
>

Re: Apache::DBI "connection lost contact" error

Posted by Xinhuan Zheng <xz...@christianbook.com>.
I believe I am using "my" declaration rather than "local". I also tried
explicitly disconnect but still have same issue. Since it only happens in
parent/child processes, I don't know a good way to debug parent/child, nor
reproducing the same error using a simple program. Can you guys help me
with that?

Thanks,
- xinhuan

On 5/31/13 9:02 AM, "Jim Schueler" <js...@eloquency.com> wrote:

>Perrin is right.  But fundamentally, I'd say that you're confusing
>'local' and 'my' variable scoping:
>
>    http://www.perlmonks.org/?node_id=94007
>
>  -Jim
>
>On Fri, 31 May 2013, Perrin Harkins wrote:
>
>> Try an explicit disconnect() call.
>> - Perrin
>> 
>> 
>> On Thu, May 30, 2013 at 7:46 PM, Xinhuan Zheng
>><xz...@christianbook.com>
>> wrote:
>>       The db handle is declared local and once it's out of scope, the
>>       destroy
>>       call will disconnect. But it appears even though variable is out
>>       of scope,
>>       we still get that error. Don't know why.
>>       - xinhuan
>>
>>       On 5/30/13 8:31 AM, "Jim Schueler" <js...@eloquency.com>
>>       wrote:
>>
>>       >Did this solve your problem?
>>       >
>>       >  -Jim
>>       >
>>       >On Wed, 29 May 2013, Perrin Harkins wrote:
>>       >
>>       >> Hi,
>>       >> Apache::DBI is supposed to skip caching if you connect during
>>       startup.
>>       >>You
>>       >> should just need to disconnect your database handle after you
>>       finish
>>       >>with
>>       >> it.  It sounds like you're opening it and then leaving it
>>       open.
>>       >>
>>       >> - Perrin
>>       >>
>>       >>
>>       >> On Wed, May 29, 2013 at 3:24 PM, Xinhuan Zheng
>>       >><xz...@christianbook.com>
>>       >> wrote:
>>       >>       Hi,
>>       >>
>>       >> I have apache 2.2.23 statically compiled with mod_perl2
>>       (prefork).
>>       >> perl binary is 5.10.1. In startup.pl file there is call
>>       >> Apache::DBI->connect_on_init.
>>       >>
>>       >> <code>
>>       >> use Apache::DBI;
>>       >> Apache::DBI->connect_on_init( $DB_DRIVER, $DB_USER,
>>       $DB_PASSWORD );
>>       >>
>>       >> use DBI;
>>       >> </code>
>>       >>
>>       >> I need to call DBI->connect to load some data during server
>>       startup
>>       >> stage. There is problem with this setup. Whenever apachectl
>>       >> startup/shutdown, we got connection error like this:
>>       >>
>>       >> DBD::Oracle::db DESTROY failed: ORA-03135: connection lost
>>       contact
>>       >> Process ID: 0
>>       >> Session ID: 3252 Serial number: 15131 (DBD ERROR:
>>       OCISessionEnd) at
>>       >> /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 228.
>>       >>
>>       >> I am trying to fix this error. I think it's related to
>>       DBI->connect
>>       >> in startup.pl. My question is:
>>       >>  1. How do I accomplish loading data into database during
>>       server
>>       >>     startup using Apache::DBI?
>>       >>  2. Once data is loaded during server startup, how do I
>>       safely destroy
>>       >>     this database handle but not affect the children
>>       instantiate their
>>       >>     database handles?
>>       >> Thanks in advance,
>>       >>
>>       >> Xinhuan
>>       >>
>>       >>
>>       >>
>> 
>> 
>> 


Re: Apache::DBI "connection lost contact" error

Posted by Jim Schueler <js...@eloquency.com>.
Perrin is right.  But fundamentally, I'd say that you're confusing 
'local' and 'my' variable scoping:

    http://www.perlmonks.org/?node_id=94007

  -Jim

On Fri, 31 May 2013, Perrin Harkins wrote:

> Try an explicit disconnect() call.
> - Perrin
> 
> 
> On Thu, May 30, 2013 at 7:46 PM, Xinhuan Zheng <xz...@christianbook.com>
> wrote:
>       The db handle is declared local and once it's out of scope, the
>       destroy
>       call will disconnect. But it appears even though variable is out
>       of scope,
>       we still get that error. Don't know why.
>       - xinhuan
>
>       On 5/30/13 8:31 AM, "Jim Schueler" <js...@eloquency.com>
>       wrote:
>
>       >Did this solve your problem?
>       >
>       >  -Jim
>       >
>       >On Wed, 29 May 2013, Perrin Harkins wrote:
>       >
>       >> Hi,
>       >> Apache::DBI is supposed to skip caching if you connect during
>       startup.
>       >>You
>       >> should just need to disconnect your database handle after you
>       finish
>       >>with
>       >> it.  It sounds like you're opening it and then leaving it
>       open.
>       >>
>       >> - Perrin
>       >>
>       >>
>       >> On Wed, May 29, 2013 at 3:24 PM, Xinhuan Zheng
>       >><xz...@christianbook.com>
>       >> wrote:
>       >>       Hi,
>       >>
>       >> I have apache 2.2.23 statically compiled with mod_perl2
>       (prefork).
>       >> perl binary is 5.10.1. In startup.pl file there is call
>       >> Apache::DBI->connect_on_init.
>       >>
>       >> <code>
>       >> use Apache::DBI;
>       >> Apache::DBI->connect_on_init( $DB_DRIVER, $DB_USER,
>       $DB_PASSWORD );
>       >>
>       >> use DBI;
>       >> </code>
>       >>
>       >> I need to call DBI->connect to load some data during server
>       startup
>       >> stage. There is problem with this setup. Whenever apachectl
>       >> startup/shutdown, we got connection error like this:
>       >>
>       >> DBD::Oracle::db DESTROY failed: ORA-03135: connection lost
>       contact
>       >> Process ID: 0
>       >> Session ID: 3252 Serial number: 15131 (DBD ERROR:
>       OCISessionEnd) at
>       >> /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 228.
>       >>
>       >> I am trying to fix this error. I think it's related to
>       DBI->connect
>       >> in startup.pl. My question is:
>       >>  1. How do I accomplish loading data into database during
>       server
>       >>     startup using Apache::DBI?
>       >>  2. Once data is loaded during server startup, how do I
>       safely destroy
>       >>     this database handle but not affect the children
>       instantiate their
>       >>     database handles?
>       >> Thanks in advance,
>       >>
>       >> Xinhuan
>       >>
>       >>
>       >>
> 
> 
> 
>

Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
Try an explicit disconnect() call.

- Perrin


On Thu, May 30, 2013 at 7:46 PM, Xinhuan Zheng <xz...@christianbook.com>wrote:

> The db handle is declared local and once it's out of scope, the destroy
> call will disconnect. But it appears even though variable is out of scope,
> we still get that error. Don't know why.
> - xinhuan
>
> On 5/30/13 8:31 AM, "Jim Schueler" <js...@eloquency.com> wrote:
>
> >Did this solve your problem?
> >
> >  -Jim
> >
> >On Wed, 29 May 2013, Perrin Harkins wrote:
> >
> >> Hi,
> >> Apache::DBI is supposed to skip caching if you connect during startup.
> >>You
> >> should just need to disconnect your database handle after you finish
> >>with
> >> it.  It sounds like you're opening it and then leaving it open.
> >>
> >> - Perrin
> >>
> >>
> >> On Wed, May 29, 2013 at 3:24 PM, Xinhuan Zheng
> >><xz...@christianbook.com>
> >> wrote:
> >>       Hi,
> >>
> >> I have apache 2.2.23 statically compiled with mod_perl2 (prefork).
> >> perl binary is 5.10.1. In startup.pl file there is call
> >> Apache::DBI->connect_on_init.
> >>
> >> <code>
> >> use Apache::DBI;
> >> Apache::DBI->connect_on_init( $DB_DRIVER, $DB_USER, $DB_PASSWORD );
> >>
> >> use DBI;
> >> </code>
> >>
> >> I need to call DBI->connect to load some data during server startup
> >> stage. There is problem with this setup. Whenever apachectl
> >> startup/shutdown, we got connection error like this:
> >>
> >> DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
> >> Process ID: 0
> >> Session ID: 3252 Serial number: 15131 (DBD ERROR: OCISessionEnd) at
> >> /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 228.
> >>
> >> I am trying to fix this error. I think it's related to DBI->connect
> >> in startup.pl. My question is:
> >>  1. How do I accomplish loading data into database during server
> >>     startup using Apache::DBI?
> >>  2. Once data is loaded during server startup, how do I safely destroy
> >>     this database handle but not affect the children instantiate their
> >>     database handles?
> >> Thanks in advance,
> >>
> >> Xinhuan
> >>
> >>
> >>
>
>

Re: Apache::DBI "connection lost contact" error

Posted by Xinhuan Zheng <xz...@christianbook.com>.
The db handle is declared local and once it's out of scope, the destroy
call will disconnect. But it appears even though variable is out of scope,
we still get that error. Don't know why.
- xinhuan

On 5/30/13 8:31 AM, "Jim Schueler" <js...@eloquency.com> wrote:

>Did this solve your problem?
>
>  -Jim
>
>On Wed, 29 May 2013, Perrin Harkins wrote:
>
>> Hi,
>> Apache::DBI is supposed to skip caching if you connect during startup.
>>You
>> should just need to disconnect your database handle after you finish
>>with
>> it.  It sounds like you're opening it and then leaving it open.
>> 
>> - Perrin
>> 
>> 
>> On Wed, May 29, 2013 at 3:24 PM, Xinhuan Zheng
>><xz...@christianbook.com>
>> wrote:
>>       Hi,
>> 
>> I have apache 2.2.23 statically compiled with mod_perl2 (prefork).
>> perl binary is 5.10.1. In startup.pl file there is call
>> Apache::DBI->connect_on_init.
>> 
>> <code>
>> use Apache::DBI;
>> Apache::DBI->connect_on_init( $DB_DRIVER, $DB_USER, $DB_PASSWORD );
>> 
>> use DBI;
>> </code>
>> 
>> I need to call DBI->connect to load some data during server startup
>> stage. There is problem with this setup. Whenever apachectl
>> startup/shutdown, we got connection error like this:
>> 
>> DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
>> Process ID: 0
>> Session ID: 3252 Serial number: 15131 (DBD ERROR: OCISessionEnd) at
>> /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 228.
>> 
>> I am trying to fix this error. I think it's related to DBI->connect
>> in startup.pl. My question is:
>>  1. How do I accomplish loading data into database during server
>>     startup using Apache::DBI?
>>  2. Once data is loaded during server startup, how do I safely destroy
>>     this database handle but not affect the children instantiate their
>>     database handles?
>> Thanks in advance,
>> 
>> Xinhuan
>> 
>> 
>> 


Re: Apache::DBI "connection lost contact" error

Posted by Jim Schueler <js...@eloquency.com>.
Did this solve your problem?

  -Jim

On Wed, 29 May 2013, Perrin Harkins wrote:

> Hi,
> Apache::DBI is supposed to skip caching if you connect during startup.  You
> should just need to disconnect your database handle after you finish with
> it.  It sounds like you're opening it and then leaving it open.
> 
> - Perrin
> 
> 
> On Wed, May 29, 2013 at 3:24 PM, Xinhuan Zheng <xz...@christianbook.com>
> wrote:
>       Hi,
> 
> I have apache 2.2.23 statically compiled with mod_perl2 (prefork).
> perl binary is 5.10.1. In startup.pl file there is call
> Apache::DBI->connect_on_init.
> 
> <code>
> use Apache::DBI;
> Apache::DBI->connect_on_init( $DB_DRIVER, $DB_USER, $DB_PASSWORD );
> 
> use DBI;
> </code>
> 
> I need to call DBI->connect to load some data during server startup
> stage. There is problem with this setup. Whenever apachectl
> startup/shutdown, we got connection error like this:
> 
> DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
> Process ID: 0
> Session ID: 3252 Serial number: 15131 (DBD ERROR: OCISessionEnd) at
> /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 228.
> 
> I am trying to fix this error. I think it's related to DBI->connect
> in startup.pl. My question is:
>  1. How do I accomplish loading data into database during server
>     startup using Apache::DBI?  
>  2. Once data is loaded during server startup, how do I safely destroy
>     this database handle but not affect the children instantiate their
>     database handles?
> Thanks in advance,
> 
> Xinhuan
> 
> 
> 
>

Re: Apache::DBI "connection lost contact" error

Posted by Perrin Harkins <ph...@gmail.com>.
Hi,

Apache::DBI is supposed to skip caching if you connect during startup.  You
should just need to disconnect your database handle after you finish with
it.  It sounds like you're opening it and then leaving it open.

- Perrin


On Wed, May 29, 2013 at 3:24 PM, Xinhuan Zheng <xz...@christianbook.com>wrote:

>  Hi,
>
>  I have apache 2.2.23 statically compiled with mod_perl2 (prefork). perl
> binary is 5.10.1. In startup.pl file there is call
> Apache::DBI->connect_on_init.
>
>  <code>
>  use Apache::DBI;
> Apache::DBI->connect_on_init( $DB_DRIVER, $DB_USER, $DB_PASSWORD );
>
>  use DBI;
> </code>
>
>  I need to call DBI->connect to load some data during server startup
> stage. There is problem with this setup. Whenever apachectl
> startup/shutdown, we got connection error like this:
>
>  DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
> Process ID: 0
> Session ID: 3252 Serial number: 15131 (DBD ERROR: OCISessionEnd) at
> /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 228.
>
>  I am trying to fix this error. I think it's related to DBI->connect in
> startup.pl. My question is:
>
>    1. How do I accomplish loading data into database during server
>    startup using Apache::DBI?
>    2. Once data is loaded during server startup, how do I safely destroy
>    this database handle but not affect the children instantiate their database
>    handles?
>
> Thanks in advance,
>
>  Xinhuan
>

Re: Apache::DBI "connection lost contact" error

Posted by Jim Schueler <js...@eloquency.com>.
A few questions:

   Precisely when do you get this error?  When startup.pl exits or before?

   Can you send a copy of your startup.pl file?

   You get exactly the same error on startup and shutdown?

   If PerlRequire startup.pl is commented out, do you still get errors?

   Do you get errors when a child starts or ends?  Or just the main
   process?

   Why does your error message say Process ID=0?  Are other messages
   different?  Does the error show up on the command line or in the log?

  -Jim

On Wed, 29 May 2013, Xinhuan Zheng wrote:

> Hi,
> 
> I have apache 2.2.23 statically compiled with mod_perl2 (prefork). perl
> binary is 5.10.1. In startup.pl file there is call
> Apache::DBI->connect_on_init.
> 
> <code>
> use Apache::DBI;
> Apache::DBI->connect_on_init( $DB_DRIVER, $DB_USER, $DB_PASSWORD );
> 
> use DBI;
> </code>
> 
> I need to call DBI->connect to load some data during server startup stage.
> There is problem with this setup. Whenever apachectl startup/shutdown, we
> got connection error like this:
> 
> DBD::Oracle::db DESTROY failed: ORA-03135: connection lost contact
> Process ID: 0
> Session ID: 3252 Serial number: 15131 (DBD ERROR: OCISessionEnd) at
> /usr/local/lib/perl5/site_perl/5.10.1/Apache/DBI.pm line 228.
> 
> I am trying to fix this error. I think it's related to DBI->connect
> in startup.pl. My question is:
>  1. How do I accomplish loading data into database during server startup
>     using Apache::DBI?  
>  2. Once data is loaded during server startup, how do I safely destroy this
>     database handle but not affect the children instantiate their database
>     handles?
> Thanks in advance,
> 
> Xinhuan
> 
>