{"record":{"id":"c9bffaacae615a04","repo":"apache/pulsar","slug":"topic-was-already-migrated","errorCode":null,"errorMessage":"Topic was already migrated","messagePattern":"Topic was already migrated","errorType":"exception","errorClass":"TopicMigratedException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java","lineNumber":936,"sourceCode":"                .getSchemaRegistryService()\n                .checkConsumerCompatibility(id, schema, getSchemaCompatibilityStrategy());\n    }\n\n    @Override\n    public CompletableFuture<Optional<Long>> addProducer(Producer producer,\n                                                         CompletableFuture<Void> producerQueuedFuture) {\n        checkArgument(producer.getTopic() == this);\n\n        return brokerService.checkTopicNsOwnership(getName())\n                .thenCompose(__ ->\n                        incrementTopicEpochIfNeeded(producer, producerQueuedFuture))\n                .thenCompose(producerEpoch -> {\n                    lock.writeLock().lock();\n                    try {\n                        checkTopicFenced();\n                        if (isMigrated()) {\n                            log.warn(\"Attempting to add producer to a migrated topic\");\n                            throw new TopicMigratedException(\"Topic was already migrated\");\n                        } else if (isTerminated()) {\n                            log.warn(\"Attempting to add producer to a terminated topic\");\n                            throw new TopicTerminatedException(\"Topic was already terminated\");\n                        }\n                        return internalAddProducer(producer).thenApply(ignore -> {\n                            USAGE_COUNT_UPDATER.incrementAndGet(this);\n                            log.debug()\n                                    .attr(\"producerName\", producer.getProducerName())\n                                    .attr(\"usageCount\", USAGE_COUNT_UPDATER.get(this))\n                                    .log(\"Added producer\");\n                            return producerEpoch;\n                        });\n                    } catch (BrokerServiceException e) {\n                        return FutureUtil.failedFuture(e);\n                    } finally {\n                        lock.writeLock().unlock();\n                    }\n                });","sourceCodeStart":918,"sourceCodeEnd":954,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java#L918-L954","documentation":"During addProducer, the topic's switch-state check found the topic already migrated to another cluster (part of topic migration); producers cannot attach to a topic whose ownership has moved, so the connection is refused.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java:936 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Let the client reconnect — the lookup will be redirected to the new owner","Retry after the migration completes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}