Lock conflict on no wait transaction

This is actually not an error, but a normal exception caused by transaction management. You'll get this message when one transaction tries to update or delete a record that was changed by another transaction after the current transaction has started. It only happens when the current transaction is a NO WAIT transaction, so it doesn't wait for other transaction to finish, but rather reports the error and gives up immediately.

Please note that this is a normal event with NO WAIT transactions and your application should be prepared for it and able to deal with it. This is needed in order to maintain database consistency. Imagine for example that you have a table with record:

-- -----
10 15000

Now, we have two transactions starting at approximately the same time, and both run:

UPDATE t1 SET value = value + 20 WHERE id = 10;

You would expect the column to have value of 15040 after they both commit. But, let's take a look what happens in a real database. Transaction one reads value 15000 from the column, adds 20 and puts 15020 - it does not commit yet, but goes on to do other things. Transaction two starts, reads 15000 from the column (as transaction one did not commit yet), adds 20 and puts 15020. If there was no error raised, you would end up with value 15020 instead of 15040 in the column. However, the exception will be raised. If it's a NO WAIT transaction, the message would should up at once. On the other hand, WAIT transaction would wait for other transaction to finish before going further (if the first one rolls back) or throwing an error (if the first one commits).

When you get such message, it often helps to change transactions from NO WAIT to WAIT, although you should investigate the issue closely as bad transaction management can lead to poor performance.

Do you find this FAQ incorrect or incomplete? Please e-mail us what needs to be changed. To ensure quality, each change is checked by our editors (and often tested on live Firebird databases), before it enters the main FAQ database. If you desire so, the changes will be credited to your name. To learn more, visit our add content page.

If you are a commercial tool maker and your tool features a great way to handle the issue written about in this FAQ, please check out our advertisement page.

All contents are copyright © 2007-2014 FirebirdFAQ.org unless otherwise stated in the text.

Links   Firebird   News   FlameRobin   Home Inventory powered by FB  
Add content   Advertise   About  

 Installation and setup
 Backup and restore
 Connectivity and API
 Errors and error codes