#1 2013-07-05 13:01:56

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Transaction commit/rollback due TSQLDBConnection.Disconnect

I found very unexpected behavior: if I stop server all uncommited transaction is COMMITed (tested for Oracle). I expect rollback in this case. This is because of

procedure TSQLDBOracleConnection.Disconnect; 
...
        Check(SessionEnd(fContext,fError,fSession,OCI_DEFAULT),fError,false,sllError);  <---- The transaction specified by the service context is implicitly committed   [url]http://docs.oracle.com/cd/A97630_01/appdev.920/a96584/oci15r14.htm[/url]

It seems for MS SQL I have to get  SQLSTATE 25000 (Invalid transaction state) in similar situation.

My propose is to check transaction state and rollback  uncommited transaction in procedure TSQLDBConnection.Disconnect; to solve this problem.
If we decide not do it on connection level, I can rollback manually in OnHttpThreadTerminate, but I think default behavior for disconnecting must be Rollback.
In other library sometimes present parameter Connection.RollbackOnDisconnect: boolean;

Which option we choose?

Last edited by mpv (2013-07-05 13:15:21)

Offline

#2 2013-07-06 11:54:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Transaction commit/rollback due TSQLDBConnection.Disconnect

It is worth.a ticket I think.

Offline

#3 2013-07-06 14:32:36

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Transaction commit/rollback due TSQLDBConnection.Disconnect

Offline

#4 2013-07-07 15:14:54

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Transaction commit/rollback due TSQLDBConnection.Disconnect

I have implemented it as expected.

Thanks for the feedback!

Offline

#5 2013-07-08 08:21:59

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Transaction commit/rollback due TSQLDBConnection.Disconnect

Many thanks!

Offline

Board footer

Powered by FluxBB