cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Managed table conversion and vacuum

Davide
New Contributor III

Hello everyone,

I am looking for clarification about the 14-day rollback period after converting an external table to a managed table using:

                                                        ALTER TABLE <table_name> SET MANAGED
Databricks documentation states that the conversion can be rolled back within 14 days. It also says that, after this period, Predictive Optimization or a manual VACUUM can delete data from the old external location to avoid unnecessary storage costs.

I would appreciate clarification on these scenarios:

  1. Running VACUUM before day 14
    If I run VACUUM before the 14-day rollback period ends, does it affect only files in the new managed-table location? Or can it also delete files from the original external location?

  2. Retention period shorter than 14 days
    If delta.deletedFileRetentionDuration is set to less than 14 days, for example 7 days:

    • Does the rollback window become 7 days?
    • If I run VACUUM on day 8, could it delete data needed for rollback, or it will just affects the data in the managed location?
  3. Retention period longer than 14 days
    If delta.deletedFileRetentionDuration is set to more than 14 days, for example 20 days:

    • Does the rollback window remain 14 days or extend to 20 days?
    • If I run VACUUM on day 16, could it delete files from the original external location?

My assumptions are that the rollback period is fixed to 14 days so, if you run vacuum before that period will not touch the data in the external location no matter the retention-days. If the retention is more than 20 days and if I run a vacuum or PO kicks in, the data in old location will be deleted. 

Has anyone tested these cases or received clarification from Databricks? I could not find details about how the rollback period interacts with delta.deletedFileRetentionDuration, manual VACUUM, and Predictive Optimization.

Thanks for any guidance.

2 REPLIES 2

Isaac_18
Contributor II

Hi @Davide, this thread never got a reply, but you asked the same thing in SET MANAGED and rollback in relation to VACUUM and posted your test result there, so I'm linking it for anyone who lands here first.

Short version: the 14-day rollback window is its own fixed retention for the old external copy. Your test showed that delta.deletedFileRetentionDuration doesn't shorten it or stretch it.

What the docs spell out:

  • Databricks keeps the data in the old external location for 14 days so you can roll back.
  • Rolling back is ALTER TABLE ... UNSET MANAGED inside that window (DBR 17.3 LTS+ or serverless). Writes made to the managed location after conversion are kept, and you need to restart any streaming jobs afterwards.

  • After 14 days, predictive optimization deletes the old external data. If predictive optimization is off, you run VACUUM on the converted table yourself to reclaim it.

-- roll back within 14 days
ALTER TABLE main.sales.orders UNSET MANAGED;

-- check whether predictive optimization will clean up for you
DESCRIBE TABLE EXTENDED main.sales.orders;  -- look for the Predictive Optimization row

If rollback really matters for a table, I'd still keep manual VACUUM jobs off it for the full 14 days. It costs you nothing and you never have to wonder.

Louis_Frolio
Databricks Employee
Databricks Employee

Greetings @Davide, I did some digging and here is what I found.

@Isaac_18 has this right, and your own test in the sibling thread settles the main question. The 14-day rollback window and delta.deletedFileRetentionDuration are separate settings. A 7-day retention doesn't shorten the window, and a 20-day retention doesn't extend it.

Here's how that maps to your three scenarios:

  • VACUUM before day 14. As a reply in your other thread pointed out, the docs don't say what a manual VACUUM inside the window does to the original external files, and I can't confirm it either way. If you might need to roll back, hold off on manual VACUUM until day 14 has passed. Predictive optimization can stay on, since the docs say it removes the old data only after 14 days.
  • Retention shorter than 14 days. A VACUUM on day 8 can remove older versions in the managed location, which cuts how far back you can time travel. It doesn't affect rollback.
  • Retention longer than 14 days. Yes, a VACUUM on day 16 can delete the old external data. That's the documented cleanup step when predictive optimization is off, or when it's on and hasn't cleaned up a small or rarely used table. Only the data files are deleted. The Delta transaction log and the Unity Catalog reference are kept.

A few related details from the current docs:

  • SET MANAGED and UNSET MANAGED need Databricks Runtime 17.3 LTS or above, or serverless compute.
  • If you roll back, restart your streaming jobs. Commits made between conversion and rollback support time travel by version, not by timestamp, and Databricks deletes the data in the managed location seven days later.
  • On Databricks Runtime 18.1 and above, path-based redirect depends on the old Delta logs staying in the external location. Don't remove that folder by hand if anything still reads or writes by path.

Plain and simple: use the 14 days to validate, and save the manual VACUUM for after.

References:

If you found this answer helpful please check off "Accept as Solutions" so that others can have confidence in the answer.

Regards, Louis.