{"record":{"id":"ddddce9c040e3d7c","repo":"nathanmarz/storm","slug":"received-commit-for-different-transaction-attempt","errorCode":null,"errorMessage":"Received commit for different transaction attempt","messagePattern":"Received commit for different transaction attempt","errorType":"exception","errorClass":"FailedException","httpStatus":null,"severity":"error","filePath":"storm-core/src/jvm/storm/trident/spout/TridentSpoutExecutor.java","lineNumber":73,"sourceCode":"        _streamName = streamName;\n    }\n    \n    @Override\n    public void prepare(Map conf, TopologyContext context, BatchOutputCollector collector) {\n        _emitter = _spout.getEmitter(_txStateId, conf, context);\n        _collector = new AddIdCollector(_streamName, collector);\n    }\n\n    @Override\n    public void execute(BatchInfo info, Tuple input) {\n        // there won't be a BatchInfo for the success stream\n        TransactionAttempt attempt = (TransactionAttempt) input.getValue(0);\n        if(input.getSourceStreamId().equals(MasterBatchCoordinator.COMMIT_STREAM_ID)) {\n            if(attempt.equals(_activeBatches.get(attempt.getTransactionId()))) {\n                ((ICommitterTridentSpout.Emitter) _emitter).commit(attempt);\n                _activeBatches.remove(attempt.getTransactionId());\n            } else {\n                 throw new FailedException(\"Received commit for different transaction attempt\");\n            }\n        } else if(input.getSourceStreamId().equals(MasterBatchCoordinator.SUCCESS_STREAM_ID)) {\n            // valid to delete before what's been committed since \n            // those batches will never be accessed again\n            _activeBatches.headMap(attempt.getTransactionId()).clear();\n            _emitter.success(attempt);\n        } else {            \n            _collector.setBatch(info.batchId);\n            _emitter.emitBatch(attempt, input.getValue(1), _collector);\n            _activeBatches.put(attempt.getTransactionId(), attempt);\n        }\n    }\n\n    @Override\n    public void cleanup() {\n        _emitter.close();\n    }\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-core/src/jvm/storm/trident/spout/TridentSpoutExecutor.java#L55-L91","documentation":"During Trident batch processing, the commit stream delivers a TransactionAttempt that must match the attempt the executor recorded for that transaction id. If the attempt on the commit stream differs from the one stored in _activeBatches, the batch state is inconsistent (e.g. a replay with a new attempt id) and Trident throws FailedException so the batch is replayed.","triggerScenarios":"A commit tuple arrives on MasterBatchCoordinator.COMMIT_STREAM_ID whose TransactionAttempt does not equal the active attempt registered for the same transaction id — typically after topology restarts/replays where the spout re-emits a transaction with a different attempt number.","commonSituations":"Topology rebalanced or restarted mid-transaction; expired messages causing rebroadcast with a new attempt; misbehaving custom spout emitting mismatched attempts.","solutions":["Let the FailedException propagate — Trident will replay the batch with the correct attempt","Verify the spout/emitter are stateless and correctly re-registered attempts after restart","Check MasterBatchCoordinator zk state for stale transaction metadata and ensure only one topology uses the same state location"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Trident worker: FailedException marks batch for replay\ntry {\n  executor.execute(tuple);\n} catch (FailedException e) {\n  LOG.warn(\"Commit attempt mismatch; batch will be replayed\", e);\n  // do not ack; let Trident replay with the correct attempt\n}","preventionTips":["Keep spout emitter stateless so replays are idempotent","Avoid sharing zk transaction state between topologies","Ensure topology.name and state locations stay stable across restarts"],"tags":["storm","trident","transaction","distributed"],"backgroundTag":"invalid-state-transition","analyzedSha":"cdb116e942666973bc4eaa0df098d5bab82739e7","analyzedAt":"2026-09-12T14:30:00.714Z","contentChangedAt":"2026-09-12T14:30:00.714Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}