{"record":{"id":"4b039f0fecba7b0f","repo":"apache/cassandra","slug":"can-not-advance-in-progress-sequence-since-its-ki","errorCode":null,"errorMessage":"Can not advance in-progress sequence, since its kind is %s, but not %s","messagePattern":"Can not advance 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":184,"sourceCode":"        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);\n        if (sequence.kind() != MultiStepOperation.Kind.RECONFIGURE_CMS)\n            throw new IllegalStateException(String.format(\"Can not advance in-progress sequence, since its kind is %s, but not %s\", sequence.kind(), MultiStepOperation.Kind.RECONFIGURE_CMS));\n\n        ReconfigureCMS transitionCMS = (ReconfigureCMS) sequence;\n        try\n        {\n            if (transitionCMS.next.activeTransition != null)\n            {\n                // An active transition represents a joining member which has been added as a write replica, but must\n                // stream up to date distributed log tables before being able to serve reads & participate in quorums.\n                // If this is the case, do that streaming now.\n                ActiveTransition activeTransition = transitionCMS.next.activeTransition;\n                InetAddressAndPort endpoint = metadata.directory.endpoint(activeTransition.nodeId);\n                Replica replica = new Replica(endpoint, entireRange, true);\n                streamRanges(replica, activeTransition.streamCandidates(metadata.directory));\n            }\n            else\n            {\n                // Run a paxos repair before starting either the addition or removal of a CMS member, where in both\n                // cases there is no active transition.","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tcm/sequences/ReconfigureCMS.java#L166-L202","documentation":"Thrown by ReconfigureCMS.executeNext when the in-progress sequence under the ReconfigureCMS SequenceKey has a kind other than RECONFIGURE_CMS. executeNext advances the current step of the sequence; the kind check guards against advancing a foreign sequence as if it were a CMS reconfiguration.","triggerScenarios":"Invoking executeNext (e.g. to advance a CMS reconfiguration after a barrier) while the SequenceKey slot holds a different MultiStepOperation kind.","commonSituations":"Racing topology operations occupying the same SequenceKey; resuming a sequence after a partially applied log replay where the key was reused; automation calling executeNext without re-validating current metadata state.","solutions":["Wait for the occupying sequence to complete before calling executeNext again","Re-read ClusterMetadata.current() and confirm the sequence kind before advancing","Serialize topology operations so only one multi-step sequence is in flight","Investigate the metadata log if the key was reused across operation types"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"MultiStepOperation<?> seq = ClusterMetadata.current().inProgressSequences.get(SequenceKey.instance);\nif (seq == null || seq.kind() != MultiStepOperation.Kind.RECONFIGURE_CMS)\n    return; // skip advance; wrong or absent sequence","typeGuard":null,"tryCatchPattern":"try { reconfigureCMS.executeNext(); }\ncatch (IllegalStateException e) { if (e.getMessage().contains(\"Can not advance in-progress sequence\")) revalidateAndRetry(); else throw e; }","preventionTips":["Re-read current metadata immediately before each executeNext call","Only one multi-step sequence should be in flight at any time","Guard automation loops with kind checks before advancing"],"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"}