{"record":{"id":"6e42e869534f3469","repo":"apache/pulsar","slug":"fullfunctionname-has-not-been-assigned-yet","errorCode":null,"errorMessage":"${fullFunctionName} has not been assigned yet","messagePattern":"(.+?) has not been assigned yet","errorType":"http","errorClass":"WebApplicationException","httpStatus":400,"severity":"error","filePath":"pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionRuntimeManager.java","lineNumber":391,"sourceCode":"        }\n\n        final String assignedWorkerId = assignment.getWorkerId();\n        final String workerId = this.workerConfig.getWorkerId();\n\n        if (assignedWorkerId.equals(workerId)) {\n            stopFunction(FunctionCommon.getFullyQualifiedInstanceId(assignment.getInstance()), true);\n            return;\n        } else {\n            // query other worker\n            List<WorkerInfo> workerInfoList = this.membershipManager.getCurrentMembership();\n            WorkerInfo workerInfo = null;\n            for (WorkerInfo entry : workerInfoList) {\n                if (assignment.getWorkerId().equals(entry.getWorkerId())) {\n                    workerInfo = entry;\n                }\n            }\n            if (workerInfo == null) {\n                throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST)\n                        .type(MediaType.APPLICATION_JSON)\n                        .entity(new ErrorData(fullFunctionName + \" has not been assigned yet\")).build());\n            }\n\n            if (uri == null) {\n                throw new WebApplicationException(Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build());\n            } else {\n                URI redirect = UriBuilder.fromUri(uri).host(workerInfo.getWorkerHostname())\n                        .port(workerInfo.getPort()).build();\n                throw new WebApplicationException(Response.temporaryRedirect(redirect).build());\n            }\n        }\n    }\n\n    public synchronized void restartFunctionInstances(String tenant, String namespace, String functionName)\n            throws Exception {\n        final String fullFunctionName = String.format(\"%s/%s/%s\", tenant, namespace, functionName);\n        Collection<Assignment> assignments = this.findFunctionAssignments(tenant, namespace, functionName);","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionRuntimeManager.java#L373-L409","documentation":"After finding the assignment, restartFunctionInstance resolves the worker that owns it by scanning workerInfoList for the assignment's workerId. If no WorkerInfo matches (workerInfo stays null), the assigned worker is unknown — the manager throws WebApplicationException (BAD_REQUEST) with '<fullFunctionName> has not been assigned yet'.","triggerScenarios":"An assignment exists but its workerId is absent from the current membership list (workerInfoList) — typically because the worker that owned the instance died/left the cluster and membership hasn't been reconciled, or the assignment is stale mid-failover.","commonSituations":"Restart attempt during/just after a worker crash or cluster membership change; stale assignment records after failover; calling restart on the leader right after a worker was removed but before rescheduling finished.","solutions":["Wait for the scheduler to reschedule the orphaned instance (leadership scheduler runs periodically), then retry.","Trigger/verify scheduler reconciliation — check leader logs for assignment updates and worker membership changes.","If a worker was decommissioned, confirm it was properly deregistered so stale assignments are cleaned up.","As a workaround, restart the entire function (restartFunctionInstances) to force fresh assignments."],"exampleFix":"// before\nadmin.functions().restartFunctionInstance(tenant, ns, fn, 0); // may 400 if worker gone\n// after\nawaitAtMost(60, SECONDS).until(() -> {\n    try {\n        admin.functions().restartFunctionInstance(tenant, ns, fn, 0);\n        return true;\n    } catch (PulsarAdminException e) {\n        return false; // rescheduling in progress, retry\n    }\n});","handlingStrategy":"retry","validationCode":"FunctionStatus status = admin.functions().getFunctionStatus(tenant, ns, fn);\nboolean assigned = status.getInstances().stream()\n    .anyMatch(i -> i.getStatus().getWorkerId() != null);\nif (!assigned) {\n    // wait for scheduler to assign before restarting\n}","typeGuard":null,"tryCatchPattern":"try {\n    admin.functions().restartFunctionInstance(tenant, ns, fn, instanceId);\n} catch (PulsarAdminException e) {\n    if (e.getStatusCode() == 400 && e.getMessage().contains(\"has not been assigned\")) {\n        Thread.sleep(retryDelayMs); // wait for rescheduling after worker loss\n        admin.functions().restartFunctionInstance(tenant, ns, fn, instanceId);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Don't restart instances during or immediately after worker membership changes/failover.","Monitor leader scheduler logs for orphaned assignments after worker loss.","Use whole-function restart when a previously assigned worker is gone."],"tags":["pulsar-functions","assignment","cluster-membership"],"backgroundTag":"function-instance-not-found","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}