Is it possible to use transaction between two instances without enable DTC?

StackOverflow https://stackoverflow.com/questions/12562649

  •  03-07-2021
  •  | 
  •  

سؤال

I have two instances of database located in two servers. I want to create an application to insert data into the first one and then update data on the second instance, if one of these process fail then I want to rollback all operations.

The database servers do not enable DTC/MSDTC. I tired to use transaction scope but no luck. Do you guys have any idea how can I do this?

هل كانت مفيدة؟

المحلول

if one of these process fail then I want to rollback all operations

You are describing a distributed transaction. To use distributed transactions, you need a transaction coordinator. You can't have the cake and eat it too.

There are alternatives if you consider asynchronous application of the changes, ie. Replication. This removes the distributed transaction requirement but the changes are applied asynchronously to the second server, after they are committed on the first server.

نصائح أخرى

One option would be to put compensation code into your application. For example, if your application were c# based, you could have a try...catch block. In the catch block, you could add compensation code to "undo" the changes you made to the data on the first server.

The best method however, is of course to make a case to the DBAs to enable DTC

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top