{"record":{"id":"a0fccfa215e35401","repo":"weaviate/weaviate","slug":"add-meta-count","errorCode":null,"errorMessage":"add meta count","messagePattern":"add meta count","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/aggregator/unfiltered.go","lineNumber":49,"sourceCode":"// However, this aggregator does not work with subselections of the dataset,\n// such as when grouping or a filter is set.\ntype unfilteredAggregator struct {\n\t*Aggregator\n}\n\nfunc newUnfilteredAggregator(agg *Aggregator) *unfilteredAggregator {\n\treturn &unfilteredAggregator{Aggregator: agg}\n}\n\nfunc (ua *unfilteredAggregator) Do(ctx context.Context) (*aggregation.Result, error) {\n\tout := aggregation.Result{}\n\n\t// without grouping there is always exactly one group\n\tout.Groups = make([]aggregation.Group, 1)\n\n\tif ua.params.IncludeMetaCount {\n\t\tif err := ua.addMetaCount(ctx, &out); err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"add meta count\")\n\t\t}\n\t}\n\n\tprops, err := ua.properties(ctx)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"aggregate properties\")\n\t}\n\n\tout.Groups[0].Properties = props\n\n\treturn &out, nil\n}\n\nfunc (ua *unfilteredAggregator) addMetaCount(ctx context.Context,\n\tout *aggregation.Result,\n) error {\n\tb := ua.store.Bucket(helpers.ObjectsBucketLSM)\n\tif b == nil {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/aggregator/unfiltered.go#L31-L67","documentation":"Wrapper error produced by unfilteredAggregator.Do when IncludeMetaCount is set and addMetaCount fails. addMetaCount counts all objects in the shard's objects bucket; it fails if the bucket is missing or the underlying LSM Count call errors. The wrap only adds context — the root cause is in the wrapped error.","triggerScenarios":"A GraphQL { Meta { count } } or aggregate-with-metaCount query against an unfiltered aggregation where the shard's objects bucket is nil (shard still initializing, corrupted, or closed) or b.Count(ctx) returns an LSM/ctx error.","commonSituations":"Querying a shard while it is being loaded or dropped; corrupted/partially-created shard directories after a crash; context canceled or timed out during a long count on a large collection.","solutions":["Check the wrapped cause: 'objects bucket is nil' means the shard store isn't open — restart the node or inspect shard directory health","If the cause is 'count objects', check for context cancellation/timeout and retry with a longer deadline","Verify the collection/shard exists and the node finished startup before issuing meta-count aggregations","Check disk health and LSM store logs for corruption; restore from backup if the shard is damaged"],"exampleFix":"// before (client)\nres, err := graphql.Batch(aggWithMetaCount) // fails with 'add meta count: objects bucket is nil'\n// after\nif shardReady(node, class, shard) { res, err := graphql.Batch(aggWithMetaCount) }","handlingStrategy":"try-catch","validationCode":"// client: ensure collection + node ready before meta-count\nstatus, _ := client.Schema().GetSchemaStatus(ctx, className)\nif status == nil || status.Shards == nil { return errors.New(\"collection not ready\") }","typeGuard":"func shardReady(b BucketGetter) bool { return b != nil && b.Bucket(helpers.ObjectsBucketLSM) != nil }","tryCatchPattern":"res, err := agg.Do(ctx)\nif err != nil {\n  if strings.Contains(err.Error(), \"objects bucket is nil\") {\n    // shard store not open: restart/inspect shard, then retry\n  } else if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n    // retry with longer deadline\n  }\n  return err\n}","preventionTips":["Verify shard health after node startup before serving aggregations","Set generous timeouts for meta-count on large collections","Monitor LSM store open errors in startup logs","Keep backups so torn shard dirs can be restored"],"tags":["weaviate","aggregation","lsmkv","storage"],"backgroundTag":"bucket-not-found","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"}