pessimistic lock hang

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Valerio M.
Posts: 4
Joined: Sun 02 Jan 2011 14:41

pessimistic lock hang

Post by Valerio M. » Sun 02 Jan 2011 14:51

Hello, I've a problem with a multiuser application.

MyDac: 6.00.0.1 for Delphi XE
MySQL server version: 5.5.8

this is the scenario:

Pc A:
mytable.Edit;

Pc B:
mytable.Edit;
Here I expected an exception to be thrown,
so I can alert the user he can't editing that record at that time.

But, when the "Pc B" call mytable.Edit, the application hang until the "Pc A"
call post or commit. Also the OnEditError event is not fired.

this happens also into the mydac lock demo in the same way.

ps: Both Pc A and Pc B are connecting to mysql server with the same account and the table engine is InnoDB.

I hope you have some suggestion on this.
Last edited by Valerio M. on Tue 04 Jan 2011 14:55, edited 1 time in total.

Valerio M.
Posts: 4
Joined: Sun 02 Jan 2011 14:41

Post by Valerio M. » Tue 04 Jan 2011 14:55

No-one have this problem?

AndreyZ

Post by AndreyZ » Tue 04 Jan 2011 15:11

Hello,

Such behaviour is correct. If any other connection tries to modify the locked record, it will wait for the time specified by the innodb_lock_wait_timeout server variable, by default 50 seconds. If during this time the record isn't unlocked, an exception raises.

Valerio M.
Posts: 4
Joined: Sun 02 Jan 2011 14:41

Post by Valerio M. » Tue 04 Jan 2011 15:16

uhm so I can tweak the inno db lock record timeout to fit my needs.

thank you :)

ps: just another question. there's a way to manually abort the "Pc B" edit command while it is waiting for inno db timeout?

swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Post by swierzbicki » Wed 05 Jan 2011 07:22

Hi,
just another question. there's a way to manually abort the "Pc B" edit command while it is waiting for inno db timeout?
Don't know if this is possible but before editing just test if the record is locked.

Valerio M.
Posts: 4
Joined: Sun 02 Jan 2011 14:41

Post by Valerio M. » Wed 05 Jan 2011 09:08

swierzbicki wrote:Hi,
just another question. there's a way to manually abort the "Pc B" edit command while it is waiting for inno db timeout?
Don't know if this is possible but before editing just test if the record is locked.
Right, I had already thought this.

But, I can't find any "mytable.TryEdit" or "mytable.isRecordLocked"

AndreyZ

Post by AndreyZ » Wed 05 Jan 2011 11:51

MySQL server doesn't allow to check if a record is locked or not. You can decrease the value of the innodb_lock_wait_timeout server variable and see if a record is locked by catching the exception.

Post Reply