{"record":{"id":"1e95243659e5ca7b","repo":"weaviate/weaviate","slug":"hashtree-level-d-discriminant-size-d-expected","errorCode":null,"errorMessage":"hashtree level %d: discriminant size %d, expected %d (height mismatch?)","messagePattern":"hashtree level (.+?): discriminant size (.+?), expected (.+?) \\(height mismatch\\?\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/shard_async_replication.go","lineNumber":1607,"sourceCode":"\t\treturn nil, fmt.Errorf(\"hashtree level %d: nil discriminant\", level)\n\t}\n\n\ts.asyncReplicationRWMux.RLock()\n\tdefer s.asyncReplicationRWMux.RUnlock()\n\n\tif s.hashtree == nil || !s.hashtreeFullyInitialized {\n\t\treturn nil, fmt.Errorf(\"%w: hashtree not initialized on shard %q\", errAsyncReplicationNotActive, s.ID())\n\t}\n\n\t// Transient during a rolling height change — retry-later, not an error.\n\tif height := s.hashtree.Height(); level > height {\n\t\treturn nil, fmt.Errorf(\"%w: hashtree level %d exceeds height %d on shard %q\",\n\t\t\terrAsyncReplicationNotActive, level, height, s.ID())\n\t}\n\n\texpected := hashtree.LeavesCount(level)\n\tif discriminant.Size() != expected {\n\t\treturn nil, fmt.Errorf(\"hashtree level %d: discriminant size %d, expected %d (height mismatch?)\",\n\t\t\tlevel, discriminant.Size(), expected)\n\t}\n\n\tdigests = make([]hashtree.Digest, discriminant.SetCount())\n\n\tn, err := s.hashtree.Level(level, discriminant, digests)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn digests[:n], nil\n}\n\nvar (\n\terrAsyncReplicationNotActive   = replica.ErrAsyncReplicationNotActive\n\terrAsyncCheckpointStale        = replica.ErrAsyncCheckpointStale\n\terrAsyncCheckpointCutoffInPast = replica.ErrAsyncCheckpointCutoffInPast\n)","sourceCodeStart":1589,"sourceCodeEnd":1625,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/shard_async_replication.go#L1589-L1625","documentation":"Validation guard in Shard.HashTreeLevel: the discriminant bitset's size does not match hashtree.LeavesCount(level), so it was built for a different tree height and cannot select digests at the requested level.","triggerScenarios":"Thrown at adapters/repos/db/shard_async_replication.go:1607 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rebuild the discriminant with the correct size for the requested level.","Check for height mismatch between coordinator and replica (height rolling change in progress).","No retry until the discriminant is regenerated consistently."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}