solved: Deadlock with unknown reason
Posted: 02.12.2023, 10:29
Hello,
i use this code to save form-position and size on closing the form in "onClose-Event of the form.
If used on two working places it sometimes chrashes with an deadlock.
For example:
I don't find the reason for the deadlock.
qryGeneric is a TZQuery with standard-settings. Nothing changed, only Conection-Proprty ist filled with the TZConnection.
I tried different transactionLevels in TZConnection, but the deadlock occures.
Can anyone give me a hint, what will be the reason for a deadlock, when there are some seconds between the execution of execSQL?
best regards
Siegbert
i use this code to save form-position and size on closing the form in "onClose-Event of the form.
If used on two working places it sometimes chrashes with an deadlock.
For example:
- open a form in one session
- open the same form in the second session
- close the first form -> size an position saved
- close the second form -> deadlock
I don't find the reason for the deadlock.
qryGeneric is a TZQuery with standard-settings. Nothing changed, only Conection-Proprty ist filled with the TZConnection.
I tried different transactionLevels in TZConnection, but the deadlock occures.
Can anyone give me a hint, what will be the reason for a deadlock, when there are some seconds between the execution of execSQL?
Code: Select all
Procedure SaveWindow(sName:String; x,y,w,h:Integer);
Begin
with dmBISaM_SQL do
begin
qryGeneric.close;
qryGeneric.SQL.Clear;
qryGeneric.SQL.Add('select * from WINDOWS where name = ''' + sName +'''' );
qryGeneric.open;
if qryGeneric.RecordCount = 0 then
begin
qryGeneric.close;
qryGeneric.sql.clear;
qryGeneric.sql.add('INSERT INTO Windows (Name, XPos, YPos, Width, Height)');
qryGeneric.sql.add('VALUES ('''+sName+''', '+IntToStr(x) +', ');
qryGeneric.Sql.Add(IntToStr(y) +', '+IntToStr(w) +', '+IntToStr(h) +')');
try
qryGeneric.ExecSQL;
except
end;
end
else begin
qryGeneric.close;
qryGeneric.sql.clear;
qryGeneric.sql.add('UPDATE Windows ');
qryGeneric.sql.add('SET XPos='+IntToStr(x) + ', YPos=' + IntToStr(y) );
qryGeneric.Sql.Add(', Width='+IntToStr(w) +', Height='+IntToStr(h));
qryGeneric.sql.add(' WHERE name ='''+sName+'''');
try
qryGeneric.ExecSQL;
except
// sometimes this exception.
on e: exception do showMessage(e.message);
end;
end;
end;
Siegbert