Msg 3910: Transaction Context in Use on a Loopback Linked Server

Msg 3910 means a distributed transaction failed because the transaction context was in use by another session. One of my clients hit it over a linked server. The twist was that the linked server was the local SQL Server, which is called a loopback linked server.

Gouache painting of a cream vintage telephone on a small wooden table, its vermilion coiled cord looping around and plugging into its own side

The Error

Msg 3910, Level 16, State 2, Line 1
Transaction context in use by another session.

What the Client Saw

When the client ran a query that performs a distributed transaction, it failed. This is the screenshot of the behavior. The linked server address in the query was the IP address of the local machine.

SSMS query window with BEGIN DISTRIBUTED TRANSACTION and a SELECT from a four-part linked server name, and the Messages pane showing Msg 3910, Level 16, State 2, Line 1: Transaction context in use by another session.

If you try to create a linked server for the local server, SSMS refuses with this message:

You cannot create a local SQL Server as a linked server.

SSMS error dialog with the message: You cannot create a local SQL Server as a linked server.

Why It Happens

I found old documentation that says loopback linked servers cannot be used in a distributed transaction. The client’s linked server pointed at the local machine, so it was a loopback.

How to Check

Check these two things when you get this error. The first query should return the right server name. The second should show the local server name under server_id = 0.

SELECT @@SERVERNAME

SELECT * FROM SYS.SERVERS

The Fix

If you must fetch data from the local server, you don’t need a linked server. Use three-part naming, database.schema.object, instead of four-part naming, server.database.schema.object.

How to Prevent It

Don’t create a linked server that points back to the same instance, because distributed transactions fail over it. If you found another solution, please share it in the comments.

Quick reference card: Msg 3910: Loopback Server

Msg 3910 is not a transaction bug, it is a linked server pointing back at itself.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

Linked Server, SQL Error Messages, SQL Scripts, SQL Transactions
Previous Post
Choosing a Processor for SQL Server: Count the Licensed Cores
Next Post
Last Query Cost in MySQL: Read It With SHOW STATUS

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.