Hi,

On Sat, Apr 06, 2002 at 03:57:39PM -0500, Victor wrote:
> Suppose that a query begins with begin. Then a couple inserts happen but
> before the commit statement is executed, the client hits stop in the
> browser. What is going to do the rollback? If there is a persistent
> connection, is it going to wait for 8 hours or so and what would happen
> then?

When the user hits the STOP button, your script (most likely) will
have no idea that the browser closed the connection until it tries
to send it some output, at which point it would probably receive
SIGPIPE or some kind of indicator that the client is gone. By
default, applications that receive SIGPIPE will terminate ("Broken pipe").
The connection to the mysql server would be broken, and the mysql
server would issue a rollback.

If your web server does any buffering, you may not know until the
entire page is sent that the client disappeared.

Your environment may provide different default behavior, but you
should be able to modify these things to taste if you're willing
to get low-level enough.

PHP (since you mention it in the next paragraph) will by default
kill running scripts if a timeout value is reached. This timeout
can be modified accordingly.

> Is there a significant increase in speed using persistent connections in
> MySQL? I am using PHP and I am cuious how one would do a persistent
> connection example. Does php would keep a class loaded in mem like java
> would? It doesn't sound plausible since php is loaded with an apache thread,
> which gets recycled every now and then, leaving the connection open on the
> mysql side but never used by apache agian.

We don't do persistent connections at all with our sites
and we don't notice a speed problem (mod_perl). PHP provides a
mysql_pconnect() function which is supposed to do persistant
connections according to the documentation.

If you don't maintain persistent connections, you may want to take
measures to ensure that each mysql connection attempt doesn't involve
a DNS lookup (either put the hostname in /etc/hosts or use an IP
address instead of a name) if your mysql server is not localhost..

-- 
Michael Bacarella  | Netgraft Corporation
                   | 545 Eighth Ave #401
 Systems Analysis  | New York, NY 10018
Technical Support  | 212 946-1038 | 917 670-6982
 Managed Services  | [EMAIL PROTECTED]


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to