{"record":{"id":"5f145862ee37f684","repo":"weaviate/weaviate","slug":"no-write-replica-found","errorCode":null,"errorMessage":"no write replica found","messagePattern":"no write replica found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cluster/router/router.go","lineNumber":403,"sourceCode":"}\n\n// BuildWriteRoutingPlan constructs a write routing plan for single-tenant collections.\nfunc (r *singleTenantRouter) BuildWriteRoutingPlan(params types.RoutingPlanBuildOptions) (types.WriteRoutingPlan, error) {\n\tif err := r.validateTenant(params.Tenant); err != nil {\n\t\treturn types.WriteRoutingPlan{}, err\n\t}\n\treturn r.buildWriteRoutingPlan(params)\n}\n\n// buildWriteRoutingPlan constructs a write routing plan for single-tenant collections.\nfunc (r *singleTenantRouter) buildWriteRoutingPlan(params types.RoutingPlanBuildOptions) (types.WriteRoutingPlan, error) {\n\twriteReplicas, err := r.getWriteReplicasLocation(r.collection, params.Tenant, params.Shard)\n\tif err != nil {\n\t\treturn types.WriteRoutingPlan{}, err\n\t}\n\n\tif len(writeReplicas.Replicas) == 0 {\n\t\treturn types.WriteRoutingPlan{}, fmt.Errorf(\"no write replica found\")\n\t}\n\n\tcl, err := writeReplicas.ValidateConsistencyLevel(params.ConsistencyLevel)\n\tif err != nil {\n\t\treturn types.WriteRoutingPlan{}, err\n\t}\n\n\tsortedWriteReplicas := sort(writeReplicas.Replicas, preferredNode(params.DirectCandidateNode, r.nodeSelector.LocalName()))\n\n\tplan := types.WriteRoutingPlan{\n\t\tShard:  params.Shard,\n\t\tTenant: params.Tenant,\n\t\tReplicaSet: types.WriteReplicaSet{\n\t\t\tReplicas: sortedWriteReplicas,\n\t\t},\n\t\tConsistencyLevel:    params.ConsistencyLevel,\n\t\tIntConsistencyLevel: cl,\n\t}","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/cluster/router/router.go#L385-L421","documentation":"The single-tenant write plan builder found no writable replicas for the target shard(s). Unlike reads (which list offending shards), this check catches the fully-empty write replica set after getWriteReplicasLocation succeeded — typically all replicas were filtered out by the replication FSM (none in a writable state) or no replica hostname could be resolved.","triggerScenarios":"BuildWriteRoutingPlan on a single-tenant collection where FilterOneShardReplicasWrite returns no nodes for the target shard(s) or all replica hostnames fail resolution, so writeReplicas.Replicas is empty.","commonSituations":"Writing while all replicas of the shard are undergoing replication/copy (cowitness state); replica nodes offline or removed; writes to a freshly created collection before replicas are ready.","solutions":["Check replica states for the shard and wait for replication operations to finish before writing","Ensure replica nodes are up, cluster members, and resolvable by hostname","Retry the write after the cluster topology settles","Re-add replicas (increase replication factor / trigger replica copy) for the affected shard"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Go: check replication status for the shard before writes\n// GET /v1/nodes or replication op endpoints should show no active REPLICA_COPY on target shard","typeGuard":null,"tryCatchPattern":"plan, err := router.BuildWriteRoutingPlan(opts)\nif err != nil && err.Error() == \"no write replica found\" {\n  // backoff + retry; escalate if no replica becomes writable within SLA\n}","preventionTips":["Keep replication factor >= 2 to survive replica migrations","Serialize large writes with replication/copy operations","Alert on shards with zero writable replicas","Verify node health before re-sharding or draining nodes"],"tags":["go","routing","replication","write-path"],"backgroundTag":"no-write-replica-available","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}