{"record":{"id":"aa57c4ff2943adfa","repo":"apache/cassandra","slug":"can-not-apply-in-progress-sequence-since-its-kind","errorCode":null,"errorMessage":"Can not apply in-progress sequence, since its kind is %s, but not %s","messagePattern":"Can not apply in-progress sequence, since its kind is (.+?), but not (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tcm/sequences/ReconfigureCMS.java","lineNumber":164,"sourceCode":"    }\n\n    @Override public Transformation.Kind nextStep()\n    {\n        return next.kind();\n    }\n\n    @Override\n    public Set<NodeId> affectedPeers(Directory directory)\n    {\n        return Set.of();\n    }\n\n    @Override\n    public Transformation.Result applyTo(ClusterMetadata metadata)\n    {\n        MultiStepOperation<?> sequence = metadata.inProgressSequences.get(SequenceKey.instance);\n        if (sequence.kind() != MultiStepOperation.Kind.RECONFIGURE_CMS)\n            throw new IllegalStateException(String.format(\"Can not apply in-progress sequence, since its kind is %s, but not %s\", sequence.kind(), MultiStepOperation.Kind.RECONFIGURE_CMS));\n        Epoch lastModifiedEpoch = metadata.epoch;\n        ImmutableSet.Builder<MetadataKey> modifiedKeys = ImmutableSet.builder();\n        while (metadata.inProgressSequences.contains(SequenceKey.instance))\n        {\n            ReconfigureCMS transitionCMS = (ReconfigureCMS) metadata.inProgressSequences.get(SequenceKey.instance);\n            Transformation.Result result = transitionCMS.next.execute(metadata);\n            assert result.isSuccess();\n            metadata = result.success().metadata.forceEpoch(lastModifiedEpoch);\n            modifiedKeys.addAll(result.success().affectedMetadata);\n        }\n        return new Transformation.Success(metadata.forceEpoch(lastModifiedEpoch.nextEpoch()), LockedRanges.AffectedRanges.EMPTY, modifiedKeys.build());\n    }\n\n    @Override\n    public SequenceState executeNext()\n    {\n        ClusterMetadata metadata = ClusterMetadata.current();\n        MultiStepOperation<?> sequence = metadata.inProgressSequences.get(SequenceKey.instance);","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tcm/sequences/ReconfigureCMS.java#L146-L182","documentation":"Thrown by ReconfigureCMS.applyTo when the in-progress sequence stored under the ReconfigureCMS SequenceKey has a kind other than MultiStepOperation.Kind.RECONFIGURE_CMS. applyTo expects to drive an in-progress CMS reconfiguration to completion; a different sequence kind under that key means the metadata state does not match what the transformation assumes.","triggerScenarios":"Committing/apply-ing a ReconfigureCMS transformation while metadata.inProgressSequences.get(SequenceKey.instance) holds some other MultiStepOperation (e.g. a Move or Bootstrap sequence) under the same key.","commonSituations":"Overlapping topology operations: starting a CMS reconfiguration while another multi-step operation occupies the SequenceKey; replay/recovery of a metadata log where sequences were interleaved; concurrent nodetool operations racing.","solutions":["Let the conflicting in-progress sequence finish before initiating the CMS reconfiguration","Inspect ClusterMetadata.current().inProgressSequences to identify the wrongly keyed sequence","Ensure only one topology operation runs at a time (serialize operator actions)","If caused by a metadata log anomaly, restore consistency per the project's TCM recovery guidance and file a bug"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"MultiStepOperation<?> seq = ClusterMetadata.current().inProgressSequences.get(SequenceKey.instance);\nif (seq != null && seq.kind() != MultiStepOperation.Kind.RECONFIGURE_CMS)\n    throw new PreconditionFailed(\"SequenceKey occupied by \" + seq.kind());","typeGuard":null,"tryCatchPattern":"try { clusterMetadataService.commit(new ReconfigureCMS(...)); }\ncatch (IllegalStateException e) { if (e.getMessage().contains(\"Can not apply in-progress sequence\")) waitForOtherSequenceThenRetry(); else throw e; }","preventionTips":["Serialize topology operations; never run overlapping nodetool/TCM operations","Check inProgressSequences before initiating a CMS reconfiguration","Verify sequence kind after any metadata log replay or recovery"],"tags":["tcm","invalid-state","cms","multi-step-operation"],"backgroundTag":"invalid-state-transition","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}