MySQL Forums
Forum List  »  PHP

PHP and Transactions
Posted by: Peter Black
Date: January 14, 2006 03:42PM

I have created a script which uses transactions with MySQL 5.

However, I just ran a test plan using JMeter which hit the script with 100 threads, 5 per second, and transactions are not working as expected.

MY script is doing the following:

start transaction

select from table1

rollback if no results are returned or error and throw exception

select from table 2

rollback if error and throw exception

if rows are returned
delete from table 2
rollback if error and throw exception
else
rollback and throw exception

select from table 1

rollback if no results are returned or error and throw exception

select from table 2

rollback if error and throw exception

if rows are returned
delete from table 2
rollback if error and throw exception
else
rollback and throw exception

insert into table 2

commit

Both tables are InnoDB. When I say start transaction I am referring to a function which sends the query START TRANSACTION, and rollback and commit send ROLLBACK and COMMIT respectively. And I am determining if rows were returned using mysql_num_rows.

When running the test plan I see in my logs that it is doing the insert in the second table a few times when it should only do the insert once. What am I doing wrong?

SEE MY LAST POST FOR THE SOLUTION



Edited 1 time(s). Last edit at 01/19/2006 05:44PM by Peter Black.

Options: ReplyQuote


Subject
Written By
Posted
PHP and Transactions
January 14, 2006 03:42PM
January 15, 2006 05:51AM
January 16, 2006 09:18AM
January 19, 2006 12:00AM
January 19, 2006 02:34PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.