How to Fix SQL Server Error 3431 (Msg 3431)
You get sql server error 3431 when a database cannot recover due to unresolved transaction outcomes. You fix it by restoring the distributed transaction coordinator and resolving in-doubt transactions. This failure is a severity 21 error in the database engine. Severity 21 means a serious problem affects the whole database process. When this happens, the database cannot finish its startup sequence. Users and apps cannot read or write data until you fix the state. You need a clear plan to check
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You get sql server error 3431 when a database cannot recover due to unresolved transaction outcomes. You fix it by restoring the distributed transaction coordinator and resolving in-doubt transactions.
This failure is a severity 21 error in the database engine. Severity 21 means a serious problem affects the whole database process. When this happens, the database cannot finish its startup sequence. Users and apps cannot read or write data until you fix the state. You need a clear plan to check the transaction logs and restore normal work.
Root causes of sql server error 3431
The database engine uses a recovery phase every time it starts up. During this phase, the engine checks the transaction log for active work. It rolls forward finished work and rolls back unfinished work. Most transactions live inside one database and resolve fast. Some transactions span across two or more servers or databases.
The Microsoft Distributed Transaction Coordinator manages these cross-server transactions. It uses a two-phase commit rule to keep all servers in sync. First, it asks each server to prepare the data change. Second, it tells every server to commit or roll back the work.
If the server crashes after phase one, the transaction stays in doubt. When the database starts up again, it asks the coordinator for the final outcome. If the coordinator is offline or broken, the engine cannot finish recovery. The engine then stops recovery for that database and logs error 3431.
Network drops between the database and the coordinator also cause this issue. Sometimes, a team member resets the coordinator log before the database recovers. When the log is gone, the database cannot find the transaction outcome.
How to diagnose and fix the failure safely
Start your check by looking at the Windows service for the transaction coordinator. Make sure the service is running on the database host and remote hosts. Check the network path between the servers to confirm they can talk. Often, starting the coordinator service and restarting recovery fixes the whole issue.
Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Next, read the server error log to find the exact database ID. The log message gives the database name and the database ID number. Check the system views in the master database to see in-doubt transactions. Look for transactions that are stuck in a prepared state.
Do not grant broad server roles to the whole team during an outage. In SQL Server, a login connects to a database through a database user. People who need many databases often use a login in master. For one or a few databases, admins can set up a contained database user. You cannot change the permissions assigned to fixed database roles. Keep responders on read-only roles while they check logs and views.
Once you find the stuck work, match the unit of work ID across servers. Check the other servers in the transaction to see if they committed or aborted. Then, tell the local engine to commit or abort the stuck work to match. After you clear the in-doubt work, bring the database back online.
How to prevent future recovery failures
You can avoid error 3431 by keeping cross-server transactions very short. Long transactions hold locks and raise the risk of a crash during commit. Keep the transaction coordinator service set to start up right away on boot.
Monitor the coordinator service health just like you monitor the database engine. Alert your team if the coordinator stops or drops network packets. Test your failover plans to make sure the coordinator moves with the database. Good habits keep your recovery phase fast and predictable.
Check SQL Server batches and results on the wire
SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server, inline in the TDS wire protocol. On every batch an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Before a batch hits the server, hoop.dev guardrails refuse disallowed actions with a native TDS error or hold risky statements for approval. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns in memory, and every decision is logged. Explore the MIT-licensed project on GitHub.
Frequently asked questions
What does severity level 21 mean for SQL Server Error 3431?
Severity 21 means the engine found a fatal problem in the database process. The affected database stays offline until an admin resolves the transaction state.
Can a read-only user fix an in-doubt distributed transaction?
No, members of the read-only role can only read data from user tables and views. Resolving an in-doubt transaction or restarting recovery requires high admin rights.
Should I rebuild the transaction log to clear Error 3431?
Make rebuilding the log your absolute last choice because it can cause data loss. Always try to reconnect the transaction coordinator and resolve the transaction outcome first.
Related guides
In this post