{"record":{"id":"a26548df669bd63a","repo":"cayleygraph/cayley","slug":"cannot-get-s-v","errorCode":null,"errorMessage":"cannot get %s: %v","messagePattern":"cannot get (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/kv/indexing.go","lineNumber":251,"sourceCode":"}\n\nfunc (qs *QuadStore) getMetaIntTx(ctx context.Context, tx kv.Tx, key string) (int64, error) {\n\tval, err := tx.Get(ctx, metaBucket.AppendBytes([]byte(key)))\n\tif err == kv.ErrNotFound {\n\t\treturn 0, err\n\t} else if err != nil {\n\t\treturn 0, fmt.Errorf(\"cannot get horizon value: %v\", err)\n\t}\n\treturn int64(binary.LittleEndian.Uint64(val)), nil\n}\n\nfunc (qs *QuadStore) incMetaInt(ctx context.Context, tx kv.Tx, key string, n int64) (int64, error) {\n\tif n == 0 {\n\t\treturn 0, nil\n\t}\n\tv, err := qs.getMetaIntTx(ctx, tx, key)\n\tif err != nil && err != kv.ErrNotFound {\n\t\treturn 0, fmt.Errorf(\"cannot get %s: %v\", key, err)\n\t}\n\tstart := v\n\tv += n\n\n\tbuf := make([]byte, 8) // bolt needs all slices available on Commit\n\tbinary.LittleEndian.PutUint64(buf, uint64(v))\n\n\terr = tx.Put(ctx, metaBucket.AppendBytes([]byte(key)), buf)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"cannot inc %s: %v\", key, err)\n\t}\n\treturn start, nil\n}\n\nfunc (qs *QuadStore) genIDs(ctx context.Context, tx kv.Tx, n int) (uint64, error) {\n\tif n == 0 {\n\t\treturn 0, nil\n\t}","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/kv/indexing.go#L233-L269","documentation":"incMetaInt reads the current counter value via getMetaIntTx and wraps any non-ErrNotFound read failure as \"cannot get %s: %v\" where %s is the meta key (e.g. horizon or size counters). Callers incSize and genIDs use it to advance counters within a write transaction.","triggerScenarios":"incSize or genIDs invoked while the underlying kv Get of a meta key fails with a backend error other than ErrNotFound (I/O error, closed store, lock contention).","commonSituations":"Concurrent writers hitting backend locking limits; database closed or reopening mid-write; disk failure or corrupted meta bucket while updating size/horizon counters.","solutions":["Read the wrapped key and inner error to identify which counter read failed and why; fix the backend issue.","Ensure the store is open and the transaction is used before commit/close.","Serialize write access or use the backend's recommended concurrency settings if lock contention is the cause.","Check disk space/health; restore from backup and reindex if the meta bucket is corrupted."],"exampleFix":"// before\nerr = qs.incSize(ctx, 1) // fails: db closed\nqs.Close()\n// after\n// close only after all writes complete\nqs.incSize(ctx, 1)\nqs.Close()","handlingStrategy":"retry","validationCode":"if err := qs.checkOpen(); err != nil {\n    return err // store must be open and writable before incrementing counters\n}","typeGuard":null,"tryCatchPattern":"_, err := qs.incSize(ctx, delta)\nif err != nil && strings.Contains(err.Error(), \"cannot get \") {\n    log.Printf(\"meta read failed: %v\", err)\n    return err // surface backend error; do not blind-retry on closed/corrupt store\n}","preventionTips":["Ensure single-writer access or backend-appropriate concurrency settings.","Fail fast on store-closed conditions instead of writing afterwards.","Alert on disk I/O errors; restore meta bucket from backup if corrupted."],"tags":["kv-store","meta","storage-error"],"backgroundTag":"database-write-failed","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}