{"record":{"id":"0237bf5d77dbee01","repo":"prestodb/presto","slug":"cannot-perform-metastore-updates-in-replay-mode","errorCode":null,"errorMessage":"Cannot perform Metastore updates in replay mode","messagePattern":"Cannot perform Metastore updates in replay mode","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/RecordingHiveMetastore.java","lineNumber":538,"sourceCode":"        return delegate.addConstraint(metastoreContext, databaseName, tableName, tableConstraint);\n    }\n\n    private <K, V> V loadValue(Cache<K, V> cache, K key, Supplier<V> valueSupplier)\n    {\n        if (replay) {\n            return Optional.ofNullable(cache.getIfPresent(key))\n                    .orElseThrow(() -> new PrestoException(NOT_FOUND, \"Missing entry found for key: \" + key));\n        }\n\n        V value = valueSupplier.get();\n        cache.put(key, value);\n        return value;\n    }\n\n    private void verifyRecordingMode()\n    {\n        if (replay) {\n            throw new IllegalStateException(\"Cannot perform Metastore updates in replay mode\");\n        }\n    }\n\n    @Immutable\n    public static class Recording\n    {\n        private final Optional<List<String>> allDatabases;\n        private final Optional<Set<String>> allRoles;\n        private final List<Pair<String, Optional<Database>>> databases;\n        private final List<Pair<HiveTableHandle, Optional<Table>>> tables;\n        private final List<Pair<HiveTableName, List<TableConstraint<String>>>> tableConstraints;\n        private final List<Pair<String, Set<ColumnStatisticType>>> supportedColumnStatistics;\n        private final List<Pair<HiveTableName, PartitionStatistics>> tableStatistics;\n        private final List<Pair<Set<HivePartitionName>, Map<String, PartitionStatistics>>> partitionStatistics;\n        private final List<Pair<String, Optional<List<String>>>> allTables;\n        private final List<Pair<String, Optional<List<String>>>> allViews;\n        private final List<Pair<HivePartitionName, Optional<Partition>>> partitions;\n        private final List<Pair<HiveTableName, Optional<List<PartitionNameWithVersion>>>> partitionNames;","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/RecordingHiveMetastore.java#L520-L556","documentation":"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.","triggerScenarios":"Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/RecordingHiveMetastore.java:538 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the cluster in recording mode (replay disabled) if write operations are expected","Replay sessions should only issue read operations; move updates to a non-replay deployment"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}