prestodb/presto · error · IllegalStateException

Cannot write recording in replay mode

Error message

Cannot write recording in replay mode

What it means

RecordingHiveMetastore.writeRecording is a JMX managed operation that flushes recorded metastore calls to disk. In replay mode no recording is being captured, so calling writeRecording is a usage error and an IllegalStateException is raised; only a recording-mode metastore can write a recording.

Solutions

  1. Run the metastore in recording mode (replay disabled) before invoking writeRecording via JMX
  2. If the goal is to consume a recording, use replay mode and read the previously captured file instead of writing
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/RecordingHiveMetastore.java:153 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/779e1fff0bcbf897. Report an issue: GitHub.

Appendix: source

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

    private static <K, V> Cache<K, V> createCache(MetastoreClientConfig metastoreClientConfig)
    {
        if (metastoreClientConfig.isReplay()) {
            return CacheBuilder.<K, V>newBuilder()
                    .build();
        }

        return CacheBuilder.<K, V>newBuilder()
                .expireAfterWrite(metastoreClientConfig.getRecordingDuration().toMillis(), MILLISECONDS)
                .build();
    }

    @Managed
    public void writeRecording()
            throws IOException
    {
        if (replay) {
            throw new IllegalStateException("Cannot write recording in replay mode");
        }

        Recording recording = new Recording(
                allDatabases,
                allRoles,
                toPairs(databaseCache),
                toPairs(tableCache),
                toPairs(tableConstraintsCache),
                toPairs(supportedColumnStatisticsCache),
                toPairs(tableStatisticsCache),
                toPairs(partitionStatisticsCache),
                toPairs(allTablesCache),
                toPairs(allViewsCache),
                toPairs(partitionCache),
                toPairs(partitionNamesCache),
                toPairs(partitionNamesByFilterCache),
                toPairs(partitionsByNamesCache),
                toPairs(tablePrivilegesCache),

View on GitHub (pinned to 55bb57d202)