{"record":{"id":"d86c380b2f4451d5","repo":"weaviate/weaviate","slug":"shard-s-of-class-s-has-no-assigned-nodes","errorCode":null,"errorMessage":"shard %s of class %s has no assigned nodes","messagePattern":"shard (.+?) of class (.+?) has no assigned nodes","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/export.go","lineNumber":56,"sourceCode":"// are write-locked simultaneously. Short enough that the added latency\n// (vs. event-driven wake-up) is negligible compared to typical lock hold\n// times (shard load/unload), long enough to keep CPU overhead trivial.\nconst lockPollInterval = 5 * time.Millisecond\n\n// ShardOwnership returns a map of node name to shard names for a given class.\n// Shards are distributed across their replica nodes using a least-loaded\n// strategy so that export work is balanced across the cluster.\nfunc (db *DB) ShardOwnership(ctx context.Context, className string) (map[string][]string, error) {\n\tshardNodes := make(map[string][]string)\n\n\terr := db.schemaReader.Read(className, true, func(_ *models.Class, state *sharding.State) error {\n\t\tif state == nil {\n\t\t\treturn fmt.Errorf(\"unable to retrieve sharding state for class %s\", className)\n\t\t}\n\n\t\tfor shardName, shard := range state.Physical {\n\t\t\tif len(shard.BelongsToNodes) == 0 {\n\t\t\t\treturn fmt.Errorf(\"shard %s of class %s has no assigned nodes\", shardName, className)\n\t\t\t}\n\n\t\t\t// Filter out empty node names to avoid assigning shards to an invalid node.\n\t\t\tvalidNodes := make([]string, 0, len(shard.BelongsToNodes))\n\t\t\tfor _, node := range shard.BelongsToNodes {\n\t\t\t\tif node != \"\" {\n\t\t\t\t\tvalidNodes = append(validNodes, node)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(validNodes) == 0 {\n\t\t\t\treturn fmt.Errorf(\"shard %s of class %s has only empty assigned nodes\", shardName, className)\n\t\t\t}\n\n\t\t\tshardNodes[shardName] = validNodes\n\t\t}\n\n\t\treturn nil\n\t})","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/export.go#L38-L74","documentation":"ShardOwnership validates that every physical shard in the class's sharding state has at least one node in BelongsToNodes. A shard with an empty BelongsToNodes list has no owner, so shards cannot be assigned to nodes for a balanced export; the read fails immediately with this error.","triggerScenarios":"Calling ShardOwnership when the class's sharding.State.Physical map contains a shard whose BelongsToNodes slice is empty/nil — e.g. shard metadata created but replica assignment never committed (interrupted shard creation, corrupted sharding state).","commonSituations":"Crashed or interrupted shard creation/migration in a cluster; restoring a partial backup; shard rebalancing that left a shard unassigned; exporting a class right after adding shards that have not been fully assigned.","solutions":["Inspect the sharding state (nodes/replication status endpoints) to find the unassigned shard","Run the shard replication/rebalance mechanism to assign nodes to the shard","If the shard is orphaned (no data needed), delete it so the sharding state is consistent","Restore a consistent sharding state from a cluster snapshot if assignment metadata is lost"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Inspect sharding state before export; fail fast on unassigned shards\nerr := db.schemaReader.Read(className, true, func(_ *models.Class, st *sharding.State) error {\n    for name, shard := range st.Physical {\n        if len(shard.BelongsToNodes) == 0 {\n            return fmt.Errorf(\"shard %s unassigned; fix before export\", name)\n        }\n    }\n    return nil\n})","typeGuard":null,"tryCatchPattern":"_, err := db.ShardOwnership(ctx, className)\nif err != nil && strings.Contains(err.Error(), \"has no assigned nodes\") {\n    // trigger replication/rebalance or delete the orphaned shard before exporting\n    return err\n}","preventionTips":["Ensure shard creation/replication jobs complete before exporting","Monitor cluster replication status; alert on shards with no owner","Never hand-edit sharding state; use the replication APIs"],"tags":["export","sharding","cluster"],"backgroundTag":"shard-unassigned","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"}