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.

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.

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.
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.SERVERSThe 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.

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.




