Home / Databricks on Azure

Databricks on AzureRunbookAdvanced

Rolling out Unity Catalog catalog commits and multi-table transactions on Azure Databricks

Enable catalog commits on managed tables without locking them, then use BEGIN ATOMIC safely. Covers prechecks, conflict behavior, retries, foreachBatch and rollback.

Deepak Bhardwaj7 min read

Applies toAzure Databricks, Unity Catalog managed tables; DBR 16.4+ to use catalog commits, DBR 18.0+ to enable on existing tables and for BEGIN ATOMIC on clusters; SQL warehouses

A load updates fact_orders, then fails before it updates dim_customer and the load audit table. Readers see a half-finished load, and the rerun has to work out what already landed. Delta commits are atomic per table, so retries alone don't fix this.

A multi-statement transaction does, but every table it writes to must be a Unity Catalog managed table with catalog commits enabled. This runbook covers the rollout and the failure modes that follow.

What changes in the commit path

Without catalog commits, writers coordinate one table at a time through the Delta log in storage. With them, Unity Catalog coordinates the commit. Two consequences matter in operations:

  • Clients must understand the catalogManaged table feature. An older runtime that doesn't can't use the table.
  • Direct path access is no longer a valid way to work with the table. Use the three-part name.
Action Minimum compute
Create, read or write a managed table with catalog commits DBR 16.4
Read or write streaming tables and materialized views with it DBR 17.3
Enable or disable on an existing managed table DBR 18.0
BEGIN ATOMIC ... END DBR 18.0, serverless or a SQL warehouse
BEGIN TRANSACTION / COMMIT / ROLLBACK SQL warehouse only

Step 1: find incompatible readers and writers

List the tables in scope and confirm they are managed:

SELECT table_catalog, table_schema, table_name, table_type, data_source_format
FROM system.information_schema.tables
WHERE table_catalog = 'prod'
  AND table_schema = 'sales'
  AND table_name IN ('fact_orders', 'dim_customer', 'load_audit');

Then find who touches them:

SELECT entity_type, entity_id, created_by,
       max(event_time) AS last_seen, count(*) AS events
FROM system.access.table_lineage
WHERE event_date >= current_date() - INTERVAL 30 DAYS
  AND (source_table_full_name = 'prod.sales.fact_orders'
       OR target_table_full_name = 'prod.sales.fact_orders')
GROUP BY ALL
ORDER BY last_seen DESC;

Find classic clusters still on old runtimes:

SELECT cluster_id, cluster_name, dbr_version, owned_by
FROM (
  SELECT *, row_number() OVER (PARTITION BY workspace_id, cluster_id
                               ORDER BY change_time DESC) AS rn
  FROM system.compute.clusters
)
WHERE rn = 1
  AND delete_time IS NULL
  AND try_cast(regexp_extract(dbr_version, '([0-9]+[.][0-9]+)', 1) AS DECIMAL(4,1)) < 16.4;

Lineage doesn't show everything. Ask separately about external engines, Delta Sharing recipients, and jobs that read the storage path.

Warning

Catalog commits on streaming tables and materialized views are not compatible with external data access. Single-user (dedicated) clusters also can't access streaming tables that have the feature. Test sharing recipients too: shared tables are served through pre-signed URLs instead of cloud tokens.

Step 2: enable it on a quiet table first

For a new table:

CREATE TABLE prod.sales.load_audit (
  batch_id STRING,
  table_name STRING,
  row_count BIGINT,
  loaded_at TIMESTAMP
)
TBLPROPERTIES ('delta.feature.catalogManaged' = 'supported');

For an existing managed table, on DBR 18.0 or above:

ALTER TABLE prod.sales.fact_orders
SET TBLPROPERTIES ('delta.feature.catalogManaged' = 'supported');

DESCRIBE DETAIL prod.sales.fact_orders;   -- tableFeatures includes catalogManaged

Caution

Don't cancel the upgrade, or the downgrade, part-way. An interrupted change can lock the table against all reads and writes. If it is interrupted, run the same command again. If the table stays locked, open a support case. On write-heavy tables the change can take several minutes, so pause writers and use a job whose timeout won't kill it.

You can't turn the feature on or off with CREATE OR REPLACE TABLE or REPLACE TABLE. For streaming tables and materialized views, put the property in the CREATE OR REFRESH definition and run an update. ALTER TABLE ... SET TBLPROPERTIES isn't supported there.

