---
title: Troubleshoot and roll back managed table conversions
description: Troubleshoot failed `SET MANAGED` conversions and roll back Unity Catalog managed table conversions to external or foreign tables.
canonical_url: https://docs.databricks.com/gcp/en/tables/convert-to-managed-rollback
---

# Troubleshoot and roll back managed table conversions

This page describes how to resolve common `ALTER TABLE ... SET MANAGED` failures and how to roll back a converted table to an external or foreign table. To convert a table, see [Convert external or foreign Delta Lake tables to Unity Catalog managed tables](https://docs.databricks.com/gcp/en/tables/convert-to-managed.md).

## <a id="troubleshooting" />Troubleshoot conversion failures

This section describes how to resolve common issues when converting external tables to Unity Catalog managed tables using `SET MANAGED`.

### <a id="dbr-version-consistency" />`VERSIONED_CLONE_INTERNAL_ERROR.EXISTING_FILE_VALIDATION_FAILED`

If the conversion fails, always retry using the same Databricks Runtime version. Metadata can be serialized differently across versions, which causes a `VERSIONED_CLONE_INTERNAL_ERROR.EXISTING_FILE_VALIDATION_FAILED` failure if you retry a conversion on a different Databricks Runtime version.

### <a id="cluster-shutdown" />Cluster shutdown during conversion

If your cluster shuts down during conversion, the command might fail with `DELTA_ALTER_TABLE_SET_MANAGED_INTERNAL_ERROR`. Retry the command to resume the conversion.

### <a id="corrupted-external-table" />Corrupted external table

If the external table is already corrupted (for example, not valid table state), the conversion might fail with errors such as `DELTA_TRUNCATED_TRANSACTION_LOG`, `DELTA_TXN_LOG_FAILED_INTEGRITY`, or `DELTA_STATE_RECOVER_ERROR`. Before attempting conversion, verify that you can run basic operations on the external table, such as `DESCRIBE DETAIL`.

### <a id="file-validation-failure" />File validation failure

The `SET MANAGED` command validates that it copied all files in the latest snapshot of the table to the new managed table location. If any files are missing, the command fails with a [`DELTA_ALTER_TABLE_SET_MANAGED_FAILED.FILE_VALIDATION_FAILED`](https://docs.databricks.com/gcp/en/error-messages/delta-alter-table-set-managed-failed-error-class.md#file_validation_failed) error.

To resolve this issue:

1. Check your Spark driver logs to identify which files could not be migrated.
2. Verify that these files exist at the source external table location and are accessible.
3. Retry the `ALTER TABLE ... SET MANAGED` command.

If the issue persists, contact Databricks support.

## <a id="rollback" />Roll back a managed table conversion

> [!IMPORTANT]
>
> Rollback commands require Serverless compute or Databricks Runtime 17.3 LTS and above.

### <a id="rollback-external" />External table

After converting an external table to a managed table, you can roll back within 14 days by using the `UNSET MANAGED` command. This updates the table metadata to point back to the original external location. Databricks preserves all writes made to the managed location after conversion.

To roll back to an external table, run the following command:

```sql
ALTER TABLE catalog.schema.my_managed_table UNSET MANAGED;
```

Keep the following information in mind:

* If the rollback command is interrupted or fails, rerun it to retry.
* You must restart your streaming jobs after rolling back, similar to conversion.
* Commits made to the managed location between conversion and rollback allow time travel by version, not by timestamp.
* Seven days after rollback, Databricks automatically deletes data in the managed location.

### <a id="rollback-foreign-move" />Foreign table: `MOVE`

> [!WARNING]
>
> You must run `UNSET MANAGED` before dropping the managed table. Dropping the table without running `UNSET MANAGED` first might result in data loss or inconsistencies.

To roll back the table migration and regain access to the source table in the external catalog, first roll back the table to an external table with `UNSET MANAGED`. Then drop the external table to re-federate it as a foreign table.

1. To roll back to an external table, run the following command:

   ```sql
   ALTER TABLE catalog.schema.my_managed_table UNSET MANAGED
   ```

2. To re-federate the table to a foreign table, drop the external table with the following command:

   ```sql
   DROP TABLE catalog.schema.my_managed_table
   ```

The foreign table is available after the next catalog sync.

Keep the following information in mind:

* For commits that you made to the managed location between conversion and rollback, you can time travel by version, not by timestamp.
* Seven days after rollback, Databricks deletes data in the managed location.

### <a id="rollback-foreign-copy" />Foreign table: `COPY`

`UNSET MANAGED` isn't supported for tables converted with `COPY`. If you run it, the command fails with [`MIGRATION_ROLLBACK_NOT_SUPPORTED`](https://docs.databricks.com/gcp/en/error-messages/error-classes.md#migration_rollback_not_supported). The conversion left the source table in the external catalog unmodified, so to roll back, drop the managed table. Databricks re-federates it as a foreign table after the next catalog sync.

## <a id="check-rollback" />Verify rollback

Verify rollbacks differently for external and foreign tables.

### <a id="verify-external-rollback" />Verify an external table rollback

To verify that your managed table rolled back to an external table successfully, check whether the table `Type` is `EXTERNAL`. You can do either of the following:

* Open a new tab and go to the Catalog Explorer. In the **Details** tab, under **About this table**, the table **Type** displays as **External**.
* Check the table `Type` by running the following SQL command:

  ```sql
  DESCRIBE EXTENDED catalog_name.schema_name.table_name
  ```

  To check multiple tables in one query or script the check, query `information_schema.tables` instead:

  ```sql
  SELECT table_type FROM system.information_schema.tables
  WHERE table_catalog = 'catalog_name' AND table_schema = 'schema_name' AND table_name = 'table_name';
  ```

### <a id="verify-foreign-rollback" />Verify a foreign table rollback

To verify that your managed table rolled back to a foreign table successfully, check whether the table `Type` is `FOREIGN`. You can do either of the following:

* Open a new tab and go to the Catalog Explorer. In the **Details** tab, under **About this table**, the table **Type** displays as **Foreign**.
* Check the table type by running the following SQL command:

  ```sql
  SELECT table_type FROM system.information_schema.tables
  WHERE table_catalog = 'catalog_name' AND table_schema = 'schema_name' AND table_name = 'table_name';
  ```

  The `table_type` column displays as `FOREIGN`.

> [!NOTE]
>
> Don't use `DESCRIBE EXTENDED` to verify foreign table conversions or rollbacks. Federation uses `hive_metastore` catalog behavior for this command, so it shows the table `Type` as `EXTERNAL`, regardless of the table's actual state.
