SET XACT_ABORT

Posts   
 
    
DvK
User
Posts: 318
Joined: 22-Mar-2006
# Posted on: 03-May-2010 17:32:38   

Hi,

Is it anyway possible to set this SQL Server parameter from within LLBLGen ? This parameter makes sure that database transactions are correctly ROLLBACKED in case of runtime-errors (e.g. time-outs) while executing statements within the scope of a transaction. Locks are then automatically lifted in case communication between client and servers no longer is present.

More info -> http://technet.microsoft.com/en-us/library/ms188792.aspx

Kind regards, Danny

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-May-2010 04:32:40   

Hi Danny,

I never used such flag but I see the point. If the client lost connection during a transaction, it will never get back the exception (FK constraint violatino, for instance) so you can't rollback the transaction by code and you will receive a TimeOut exception, but what happens to the current transaction? Is that the case?

Anyway, I think you can create your own version of DataAccessAdapter (XactAbortDataAccessAdapter, f.i.) to specify that hint. You can do that per instance of adapter. Here is the code snippet for NOLOCK: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=16508&StartAtMessage=0&#92356 , you just need to do it for your own hint.

David Elizondo | LLBLGen Support Team
psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 04-May-2010 05:15:26   

Interesting--I put this in all my stored procedures that use explicit transactions, but it never occurred to me that I should be using this statement in my generated SQL that involves multiple operations (Units of Work) or operations that could time out.

Is this something that could be added as a flag to the DataAccessAdapter, or become default behavior? I can't imagine a situation where you would want SET XACT ABORT OFF.

DvK
User
Posts: 318
Joined: 22-Mar-2006
# Posted on: 04-May-2010 09:28:16   

Hi @PSandler,

I did read some blogs though where they stated that performance could decrease somewhat. Is that really the case ?

Regards, Danny

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 04-May-2010 10:29:09   

I can't see why it would have a bad effect on performance. I would have expected the other way around.

DvK
User
Posts: 318
Joined: 22-Mar-2006
# Posted on: 04-May-2010 11:33:48   

@Daelmo : thanks for the link, however it's not a Sql HINT which must be added but a SET parameter that should be inserted at the beginning. How would you do this ?

Thanks in advance !

Regards, Danny

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 04-May-2010 12:56:50   

You will need to add a method to the DataAccessAdapter.cs class similar to the following method, either by using another file (partial class) , or by deriving from it.

public static void SetArithAbortFlag(bool value)
{           SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.ArithAbortOn = value;
}

Then you will need to modify the SQL Server DQE (DynamicQueryEngine.cs) Just follow the ArithAbortOn flag, and you will know what to add and where to ad it.

DvK
User
Posts: 318
Joined: 22-Mar-2006
# Posted on: 04-May-2010 14:34:49   

Ahh...Ok ! Just inspected the DynamicQueryEngine, this looks doable....but not very maintenance-friendly. After each update of LLBLGen we have to rebuild the DynamicQueryEngine.

Isn't there another friendly way, via a partial class within the generated data-access code instead of the runtime libraries ?

greetings, Danny

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 04-May-2010 21:14:47   

Create your own class which inherits from DynamicQueryEngine, and add your code to that.

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 05-May-2010 10:23:44   

To instantiate the DQE of your own, you've to override the CreateDynamicQueryEngine method in a derived class of DataAccessAdapter

Frans Bouma | Lead developer LLBLGen Pro