| Author |
Persistent Connection Question
|
|
| Dumbass 2005-04-16, 3:56 pm |
| Hello all,
Sorry if you are getting this twice I am not sure if my other one
actually made it or not.
I know that this wouldn't be an issue with a regular connection but
using persistent connection suppose I have script.php and there are 2
instances running.
If I do an INSERT followed by mysql_insert_id() in instance1, but
between those 2 statments instance2 does an INSERT, would this introduce
a kind of race condition where instance1 would get the insert id of
instance2?
And the same thing with mysql_select_db(). If instance1 selects
databaseA, and instance2 runs a SELECT statement thinking it is using
databaseB wouldn't that cause an error?
TIA,
Me
| |
| Norman Peelman 2005-04-17, 3:57 am |
| "Dumbass" <blah@hotmail.com> wrote in message
news:1162l1sa3pujo12@corp.supernews.com...
> Hello all,
>
> Sorry if you are getting this twice I am not sure if my other one
> actually made it or not.
>
> I know that this wouldn't be an issue with a regular connection but
> using persistent connection suppose I have script.php and there are 2
> instances running.
>
> If I do an INSERT followed by mysql_insert_id() in instance1, but
> between those 2 statments instance2 does an INSERT, would this introduce
> a kind of race condition where instance1 would get the insert id of
> instance2?
>
> And the same thing with mysql_select_db(). If instance1 selects
> databaseA, and instance2 runs a SELECT statement thinking it is using
> databaseB wouldn't that cause an error?
>
> TIA,
> Me
The answers to your questions are 'no', each instance will receive the
insert id associated with its connection id and neither will trip up over
which database the other is currently accessing...
Norm
--
FREE Avatar hosting at www.easyavatar.com
| |
| Dumbass 2005-04-17, 3:57 am |
| Norman Peelman wrote:
> "Dumbass" <blah@hotmail.com> wrote in message
> news:1162l1sa3pujo12@corp.supernews.com...
>
>
>
> The answers to your questions are 'no', each instance will receive the
> insert id associated with its connection id and neither will trip up over
> which database the other is currently accessing...
>
> Norm
And how do you know this?
| |
| Michael Vilain 2005-04-17, 8:56 am |
| In article <1163lqvahdrvt6f@corp.supernews.com>,
Dumbass <blah@hotmail.com> wrote:
> Norman Peelman wrote:
>
> And how do you know this?
Simple. It's the way connections to MySQL are created by PHP. You can
download the source to PHP and MySQL and check for yourself.
--
DeeDee, don't press that button! DeeDee! NO! Dee...
| |
| Dumbass 2005-04-17, 3:55 pm |
| Michael Vilain wrote:
> Simple. It's the way connections to MySQL are created by PHP. You can
> download the source to PHP and MySQL and check for yourself.
>
What kind of answers are those though? "No", "Simple. That's the way it
is!" Have you read the source and understand how it works? If so then
why didn't you offer an explanation? Not all of us are end user level
programmers. Some of us can take a little technical discussion. And
explanation like this would have been nice...
Persistent resources are per engine. For example, with apache 1.3.x and
apache2-prefork mpm, there is one php engine per child. Each engine has
it's own persistant resource list. So a script running with 2 instances
do not share a single resource. They each use the persistent connection
for that instance of the engine. Also because of this there is no such
thing as persistent resources for the cli or cgi SAPI's (even if the cgi
is ran thru apache) because the engine is created and destroyed for each
request, so "the persistent connections simply do no persist".
| |
| Colin McKinnon 2005-04-18, 8:55 am |
| Dumbass wrote:
> Michael Vilain wrote:
>
> What kind of answers are those though? "No", "Simple. That's the way it
> is!" Have you read the source and understand how it works? If so then
> why didn't you offer an explanation? Not all of us are end user level
> programmers. Some of us can take a little technical discussion. And
> explanation like this would have been nice...
>
No need to loose the plot - Michael is trying to help to help you here.
And the answer is perfectly valid.
And a much better answer than 'because the supplier said so'.
If you can't be bothered to check the source for yourself but *must* know
the answer, TEST IT YOURSELF.
C.
| |
| coolsti 2005-04-18, 8:55 am |
| > What kind of answers are those though? "No", "Simple. That's the way it
> is!" Have you read the source and understand how it works? If so then
> why didn't you offer an explanation? Not all of us are end user level
> programmers. Some of us can take a little technical discussion. And
> explanation like this would have been nice...
Rather than getting nasty at each other ...
When the poster means two instances running, I assume it is meant that the
script is called simultaneously by to "users" as opposed to simultaneously
(sort of) by the same calling program, i.e. same user. I think mysql and
php are able to handle this without getting ; that is the whole
point of persistant connections, otherwise why bother implementing it?
Without knowing any of the details, I assume a connection ID is
established for each connection, and it is this ID that is used to
determine stuff like last_insert etc.
| |
| Norman Peelman 2005-04-18, 8:55 am |
| "Dumbass" <blah@hotmail.com> wrote in message
news:1163lqvahdrvt6f@corp.supernews.com...
> Norman Peelman wrote:
over[color=darkred]
>
> And how do you know this?
Because I use PHP/MySQL and I learned, read the docs/manuals/faqs/etc.
Bottom line, test it for yourself (as has been suggested) - don't confuse
the database connection with the php resource identifier.
Norm
--
FREE Avatar hosting at www.easyavatar.com
| |
| Norman Peelman 2005-04-20, 8:55 am |
| "Dumbass" <blah@hotmail.com> wrote in message
news:1163lqvahdrvt6f@corp.supernews.com...
> Norman Peelman wrote:
over[color=darkred]
>
> And how do you know this?
Because I use PHP/MySQL and I learned, read the docs/manuals/faqs/etc.
Bottom line, test it for yourself (as has been suggested) - don't confuse
the database connection with the php resource identifier.
Norm
--
FREE Avatar hosting at www.easyavatar.com
| |
| Dumbass 2005-04-23, 3:56 am |
| Michael Vilain wrote:
> Simple. It's the way connections to MySQL are created by PHP. You can
> download the source to PHP and MySQL and check for yourself.
>
What kind of answers are those though? "No", "Simple. That's the way it
is!" Have you read the source and understand how it works? If so then
why didn't you offer an explanation? Not all of us are end user level
programmers. Some of us can take a little technical discussion. And
explanation like this would have been nice...
Persistent resources are per engine. For example, with apache 1.3.x and
apache2-prefork mpm, there is one php engine per child. Each engine has
it's own persistant resource list. So a script running with 2 instances
do not share a single resource. They each use the persistent connection
for that instance of the engine. Also because of this there is no such
thing as persistent resources for the cli or cgi SAPI's (even if the cgi
is ran thru apache) because the engine is created and destroyed for each
request, so "the persistent connections simply do no persist".
| |
| Colin McKinnon 2005-04-23, 3:56 am |
| Dumbass wrote:
> Michael Vilain wrote:
>
> What kind of answers are those though? "No", "Simple. That's the way it
> is!" Have you read the source and understand how it works? If so then
> why didn't you offer an explanation? Not all of us are end user level
> programmers. Some of us can take a little technical discussion. And
> explanation like this would have been nice...
>
No need to loose the plot - Michael is trying to help to help you here.
And the answer is perfectly valid.
And a much better answer than 'because the supplier said so'.
If you can't be bothered to check the source for yourself but *must* know
the answer, TEST IT YOURSELF.
C.
| |
| Dumbass 2005-04-23, 3:56 am |
| Norman Peelman wrote:
> "Dumbass" <blah@hotmail.com> wrote in message
> news:1162l1sa3pujo12@corp.supernews.com...
>
>
>
> The answers to your questions are 'no', each instance will receive the
> insert id associated with its connection id and neither will trip up over
> which database the other is currently accessing...
>
> Norm
And how do you know this?
|
|
|
|