Fix STATUS_CURRENT_TRANSACTION_NOT_VALID error 0XC0190018
This NTSTATUS error means the current transaction handle is stale or invalid. The quick fix is to reset the transaction state, then check for orphaned transactions.
You're staring at STATUS_CURRENT_TRANSACTION_NOT_VALID (0XC0190018) and it's a pain. Let's get this fixed fast.
This error means the current transaction you're trying to use has gone bad. The handle is still open, but the transaction itself is either rolled back, committed, or otherwise invalid. You'll see this most often when someone's using Kernel Transaction Manager (KTM) APIs in a Windows app, or when SQL Server or other database software hits a transaction that's been orphaned after a sudden crash or network drop.
Here's the direct fix — it's about resetting the transaction state and cleaning up the handles.
The Fix: Reset and Clean Up the Transaction
- Identify the process holding the transaction.
Open Task Manager (Ctrl+Shift+Esc), go to the Details tab, and look for your database process (e.g., sqlservr.exe). Note the PID. If you don't see the process, skip to step 2 — the transaction handle is probably already orphaned. - Open an elevated Command Prompt.
Hit the Windows key, typecmd, right-click Command Prompt, choose Run as administrator. - List all active transactions.
Run this command:
wmic path Win32_Process where "Name='sqlservr.exe'" get ProcessId
That gives you the PID if you missed it. Then run:
fltmc transactions
This lists all transactions managed by the filter manager. You're looking for a transaction with a status of ACTIVE but no associated process. - Terminate the orphaned transaction.
Find the transaction GUID from thefltmc transactionsoutput. Then run:
fltmc detach transaction
Replace<GUID>with the actual GUID. This detaches the transaction from the volume. After that, the handle becomes invalid, which is exactly what we want — the system will then clean it up. - Restart the database service.
If this is SQL Server, open Services (services.msc), find SQL Server (MSSQLSERVER) (or your named instance), right-click and choose Restart. This forces a fresh start of the transaction manager within the database engine. - Verify the error is gone.
After the service restarts, try the operation that triggered the error. You should see it complete without the 0XC0190018 error. If it doesn't, check the Windows Application Event Log (Event Viewer > Windows Logs > Application) for related KTM or transaction manager errors.
Expected outcome after step 4: The fltmc transactions output should show no active orphaned transactions. After step 5, the database service restarts cleanly, and the transaction handle is reinitialized.
Why This Works
The error code 0XC0190018 maps to STATUS_CURRENT_TRANSACTION_NOT_VALID in the NTSTATUS header files. It specifically means the transaction descriptor (the handle) still exists in the current thread's context, but the underlying transaction object is no longer valid. This happens when:
- The transaction was rolled back by another thread or process.
- The transaction timed out (KTM has a default timeout of 60 seconds for transactions).
- The volume where the transaction was being used got dismounted or remounted.
When you detach the orphaned transaction via fltmc detach, you're telling the filter manager to cut the connection between the transaction and the volume. Without that, the transaction handle lingers as a zombie handle. Once detached, the handle goes invalid, and the next time the application tries to use it, it gets a clean error (like invalid handle) rather than this stale-transaction error. Restarting the service reinitializes the whole KTM instance and the database engine's transaction context.
Less Common Variations of This Error
1. Transaction handle passed between processes
If you have a custom app that passes a transaction handle from one process to another via DuplicateHandle or RPC, the recipient can get this error if the source process closes its copy first. The fix here is to redesign the transaction flow: keep the transaction open in the source process until the destination has finished using it. Use synchronization like a named event to signal completion.
2. Transaction created with CreateTransaction but never committed or rolled back
This one's a developer mistake. If code calls CreateTransaction then leaks the handle without calling CommitTransaction or RollbackTransaction, the transaction stays in limbo. Eventually, the system's garbage collection (KTM's transaction manager) may mark it invalid. The fix is to always wrap transactions in try/finally blocks. Example in C++:
HANDLE hTx = CreateTransaction(NULL, 0, 0, 0, 0, NULL, NULL);
if (hTx == INVALID_HANDLE_VALUE) { /* handle error */ }
__try {
// use transaction
CommitTransaction(hTx);
}
__finally {
if (hTx != INVALID_HANDLE_VALUE) CloseHandle(hTx);
}
3. Volume dismounted after transaction started
Rare but nasty — if a USB drive or external volume with a transaction gets disconnected, the transaction becomes invalid on reconnection. The error shows up when the app tries to continue the transaction on the remounted volume. The fix is to check the volume mount state before starting a transaction, or handle the error by restarting the transaction from scratch.
How to Prevent This Error
The root cause is almost always one of three things:
- Improper transaction lifecycle management. Every transaction must end with commit or rollback. If you're writing code, use RAII patterns (like
std::unique_ptrwith a custom deleter) to guarantee cleanup. - Unexpected process termination. If your database or app crashes mid-transaction, the next startup should detect and roll back any pending transactions. SQL Server does this automatically via recovery. If you're building your own transaction manager, implement recovery logic that checks for uncommitted transactions on startup.
- Network or disk failures. Use a reliable transport (TCP with retry logic) and handle volume mount/unmount events. Monitor the Windows Kernel-TransactionManager event log for warnings about transaction timeouts.
One more thing — don't ignore the error. I've seen teams just restart the service and hope it goes away. It might work once, but if you keep seeing 0XC0190018, there's a deeper bug in the transaction handling code. Track down the source and fix it permanently.
Was this solution helpful?