Hello,

while I begin to  write some test perl script to test mod_perl after  read
necessary document,still get folloing error.please correct my error(maybe
silly one)

Following is my problem while using mod_perl.
apache 1.3.3 + mysql 2.22 + RH  6.0 + modperl 1.21 + perl 5.005_3
Modperl build w/ everything=1
apache conf:

Alias /perl/            /usr/local/apache/share/cgi-bin/
PerlFreshRestart        On
PerlRequire             /usr/local/apache/share/cgi-bin/include/startup.pl
#PerlSetupEnv OFF
PerlSendHeader OFF
#DBI_TRACE "2=/tmp/dbitrace.log"
PerlModule Apache::DBI

<Location /perl>
SetHandler  perl-script
PerlHandler Apache::Registry
# PerlSendHeader On
Options +ExecCGI
</Location>

<Location /perl-status>
SetHandler  perl-script
PerlHandler Apache::Status
</Location>
+++++++++++++

and the startup.pl is below:
use CGI;
use Apache::DBI;
use strict;
Apache::DBI->connect_on_init
("DBI:mysql:uwang::localhost",
"uwang",
"uwang",
{
PrintError => 1, # warn() on errors
RaiseError => 0, # don't die on error
AutoCommit => 1 # commit executes immediately
}
);
1;
++++++++++++++++++++
I did read the mod_perl,cgi-to_mod_perl,mod_perl_traps and
perl.apche.org/guide before coding.

now weird problem is:
1. since I use connect_on_init and set dbi trace,I think once the apache
server start,it should automatically create a dbh connection,aka dbh,is it?
but i never see this info in /tmp/dbitrace.log  .why?

2.dbitrace.log did log any connection  made by my mod_perl script.something
like below:
DBI 1.06 dispatch trace level set to 2
-> DBI->Apache::DBI::connect(DBI:mysql:uwang::localhost, uwang, uwang,
HASH(0x830d900))
<- FETCH= 'mysql' ('Name' from cache) at DBI.pm line 64.
-> ping for DBD::mysql::db (Apache::DBI::db=HASH(0x821db30)~0x821db00)
<- ping= 1 at DBI.pm line 112.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-> STORE for DBD::mysql::db (DBI::db=HASH(0x821db00)~INNER 'RaiseError' 0)
<- STORE= 1 at DBI.pm line 400.
-> STORE for DBD::mysql::db (DBI::db=HASH(0x821db00)~INNER 'PrintError' 1)
<- STORE= 1 at DBI.pm line 400.
-> STORE for DBD::mysql::db (DBI::db=HASH(0x821db00)~INNER 'AutoCommit' 1)
<- STORE= 1 at DBI.pm line 400.
<- connect= Apache::DBI::db=HASH(0x821db30)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Now here is 2 questoin. first is,does the ping=1... line means what the
guide document said "it will ping if a exist dbh still   alive" ?so does the
ping=1 means "Yes,I've find a exist dbh and it's ok"?since these info is
generate by my first connection in my script,does it means it's ping the dbh
create by the apache::DBI connect_on_init?butjust the connect_on_init not
logged? the 2nd is,the connect line, does this means,"ok,I will tell  the
mod_perl script to use a exist dbh HASH(0x821db30)"?  if so,means the script
is REUSE the dbh as we expect.Also,I am  quite sure  because when I reload
the script again and find out that above log info  occur again,yeah,so does
it means the 2nd connection still reuse the same dbh?
I am happy at first but later all changed. TO test if its true,I use ab to
do the test,I run with:
./httpd -X
then
./ab -n 10 -c 10 myscript.pl

during the runtime,I use mysaladmin processlist to see it it REALLY just
create one connection.and :-----( NO,NOT at all.tens of mysql connection
there...why? Do I understand above log info  wrongly or config the
httpd.conf file wrong?

Ok,with above configuration,another problem there.my script just do one
thing,"select username from user where id=1".the problem is funny.in the
first time I run the script,the homepage generated like :

test blah blah blah----------->just one line

Ok,then I reload it via hit the Refresh button of browser,ok now it looks
like:
test blah blah blah----------->just one line
test blah blah blah----------->the 2nd  line!!!

so when you  refresh again,just add another SAME line.Seems the sql query
was cached??when I hit the  REFRESH button,its funny that  it not only
execute the sql query in this request,but also execute the one I execute
before.so when you refresh 10 times,you got 10 line.I am blur and I didn't
think I use any sentence could make this problem occur.


Also,I set the StartServer is 15 in  httpd.conf.before I startup apache,it
will start 15 apache child.ok,before start apache,there is just 1 mysqld
there,as soon as I start up apache,it 's 16 now.yes,each apache child
establish a mysql connection,seems the connect_on_init works,but now what I
want?



Thank you all very much,

Vincent

______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com?sr=mc.mk.mcm.tag001

Reply via email to