Restart one copy of each streaming consumer in test before you change production. Streaming reads can fail on commits that change table metadata and then need a restart.

Step 3: use the non-interactive form for jobs

BEGIN ATOMIC
  MERGE INTO prod.sales.dim_customer AS t
  USING prod.staging.customer_batch AS s
  ON t.customer_id = s.customer_id
  WHEN MATCHED THEN UPDATE SET t.segment = s.segment, t.updated_at = s.updated_at
  WHEN NOT MATCHED THEN INSERT (customer_id, segment, updated_at)
    VALUES (s.customer_id, s.segment, s.updated_at);

  INSERT INTO prod.sales.fact_orders
  SELECT order_id, customer_id, amount, order_date
  FROM prod.staging.order_batch;

  IF (SELECT count(*) FROM prod.staging.order_batch WHERE amount < 0) > 0 THEN
    SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'negative amounts in order_batch';
  END IF;

  INSERT INTO prod.sales.load_audit
  SELECT '2026-11-25-01', 'fact_orders', count(*), current_timestamp()
  FROM prod.staging.order_batch;
END;

Any error, including SIGNAL, rolls the whole block back. Run DDL before the block, because CREATE, ALTER and DROP TABLE aren't allowed in a transaction. Time travel isn't allowed either.

Use the interactive form for supervised fixes from a SQL warehouse. Issue ROLLBACK; first to clear anything left open in the session. Interactive transactions roll back after 10 minutes idle.

Step 4: design for conflicts

Transactions are optimistic. Nothing is locked, and conflicts surface at commit.

Form Conflict granularity Use for
BEGIN ATOMIC Row level, if row-level concurrency applies to the target Scheduled jobs
BEGIN TRANSACTION Table level, except unconditional appends Manual fixes, small driver workloads

The first access to a table fixes its snapshot for the transaction. A 40-minute transaction therefore exposes 40 minutes of other writers' commits to conflict. Keep expensive work outside: compute results into staging tables, then open a short transaction that only merges and inserts.

Retry the whole unit, and reread the data each time:

import random, time

def run_atomic(sql_text, attempts=4):
    for n in range(attempts):
        try:
            return spark.sql(sql_text)
        except Exception as e:
            msg = str(e).upper()
            if "CONCURRENT" not in msg and "CONFLICT" not in msg:
                raise
            if n == attempts - 1:
                raise
            time.sleep(2 ** n * 5 + random.random() * 5)

Match on the error class your runtime reports. Names vary by version, so check a real conflict in test and tighten the filter. Don't retry a SIGNAL, because it is a data problem.

Step 5: know the limits

  • 100 tables read or written combined, 100 views, and up to 100 intermediate commits per table. Check the current limits before designing a large load.
  • A transaction rolls back after 48 hours in total, or when the session disconnects.
  • Path reads such as parquet.`abfss://...` raise PATH_BASED_ACCESS. Load files to a staging table first.
  • Federated or external file reads need WITH (allow_nontransactional_read = true) and aren't repeatable.
  • Lineage events remain after a rollback. Don't use lineage as proof that a load committed.

foreachBatch isn't exactly-once by itself

You can run BEGIN ATOMIC inside foreachBatch, but the checkpoint doesn't advance in the same transaction. If the driver dies between the commit and the checkpoint, the batch is replayed. Insert batchId and the stream name into a control table in the same transaction, and skip the batch when that row already exists. This also needs a single writer per stream.

Roll back the rollout

If a critical client can't read the table, upgrade the client first if you can. If you can't, stop all writers, then on DBR 18.0+ drop the feature:

ALTER TABLE prod.sales.fact_orders DROP FEATURE catalogManaged;
DESCRIBE DETAIL prod.sales.fact_orders;

DROP FEATURE conflicts with every concurrent write and adds the checkpointProtection writer feature. Some old writers won't accept that. The full downgrade uses TRUNCATE HISTORY, needs a 24-hour wait, and removes older history and time travel. Read the documented procedure before choosing it.

Prevent it next time

  • Set minimum runtimes in compute policies before enabling the feature.
  • Add tableFeatures from DESCRIBE DETAIL to your table inventory, and alert on unexpected changes.
  • Put tables that share a transaction in the same rollout wave.
  • Keep transactions short and alert on retry counts. Rising retries mean two jobs need separate schedules or keys.
  • Watch the release notes for automatic upgrades of managed tables to catalog commits.