prestodb/presto · error · IllegalStateException

Cannot perform Metastore updates in replay mode

Error message

Cannot perform Metastore updates in replay mode

What it means

verifyRecordingMode is a shared guard used by all metastore update operations (create/drop/rename, statistics updates, etc.): in replay mode the metastore is read-only against a recorded log, so any write/update request is rejected with this IllegalStateException to protect the recording's integrity.

Solutions

  1. Run the cluster in recording mode (replay disabled) if write operations are expected
  2. Replay sessions should only issue read operations; move updates to a non-replay deployment
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/RecordingHiveMetastore.java:538 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/0237bf5d77dbee01. Report an issue: GitHub.

Appendix: source

Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/RecordingHiveMetastore.java:538

        return delegate.addConstraint(metastoreContext, databaseName, tableName, tableConstraint);
    }

    private <K, V> V loadValue(Cache<K, V> cache, K key, Supplier<V> valueSupplier)
    {
        if (replay) {
            return Optional.ofNullable(cache.getIfPresent(key))
                    .orElseThrow(() -> new PrestoException(NOT_FOUND, "Missing entry found for key: " + key));
        }

        V value = valueSupplier.get();
        cache.put(key, value);
        return value;
    }

    private void verifyRecordingMode()
    {
        if (replay) {
            throw new IllegalStateException("Cannot perform Metastore updates in replay mode");
        }
    }

    @Immutable
    public static class Recording
    {
        private final Optional<List<String>> allDatabases;
        private final Optional<Set<String>> allRoles;
        private final List<Pair<String, Optional<Database>>> databases;
        private final List<Pair<HiveTableHandle, Optional<Table>>> tables;
        private final List<Pair<HiveTableName, List<TableConstraint<String>>>> tableConstraints;
        private final List<Pair<String, Set<ColumnStatisticType>>> supportedColumnStatistics;
        private final List<Pair<HiveTableName, PartitionStatistics>> tableStatistics;
        private final List<Pair<Set<HivePartitionName>, Map<String, PartitionStatistics>>> partitionStatistics;
        private final List<Pair<String, Optional<List<String>>>> allTables;
        private final List<Pair<String, Optional<List<String>>>> allViews;
        private final List<Pair<HivePartitionName, Optional<Partition>>> partitions;
        private final List<Pair<HiveTableName, Optional<List<PartitionNameWithVersion>>>> partitionNames;

View on GitHub (pinned to 55bb57d202)