Understanding MSDTC Transactions and Isolation Levels in SQL Server

Joseph Chakola
3 min readApr 12, 2024

--

Read Committed Snapshot Isolation

Introduction

Have you ever wondered how SQL Server handles transactions that span multiple databases or even multiple servers? That’s where MSDTC comes in. MSDTC, or Microsoft Distributed Transaction Coordinator, is a component that enables distributed transactions across multiple resources. In this article, we’ll dive into how MSDTC transactions work in SQL Server and clear up some common questions about the isolation levels they use. By the end, you’ll have a solid understanding of this important aspect of SQL Server transaction management.

What is MSDTC?

MSDTC is a Windows service that coordinates transactions across multiple resources, such as databases, message queues, and file systems. It ensures that distributed transactions maintain ACID properties (Atomicity, Consistency, Isolation, Durability) even when they involve multiple resources.

When you start a distributed transaction in SQL Server using BEGIN DISTRIBUTED TRANSACTION, MSDTC springs into action behind the scenes. It communicates with the resource managers (like SQL Server) involved in the transaction to coordinate their work and make sure they all commit or roll back together.

Isolation Levels in MSDTC Transactions

One common point of confusion with MSDTC transactions is what isolation level they use. Some people assume that MSDTC always translates the isolation level to SERIALIZABLE, the strictest level. However, that’s not actually the case.

In reality, MSDTC transactions use the isolation level specified in the connection string or via SET TRANSACTION ISOLATION LEVEL, just like local transactions. If you don’t specify an isolation level, they default to the database’s default isolation level, which is usually READ COMMITTED.

You can verify this by checking the isolation_level column in the sys.dm_exec_sessions DMV for your session when an MSDTC transaction is active. You’ll see it reflects the actual isolation level being used.

Interaction with Read Committed Snapshot Isolation (RCSI)

Another related question is how MSDTC transactions behave when the database is using Read Committed Snapshot Isolation (RCSI). In this case, you might see sp_whoisactive reporting the isolation level as READ COMMITTED even though RCSI is enabled.

The reason for this is that RCSI is an implementation detail of the READ COMMITTED isolation level. From the perspective of the transaction, it’s still using READ COMMITTED isolation. The fact that SQL Server is using row versioning behind the scenes to provide statement-level read consistency doesn’t change the isolation level.

So it’s perfectly normal and expected to see a READ COMMITTED isolation level reported for an MSDTC transaction when RCSI is enabled. The transaction is still getting the benefits of RCSI, such as not being blocked by other transactions’ writes.

Conclusion

In this article, we’ve taken a closer look at how MSDTC transactions work in SQL Server and cleared up some common misconceptions about their isolation levels. We’ve seen that MSDTC transactions use the isolation level you specify, not SERIALIZABLE by default, and that it’s normal for them to show as READ COMMITTED when RCSI is enabled.

Armed with this knowledge, you’ll be better equipped to understand and troubleshoot MSDTC transactions in your SQL Server environment. The next time you see an MSDTC transaction in sp_whoisactive, you’ll know exactly what’s going on under the hood!

I hope this explanation has been helpful. If you have any other questions about SQL Server transactions, feel free to ask.

--

--

Joseph Chakola

I'm a SQL Server DBA with over 17 years under my belt. Excited to share my knowledge and experience using AI to tackle the toughest db challenges out there.