{"record":{"id":"fb049d9a701b9b88","repo":"cayleygraph/cayley","slug":"cannot-inc-s-v","errorCode":null,"errorMessage":"cannot inc %s: %v","messagePattern":"cannot inc (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/kv/indexing.go","lineNumber":261,"sourceCode":"}\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}\n\tstart, err := qs.incMetaInt(ctx, tx, \"horizon\", int64(n))\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn uint64(start + 1), nil\n}\n\ntype nodeUpdate struct {\n\tInd int\n\tID  uint64","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/kv/indexing.go#L243-L279","documentation":"After computing the new counter value, incMetaInt writes the 8-byte encoding back to the meta bucket. If tx.Put fails, the write error is wrapped as \"cannot inc %s: %v\" with the key name. This means the counter increment could not be persisted.","triggerScenarios":"tx.Put on a meta key failing during incSize or genIDs — backend write error such as a read-only database, full disk, bolt write failure, or transaction already errored/committed.","commonSituations":"Disk full while appending node IDs during bulk load; opening a bolt file in read-only mode; using a transaction after Commit; backend-specific write failures on the meta bucket.","solutions":["Examine the wrapped inner error for the concrete backend cause (disk full, read-only, tx misuse).","Free disk space if writes are failing due to storage limits.","Ensure the store and transaction are opened read-write and the tx is not reused after Commit.","Retry the operation; if the meta bucket is corrupted, restore from backup and reindex."],"exampleFix":"// before: bulk load with full disk\ncayley load --files data.nq // cannot inc horizon: no space left on device\n// after\ndf -h # free space first\ncayley load --files data.nq","handlingStrategy":"retry","validationCode":"// preflight before bulk loads\nif free, err := diskFree(dbPath); err == nil && free < minBytes {\n    return fmt.Errorf(\"insufficient disk space for kv writes\")\n}","typeGuard":null,"tryCatchPattern":"_, err := qs.incSize(ctx, 1)\nif err != nil && strings.Contains(err.Error(), \"cannot inc \") {\n    if isDiskFull(err) {\n        return errAfterFreeingSpace()\n    }\n    return fmt.Errorf(\"meta write failed, aborting tx: %w\", err)\n}","preventionTips":["Monitor disk space on database volumes during bulk loads.","Open the store read-write, never read-only, when writing.","Never reuse a kv.Tx after Commit."],"tags":["kv-store","write-failed","meta"],"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-14T05:17:10.506Z"}