[prev in list] [next in list] [prev in thread] [next in thread] 

List:       msqlperl
Subject:    Re: Msql->connect (from different users)
From:       "Andreas Koenig" <k () anna ! in-berlin ! de>
Date:       1997-02-04 0:58:13
[Download RAW message or body]

>>>>> Zeus  writes:

 zeus>   When two people try to post at the same time, they'll often get an
 zeus> error when my script executes the Msql->connect command (with no
 zeus> arguments, i.e. connecting to the local socket).  Msql->connect will
 zeus> return an undef() value for one of them.

 zeus>   However, I always thought that Msql supported multiple connections without
 zeus> any problem.

That's right, about 25 of them.
 
 zeus>               I investigated this a little further, and found the following.

 zeus> *  If I start the standard msql query program distributed with mSQL
 zeus> (from my user account) and leave it sitting at the prompt, then ANY
 zeus> attempt to access the mSQL database from my Perl cgi-bin script (which
 zeus> runs under "nobody" privileges) will FAIL (in the Msql->connect command).

I do not recall that I have ever read such a bug report.

 zeus> * If I do the same with pmsql (distributed with msqlperl), then the
 zeus> cgi-bin scripts seem to work OK (i.e. Msql->connect succeeds) while
 zeus> the program is open. My understanding is that pmsql explicitly closes
 zeus> the connection to the database, while msql leaves it open.

That's right.

 zeus> *  However, if I run two copies of msql from two different windows, then
 zeus> things seem to work fine.  

 zeus> * I've found that if I try to call Msql->connect twice inside the same
 zeus> cgi-bin script (I am using this in a global variable context inside my
 zeus> Perl scripts by the way, so I guess this is strictly a programming
 zeus> error), it will always fail the second time.

This is not a programming error, you can call Msql->connect as often
as you please within a program:

% perl -MMsql -le ' 
$i=100;
while ($i--){
    $q = Msql->connect or warn "$q: failed";
}
'

 zeus>   My questions are the following

 zeus> Q: What restrictions do mSQL and msqlperl place on opening
 zeus> connections to the same host (via a socket) and database?

The exact number is in msql_priv.h. Mine says

#define MAX_CON         24              /* Max connections */

 zeus> Q: Is it possible for two different users (in my case, my own username
 zeus> and the "nobody" user associated with running the cgi-bin scripts) to
 zeus> both call Msql->connect and leave the connection open?  Is this same
 zeus> compile time problem with Msql that I should talk to my hosting site
 zeus> about??

I guess, compile time problem. Maybe at the time you were testing
there were some stale connections open to the database and restarting
the msqld would have helped? Unfortunately there's no way to query the
msqld how many handles it has open at any one time, all you can try is
shutting down the server and start it again.

 zeus> Q: If two different cgi-bin scripts both try to call Msql->connect, 
 zeus> will they fail if one of the other scripts already has the connection 
 zeus> open?

No.

 zeus> Thanks for any help... I know this has been a long question.

Answer's shorter, hope it helps,
andreas

 zeus> Cheers

 zeus> Evan.
----------------------------------------------------------------------
To unsubscribe from this list send a message containing "unsubscribe"
to msqlperl-request@franz.ww.tu-berlin.de

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic