Apache::DBI connect_on_init problem
Apache::DBI connect_on_init problem
am 17.04.2010 21:27:40 von jira
Hello,
I'm trying to prestart db connection. But Apache::DBI->connect_on_init
is not working. Gives no error, but db connection is not made.
Setting $Apache::DBI::DEBUG = 2 indicates that ChildInitHandler runs.
I tried to create my custom ChildInitHandler and start db connection
from it but it also has no effect.
It also seems as if the handler was silently aborted after the connect call.
I inserted debugging print before and after the connect call. In the
Postgres log I can see a connection made and immediately terminated.
So now I'm quite helpless as what to do.
Re: Apache::DBI connect_on_init problem
am 17.04.2010 22:09:24 von jira
On 17.4.2010 22:22, Chris Bennett wrote:
> On 04/17/10 14:27, Jiri Pavlovsky wrote:
>> Hello,
>>
>> I'm trying to prestart db connection. But Apache::DBI->connect_on_init
>> is not working. Gives no error, but db connection is not made.
>> Setting $Apache::DBI::DEBUG = 2 indicates that ChildInitHandler runs.
>>
>> I tried to create my custom ChildInitHandler and start db connection
>> from it but it also has no effect.
>> It also seems as if the handler was silently aborted after the connect
>> call.
>> I inserted debugging print before and after the connect call. In the
>> Postgres log I can see a connection made and immediately terminated.
>>
>>
>> So now I'm quite helpless as what to do.
>>
>
> I use Apache::DBI and connect_on_init.
> What are your full details? Using startup.pl?
> what values for initial connection?
Hello,
my start-up.pl below. I try to setup two connections.
In Apache log I see several lines like:
13121 Apache::DBI PerlChildInitHandler
13121 Apache::DBI push PerlChildExitHandler
No errors. But in Postgres log I can see several very short connections
as the first user. So maybe it is connecting and then it quits?
Thats all I could find out.
Thanks
----------------------------------------------
#!/usr/bin/perl -w
use strict;
use Apache::DBI;
$Apache::DBI::DEBUG = 2;
DBI->install_driver("Pg");
Apache::DBI->connect_on_init("dbi:Pg:dbname=p69",
"user",
"pass",
{
PrintError => 1, # warn() on errors
RaiseError => 0, # don't die on error
AutoCommit => 1, # commit executes immediately
pg_enable_utf8 => 1,
}
);
Apache::DBI->connect_on_init("dbi:Pg:dbname=p69",
"another",
"pass",
{
PrintError => 1, # warn() on errors
RaiseError => 0, # don't die on error
AutoCommit => 1, # commit executes immediately
pg_enable_utf8 => 1,
}
);
Re: Apache::DBI connect_on_init problem
am 17.04.2010 22:15:59 von Fred Moyer
On Sat, Apr 17, 2010 at 1:09 PM, Jiri Pavlovsky
wrote:> =A0Apache::DBI->connect_on_init("dbi:Pg:dbname=3Dp69",
> =A0 =A0"user",
> =A0 =A0"pass",
> =A0 =A0{
> =A0 =A0 =A0PrintError =3D> 1, # warn() on errors
> =A0 =A0 =A0RaiseError =3D> 0, # don't die on error
> =A0 =A0 =A0AutoCommit =3D> 1, # commit executes immediately
> =A0 =A0 =A0pg_enable_utf8 =3D> 1,
> =A0 =A0}
> =A0);
>
> =A0Apache::DBI->connect_on_init("dbi:Pg:dbname=3Dp69",
> =A0 =A0"another",
> =A0 =A0"pass",
> =A0 =A0{
> =A0 =A0 =A0PrintError =3D> 1, # warn() on errors
> =A0 =A0 =A0RaiseError =3D> 0, # don't die on error
> =A0 =A0 =A0AutoCommit =3D> 1, # commit executes immediately
> =A0 =A0 =A0pg_enable_utf8 =3D> 1,
> =A0 =A0}
> =A0);
Why do you call connect_on_init twice with different parameters? If
anything stands out as causing the problem, that would come to my mind
as the first thing.
Re: Apache::DBI connect_on_init problem
am 17.04.2010 22:22:14 von Chris Bennett
On 04/17/10 14:27, Jiri Pavlovsky wrote:
> Hello,
>
> I'm trying to prestart db connection. But Apache::DBI->connect_on_init
> is not working. Gives no error, but db connection is not made.
> Setting $Apache::DBI::DEBUG = 2 indicates that ChildInitHandler runs.
>
> I tried to create my custom ChildInitHandler and start db connection
> from it but it also has no effect.
> It also seems as if the handler was silently aborted after the connect
> call.
> I inserted debugging print before and after the connect call. In the
> Postgres log I can see a connection made and immediately terminated.
>
>
> So now I'm quite helpless as what to do.
>
I use Apache::DBI and connect_on_init.
What are your full details? Using startup.pl?
what values for initial connection?
Re: Apache::DBI connect_on_init problem
am 17.04.2010 22:42:51 von Chris Bennett
On 04/17/10 15:09, Jiri Pavlovsky wrote:
> On 17.4.2010 22:22, Chris Bennett wrote:
>> On 04/17/10 14:27, Jiri Pavlovsky wrote:
>>> Hello,
>>>
>>> I'm trying to prestart db connection. But Apache::DBI->connect_on_init
>>> is not working. Gives no error, but db connection is not made.
>>> Setting $Apache::DBI::DEBUG = 2 indicates that ChildInitHandler runs.
>>>
>>> I tried to create my custom ChildInitHandler and start db connection
>>> from it but it also has no effect.
>>> It also seems as if the handler was silently aborted after the connect
>>> call.
>>> I inserted debugging print before and after the connect call. In the
>>> Postgres log I can see a connection made and immediately terminated.
>>>
>>>
>>> So now I'm quite helpless as what to do.
>>>
>>
>> I use Apache::DBI and connect_on_init.
>> What are your full details? Using startup.pl?
>> what values for initial connection?
>
>
>
> Hello,
>
> my start-up.pl below. I try to setup two connections.
>
> In Apache log I see several lines like:
> 13121 Apache::DBI PerlChildInitHandler
> 13121 Apache::DBI push PerlChildExitHandler
>
> No errors. But in Postgres log I can see several very short connections
> as the first user. So maybe it is connecting and then it quits?
>
> Thats all I could find out.
>
> Thanks
>
>
>
> ----------------------------------------------
>
>
>
> #!/usr/bin/perl -w
>
>
>
> use strict;
> use Apache::DBI;
>
> $Apache::DBI::DEBUG = 2;
>
> DBI->install_driver("Pg");
>
>
>
>
> Apache::DBI->connect_on_init("dbi:Pg:dbname=p69",
> "user",
> "pass",
> {
> PrintError => 1, # warn() on errors
> RaiseError => 0, # don't die on error
> AutoCommit => 1, # commit executes immediately
> pg_enable_utf8 => 1,
> }
> );
>
> Apache::DBI->connect_on_init("dbi:Pg:dbname=p69",
> "another",
> "pass",
> {
> PrintError => 1, # warn() on errors
> RaiseError => 0, # don't die on error
> AutoCommit => 1, # commit executes immediately
> pg_enable_utf8 => 1,
> }
> );
>
>
Oh, this is your error. You may only use Apache::DBI_connect_on_init for
ONE connection, which stays up and running. Use your more important one
(for speed) for this.
You may also have other connections, but these will reconnect-disconnect
each time
Use the following for those:
tack in a dbi_connect_method => 'connect' for these other ones
Re: Apache::DBI connect_on_init problem
am 17.04.2010 23:21:29 von jira
On 17.4.2010 22:42, Chris Bennett wrote:
>
> Oh, this is your error. You may only use Apache::DBI_connect_on_init for
> ONE connection, which stays up and running. Use your more important one
> (for speed) for this.
This doesn't seem to make difference. It doesn't work even when making
only one connection. The connection is not made.
I wanted to make two, because I have two apps. One is frequently used
and so the db connection is made from the app short after spawning the
child anyway.
The other one is seldom so there is a overhead every time request comes.
What seems to work though is to create both connection sin the first app.
Re: Apache::DBI connect_on_init problem
am 17.04.2010 23:49:24 von jira
On 17.4.2010 23:21, Jiri Pavlovsky wrote:
> On 17.4.2010 22:42, Chris Bennett wrote:
>>
>> Oh, this is your error. You may only use Apache::DBI_connect_on_init for
>> ONE connection, which stays up and running. Use your more important one
>> (for speed) for this.
>
>
>
> This doesn't seem to make difference. It doesn't work even when making
> only one connection. The connection is not made.
>
> I wanted to make two, because I have two apps. One is frequently used
> and so the db connection is made from the app short after spawning the
> child anyway.
>
> The other one is seldom so there is a overhead every time request comes.
>
> What seems to work though is to create both connection sin the first app.
>
UPDATE: My problem was solved by upgrading Apache::DBI to 1.08. Yes, I
should have done that first.
I can even make two connections from startup.pl.
Re: Apache::DBI connect_on_init problem
am 19.04.2010 17:25:20 von Perrin Harkins
On Sat, Apr 17, 2010 at 4:42 PM, Chris Bennett
wrote:
> You may also have other connections, but these will reconnect-disconnect
> each time
For the record, Apache::DBI will work with any number of connections,
keeping them persistent. It's also correct to call connect_on_init
multiple times. It just pushes the parameters onto a list of
connections to open.
> tack in a dbi_connect_method =3D> 'connect' =A0for these other ones
You can do that for connections that you don't want to be persistent.
- Perrin