dbTalk Databases Forums  

problem with Lock table

comp.databases.mysql comp.databases.mysql


Discuss problem with Lock table in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
armando
 
Posts: n/a

Default problem with Lock table - 02-06-2011 , 05:53 AM






Hello

I explain my situation:
I created a db in which I enter reservations to the hotels, especially
in this entry I have carried out over two web pages (and a.php b.php)
and, since the procedure of inserting a new book contains a number of
steps to perform, I have implemented this procedure through the
commit / rollback and with table locks...

I tested everything with the sleep (PHP).
If I do the test between two pages A and B. .. everything works! The
second page is waiting until the first has not finished

PROBLEM: The problem comes when I do the test using the same page ...
that is, if two or more users enter the page to perform all these
steps ... nobody respect the lock ....

I can not understand where the problem is ...
someone would help me
thanks

Reply With Quote
  #2  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: problem with Lock table - 02-06-2011 , 08:25 AM






On 2/6/2011 6:53 AM, armando wrote:
Quote:
Hello

I explain my situation:
I created a db in which I enter reservations to the hotels, especially
in this entry I have carried out over two web pages (and a.php b.php)
and, since the procedure of inserting a new book contains a number of
steps to perform, I have implemented this procedure through the
commit / rollback and with table locks...

I tested everything with the sleep (PHP).
If I do the test between two pages A and B. .. everything works! The
second page is waiting until the first has not finished

PROBLEM: The problem comes when I do the test using the same page ...
that is, if two or more users enter the page to perform all these
steps ... nobody respect the lock ....

I can not understand where the problem is ...
someone would help me
thanks
First of all, NEVER lock tables across web pages. What happens if, for
instance, someone displays the second page then closes his/her browser?
Or any of hundreds of other things which can go wrong.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #3  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: problem with Lock table - 02-06-2011 , 09:39 AM



armando <armando.cazzetta (AT) gmail (DOT) com> wrote:
Quote:
I explain my situation:
I created a db in which I enter reservations to the hotels, especially
in this entry I have carried out over two web pages (and a.php b.php)
and, since the procedure of inserting a new book contains a number of
steps to perform, I have implemented this procedure through the
commit / rollback and with table locks...
I'm sorry, but I don't see what exactly you do. Besides that table
locks have nothing to do with commit/rollback.

It sounds as if you try to keep a lock and/or an open transaction
between different HTTP requests. This won't work, because the web
server normally does not keep a database session between requests.
Even if it would - it cannot reliably dispatch existing sessions
to incoming HTTP requests.

If you want to use transactions from within PHP (this can make a lot
of sense) then you must either commit or rollback any transaction
before the script execution ends. If you don't, then at the end of
the script your database connection will be closed and any pending
transaction will be rolled back.

PHP also knows persistent database connections. Beware! If you use
those, then the database connections will never be closed, but you
may end with lots(!) of unfinished transactions and dangling locks.


XL

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.