{"record":{"id":"592e0b2dd697421b","repo":"elastic/elasticsearch","slug":"cannot-create-past-tsdb-backing-index-for-replicat","errorCode":null,"errorMessage":"Cannot create past TSDB backing index for replicated data stream [{}]","messagePattern":"Cannot create past TSDB backing index for replicated data stream \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/TransportPastTimeSeriesIndexCreationAction.java","lineNumber":522,"sourceCode":"        public void init() {\n            clusterService.getClusterSettings()\n                .addSettingsUpdateConsumer(PAST_TSDB_INDEX_INTERVAL, tv -> indexIntervalMillis = tv.millis());\n        }\n    }\n\n    record CoveredTimeWindow(long start, long end) {\n\n        CoveredTimeWindow(Instant start, Instant end) {\n            this(start.toEpochMilli(), end.toEpochMilli());\n        }\n    }\n\n    private static void validateDataStream(String dataStreamName, DataStream dataStream, ProjectMetadata project) {\n        if (dataStream == null) {\n            throw new ResourceNotFoundException(\"Data stream [\" + dataStreamName + \"] not found\");\n        }\n        if (dataStream.isReplicated()) {\n            throw new IllegalArgumentException(\"Cannot create past TSDB backing index for replicated data stream [\" + dataStreamName + \"]\");\n        }\n        if (dataStream.isSystem()) {\n            throw new IllegalArgumentException(\"Cannot create past TSDB backing index for system data stream [\" + dataStreamName + \"]\");\n        }\n\n        if (IndexMode.isTsdb(dataStream.getIndexMode()) == false) {\n            throw new IllegalArgumentException(\n                \"Cannot create past TSDB backing index for data stream [\"\n                    + dataStreamName\n                    + \"] with mode [\"\n                    + dataStream.getIndexMode()\n                    + \"], it needs to be a time series data stream.\"\n            );\n        }\n        Index writeIndex = dataStream.getWriteIndex();\n        IndexMetadata writeIndexMetadata = writeIndex == null ? null : project.index(writeIndex);\n        if (writeIndexMetadata == null || IndexMode.isTsdb(writeIndexMetadata.getIndexMode()) == false) {\n            throw new IllegalStateException(","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/TransportPastTimeSeriesIndexCreationAction.java#L504-L540","documentation":"Thrown by validateDataStream when the data stream exists but isReplicated() returns true (a cross-cluster-replication follower data stream). Past TSDB backing index creation is a write operation that must run on the leader; follower streams are read-only replicas and cannot have new backing indices minted on the follower side.","triggerScenarios":"Calling the past TSDB index creation API on a data stream that is a CCR follower. The check runs right after the not-found check and before the tsdb-mode check.","commonSituations":"Operating on the follower cluster instead of the leader; automation that targets all streams without filtering out replicated ones.","solutions":["Run the past TSDB index creation request against the leader data stream, not the replicated follower.","Filter replicated streams out of any bulk/batch backfill job using the is_replicated flag from GET _data_stream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (dataStream.isReplicated()) {\n  throw new IllegalArgumentException(\"Cannot create past TSDB backing index for replicated data stream\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run past TSDB index creation on the leader cluster only.","Filter is_replicated=true streams out of batch backfill jobs."],"tags":["data-streams","ccr","replication","past-index-creation","elasticsearch"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}