El 6/5/26 a les 12:02, Luca Olivetti via fpc-pascal ha escrit:


Since I don't manage the ms sql server, don't know what it does in its stored procedures and views and don't want to learn the intricacies of its transaction management, I just added a TCriticalSection so that only one connection can start a transaction (they should complete quite fast anyway). Maybe there's a way to achieve the same with some special parameter in the transaction/connection but the global TCriticalSection works.

Bye


El 6/5/26 a les 10:55, Luca Olivetti via fpc-pascal ha escrit:

As always I found the problem right after hitting "send": another thread started a transaction which blocks this one. I still don't understand why (this is a select that it shouldn't be affected by the other transaction)

Bye

Hello,

I encountered a strange problem in an application, that's been running for over a year now. The application is quite convoluted with hundred of threads, one (actually more than one) of those threads connects to an ms sql server and now it blocks inside TMSSQLConnection.Execute, but not always


procedure TMSSQLConnection.Execute(const cmd: string);
begin
   DBErrorStr:='';
   DBMsgStr  :='';
   CheckError( dbcmd(FDBProc, PAnsiChar(cmd)) );
   CheckError( dbsqlexec(FDBProc) );  <--- this doesn't return
   CheckError( dbresults(FDBProc) );
end;


However when I terminate the application and before the destroy method of the thread is called, dbsqlexec returns and the rest of the thread goes on as nothing happened.

As an experiment I wrapped the method in synchronize but that only freezes the gui when it happens.

I don't know it if is relevant but I have a note in my program that I have to initialize the sql server libraries in the main thread, otherwise doing it in another thread eventually causes a sigsev.

I got the dlls (almost 2 years ago) following the instructions here

https://forum.lazarus.freepascal.org/index.php/ topic,55037.msg409167.html#msg409167

using Environment: PLAT=Win32, WIDTH=32, VS_VERSION=2017, TDSVER=7.3
(though older artifacts are deleted after a month)

This is on windows 32 bits, fpc 3.2.2, any hint on how to debug it further?

Bye

_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to