apache/iceberg · error · RuntimeException

Metastore operation failed for %s.%s

Error message

Metastore operation failed for %s.%s

What it means

A generic Thrift (TException) failure occurred while performing the metastore commit for the view. Iceberg could not classify it as a known commit state, so it wraps the exception in a RuntimeException naming the database and view. The original Thrift exception is the cause and indicates the true failure (connectivity, permissions, etc.).

Source

Thrown at hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java:253

            e);
        commitStatus = BaseMetastoreOperations.CommitStatus.UNKNOWN;
        commitStatus =
            checkCommitStatus(
                viewName,
                newMetadataLocation,
                metadata.properties(),
                () -> checkCurrentMetadataLocation(newMetadataLocation));
        switch (commitStatus) {
          case SUCCESS:
            break;
          case FAILURE:
            throw e;
          case UNKNOWN:
            throw new CommitStateUnknownException(e);
        }
      }
    } catch (TException e) {
      throw new RuntimeException(
          String.format("Metastore operation failed for %s.%s", database, viewName), e);

    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new RuntimeException("Interrupted during commit", e);

    } catch (LockException e) {
      throw new CommitFailedException(e);

    } finally {
      HiveOperationsBase.cleanupMetadataAndUnlock(io(), commitStatus, newMetadataLocation, lock);
    }

    LOG.info(
        "Committed to view {} with the new metadata location {}", fullName, newMetadataLocation);
  }

  /**

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Inspect the cause chain (e.getCause) for the underlying TException to find the real failure.
  2. Verify metastore connectivity (host, port, hive.metastore.uris) and retry the commit.
  3. Confirm the view still exists and the user has ALTER privileges in Hive.
  4. Align the iceberg-hive-metastore Thrift version with the deployed Hive metastore version.

Example fix

// before
try {
  view.refresh(); view.updateSQL()...commit();
} catch (RuntimeException e) {
  // swallowed, no diagnosis
}

// after
try {
  view.updateSQL()...commit();
} catch (RuntimeException e) {
  if (e.getCause() instanceof TException) {
    LOG.error("Metastore unreachable: {}", e.getCause().getMessage());
    // check metastore health then retry
  }
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// health-check the metastore before writes
// hive.client.getAllDatabases() should succeed; check hive.metastore.uris reachability

Try / catch

try {
  view.updateSQL()...commit();
} catch (RuntimeException e) {
  Throwable cause = e.getCause();
  if (cause instanceof org.apache.thrift.TException) {
    // inspect cause: connectivity? permissions? missing view?
  }
  throw e;
}

Prevention

When it happens

Trigger: doCommit invoking metastore client calls (alter_view, check locks) that throw any TException not mapped to KNOWN commit states; network drop to metastore; missing view; thrift protocol mismatch.

Common situations: Metastore restarted or unreachable during a write; view dropped by another user mid-commit; Hive metastore version incompatibility with the Thrift client.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/1973ef98739b3b26. Report an issue: GitHub.