The Version Store Won’t Clear If ANY Database Has Open Transactions.

TempDB
11 Comments

Short story: what the title says.

This is especially problematic for folks who merge multiple databases onto the same server. All it takes is one badly-behaving application to leave its transactions open, and suddenly it causes the rest of the databases to run TempDB out of space. That app’s transaction might not even be changing anything, and it might have never caused problems for that application before – but once it shares a TempDB with other apps, it causes cascading problems.

Long story: let’s start by creating a database and throwing some data in it:

Check to see how much space is used in the version store right now, and it should be none:

Do a non-updating update, and check the version store again:

Even though our update statement wasn’t in a transaction, and even though the query’s already finished, you’ll still see a copy of the table in the version store temporarily:

Version store in use

Wait 30 seconds or so, and then check the version store again. It’ll clean itself out automatically in the background. That’s how the world is supposed to work when everything’s going well.

However, imagine that you install a 3rd party vendor app on that same server, and it goes into its own database:

The badly behaved application left its transaction open, but what’s the big deal? It only affects the vendor app, not our own isolated app, right?

Badly behaved app using the version store

Here’s the problem: switch back over to our own supposedly isolated app, try the one-line update statement again, and check the version store space usage:

Version store still in use

You can wait all you want, but our version store size ain’t going down, even though our databases aren’t connected in any way, and even though my well-behaving app isn’t using transactions! Every update & delete happening in my ShouldBeIsolated app is going to go into the version store, and stay there, until my BadlyBehaved app commits or rolls back its transactions.

What if I turn on ADR in BadlyBehaved?

The database-level setting Accelerated Database Recovery moves the RCSI version store out of the shared TempDB, and into the user database itself. This enables faster rollbacks. We’ll roll back our transaction in BadlyBehaved, wait for everybody’s version store to clear out of TempDB, then turn on ADR in BadlyBehaved:

Now, our BadlyBehaved app isn’t using any TempDB space:

BadlyBehaved using ADR

And if we switch back over to our isolated app database, and run our update statement, and check the TempDB version store usage:

Version store growing

Yes, the table initially goes into the version store – it has to, when you’re using RCSI – but then wait 30 seconds and check again, and:

Still there

Bad news. ADR doesn’t help this scenario. Again, if any database has open transactions, even if that database has ADR enabled, the version store won’t clear itself out.

Note: this post was inspired by this 2008 MSDN blog post by Sunil Agarwal and this now-removed post (slow archive at the Wayback Machine) by an unknown author at Kohera.be. Kohera kept moving their post URL around, and then finally deleted their post, and MSDN certainly has a habit of doing that, so I figured I should just stick a post on here and be done with it because I mention this problem during my Fundamentals of TempDB class.

Previous Post
[Video] Office Hours in My Backyard
Next Post
SQL ConstantCare® Population Report: Fall 2025

11 Comments. Leave new

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.