{"record":{"id":"742ff89a82941ad6","repo":"aeron-io/aeron","slug":"unknown-publication","errorCode":"UNKNOWN_PUBLICATION","errorMessage":"unknown publication: ${registrationId}","messagePattern":"unknown publication: (.+?)","errorType":"error_code","errorClass":"ControlProtocolException","httpStatus":null,"severity":"error","filePath":"aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java","lineNumber":764,"sourceCode":"\n    void onRemovePublication(final long registrationId, final long correlationId, final boolean revoke)\n    {\n        PublicationLink publicationLink = null;\n        final ArrayList<PublicationLink> publicationLinks = this.publicationLinks;\n        for (int i = 0, size = publicationLinks.size(); i < size; i++)\n        {\n            final PublicationLink publication = publicationLinks.get(i);\n            if (registrationId == publication.registrationId())\n            {\n                publicationLink = publication;\n                fastUnorderedRemove(publicationLinks, i);\n                break;\n            }\n        }\n\n        if (null == publicationLink)\n        {\n            throw new ControlProtocolException(UNKNOWN_PUBLICATION, \"unknown publication: \" + registrationId);\n        }\n\n        if (revoke)\n        {\n            publicationLink.revoke();\n        }\n        publicationLink.close();\n        clientProxy.operationSucceeded(correlationId);\n    }\n\n    void onAddSendDestination(final long registrationId, final String destinationChannel, final long correlationId)\n    {\n        scheduleClientCommand(new AddSendDestinationCommand(registrationId, destinationChannel, correlationId));\n    }\n\n    void onRemoveSendDestination(final long registrationId, final String destinationChannel, final long correlationId)\n    {\n        scheduleClientCommand(new RemoveSendDestinationCommand(registrationId, destinationChannel, correlationId));","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java#L746-L782","documentation":"Thrown by Aeron's DriverConductor when a client asks the driver to remove (or revoke) a publication whose registrationId does not match any active PublicationLink in the driver. The driver tracks every publication by the registrationId returned at addPublication time; a remove command only succeeds for a still-live publication. This is a ControlProtocolException with code UNKNOWN_PUBLICATION delivered back to the requesting client.","triggerScenarios":"Calling Aeron.removePublication() (or driver control removePublication with revoke=true) with a registrationId that was never added, was already removed, or belonged to a publication closed when its client timed out.","commonSituations":"Double-removing the same publication; using a stale registrationId after a driver restart or client keepalive timeout reaped the publication; mixing up publication vs counter/subscription registration ids; caching ids across a driver reconnection.","solutions":["Verify you pass the exact registrationId returned by the addPublication future (Publication.registrationId()) and remove each publication at most once","Track publication lifecycle: ignore UNKNOWN_PUBLICATION on cleanup paths, treating it as 'already gone' rather than a failure","Check the driver is the same instance the publication was added to (driver was not restarted or clustered away)","Enable driver event log (aeron.driver.event.log) to confirm when the publication link was removed and by whom"],"exampleFix":"// before\ntry { aeron.removePublication(publication.registrationId()); } catch (ControlProtocolException e) { throw e; }\n// after\nlong regId = publication.registrationId();\ntry {\n    aeron.removePublication(regId);\n} catch (ControlProtocolException e) {\n    if (e.errorCode() == ControlProtocolException.Code.UNKNOWN_PUBLICATION) {\n        // publication already closed/reaped - treat as success on cleanup path\n    } else { throw e; }\n}","handlingStrategy":"try-catch","validationCode":"if (publication.isClosed()) { return; } // publication already gone, skip removal\nfinal long regId = publication.registrationId();","typeGuard":"boolean isKnownPublication(Aeron aeron, long registrationId) { return registrationId > 0 && !publication.isClosed(); }","tryCatchPattern":"try {\n    aeron.removePublication(regId);\n} catch (ControlProtocolException e) {\n    if (e.errorCode() != ControlProtocolException.Code.UNKNOWN_PUBLICATION) throw e;\n    // idempotent: publication already removed or reaped\n}","preventionTips":["Always capture the registrationId from the Publication object at add time","Remove each publication exactly once from a single lifecycle owner","Treat UNKNOWN_PUBLICATION as success in cleanup/shutdown paths","Watch driver event log for keepalive-timeout reaping of your publications"],"tags":["aeron","driver","publication","unknown-registration-id"],"backgroundTag":"resource-not-found","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}