I have got some strange problem withe FireDAC and locking on mssql-server and have no idea how this can happen. So I hope anybody has some experience and will help me :)
We have got the following situation:
In our application we have got a table ToDo and a table ToDoNotes. Both have primary unique keys ID and they are linked via ToDoNotes.ToDoID.
Table ToDo is used to write down the next tasks and table ToDoNotes is to leave comments on each of the tasks. So several records in table ToDoNotes can be for one record in table ToDo. We connect to these mssql-tables using FireDac Table-Component FDTable. The connection has lockmode pessimistic
with locktpoint immediate
.
The following steps are locking the complete table ToDoNotes and I do not know why:
Session one:
- TblToDo.Edit for record 1
- TblToDoNotes.Append to append a record for TblToDo-record 1
so both Tables are in EditMode now.
Session two:
- TblToDoNotes.Append
At this point the application (Session two) is freezing until, we do a TblToDo.Post
or a TblToDo.Cancel
in Session one.
In the Microsoft Managment Studio I can see session two with waittype LCK_M_S and resource ridlock
Has anyone an idea what is going wrong? If we append records to TblToDoNotes in two different sessions everything works fine. It seems to me that FireDAC creates a second transaction which blocks the whole table ToDoNotes if there is already one table in editmode or something like that.
Every help is greatly appreciated.
Markus