{"record":{"id":"b39165a4f8702a60","repo":"apache/pulsar","slug":"error-starting-logtopic-producer-for-function-s","errorCode":null,"errorMessage":"Error starting LogTopic Producer for function %s","messagePattern":"Error starting LogTopic Producer for function (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/LogAppender.java","lineNumber":123,"sourceCode":"    @Override\n    public void initialize() {\n        this.state = State.INITIALIZED;\n    }\n\n    @Override\n    public void start() {\n        this.state = State.STARTING;\n        try {\n            producer = pulsarClient.newProducer()\n                    .topic(logTopic)\n                    .blockIfQueueFull(false)\n                    .enableBatching(true)\n                    .compressionType(CompressionType.LZ4)\n                    .batchingMaxPublishDelay(100, TimeUnit.MILLISECONDS)\n                    .property(\"function\", fqn)\n                    .create();\n        } catch (Exception e) {\n            throw new RuntimeException(\"Error starting LogTopic Producer for function \" + fqn, e);\n        }\n        this.state = State.STARTED;\n    }\n\n    @Override\n    public void stop() {\n        this.state = State.STOPPING;\n        if (producer != null) {\n            producer.closeAsync();\n            producer = null;\n        }\n        this.state = State.STOPPED;\n    }\n\n    @Override\n    public boolean isStarted() {\n        return state == State.STARTED;\n    }","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/LogAppender.java#L105-L141","documentation":"LogAppender.start() creates a Pulsar Producer bound to the function's log topic (batched, LZ4-compressed). If producer creation throws for any reason (broker unreachable, authorization, topic issues, client config), the appender wraps it in a RuntimeException naming the function FQN, preserving the cause.","triggerScenarios":"Broker unavailable or TLS/auth misconfigured when the function instance starts; the function service account lacks produce permission on the log topic; log topic namespace doesn't exist and auto-creation is disabled; invalid producer config (e.g. bad serviceUrl).","commonSituations":"Function workers pointed at the wrong cluster; logTopic set to an illegal topic name; token/cert expiry at instance startup; network policy blocking broker port from function pods; Pulsar topic auto-creation disabled.","solutions":["Read the wrapped cause (e) in the stack trace — fix the underlying producer error (connectivity, auth, topic)","Verify the function's logTopic configuration points to a valid topic on the correct cluster/serviceUrl","Grant the function's role produce permissions on the log topic namespace (grant permissions on the namespace/topic)","Enable topic auto-creation or create the log topic manually; check broker reachability and TLS/auth settings from the function instance"],"exampleFix":"// before (conf/worker or function config)\nlogTopic: persistent://public/default/does-not-exist\n// after\nlogTopic: persistent://public/default/functions-logs\n# and grant produce rights:\n# pulsar-admin namespaces grant-permissions public/default --role functions-role --actions produce","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { logAppender.start(); }\ncatch (RuntimeException e) {\n  Throwable cause = e.getCause();\n  log.error(\"Log topic producer failed for function: \" + e.getMessage(), cause);\n  // inspect cause: connectivity, authorization, or topic issues\n}","preventionTips":["Pre-create the log topic or enable auto-creation on the namespace","Grant the function role produce permission on the log topic","Verify serviceUrl/TLS/auth config from the function instance environment","Include the cause chain when debugging; it names the real producer failure","Test log-topic connectivity from a pod/instance before deploying"],"tags":["java","pulsar-functions","producer","log-topic","startup"],"backgroundTag":"producer-creation-failed","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"}