{"record":{"id":"8efd58feefa7d526","repo":"juicedata/juicefs","slug":"set-total-inodes-w","errorCode":null,"errorMessage":"set total inodes: %w","messagePattern":"set total inodes: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/tkv.go","lineNumber":3655,"sourceCode":"\t\treturn nil\n\t})\n}\n\nfunc (m *kvMeta) doSyncVolumeStat(ctx Context, used, inodes int64) error {\n\tif m.conf.ReadOnly {\n\t\treturn syscall.EROFS\n\t}\n\tif err := m.doScanSustainedInodes(ctx, func(uid, gid uint32, length uint64) error {\n\t\tused += align4K(length)\n\t\tinodes++\n\t\treturn nil\n\t}); err != nil {\n\t\treturn err\n\t}\n\tlogger.Debugf(\"Used space: %s, inodes: %d\", humanize.IBytes(uint64(used)), inodes)\n\terr := m.setValue(m.counterKey(totalInodes), packCounter(inodes))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"set total inodes: %w\", err)\n\t}\n\treturn m.setValue(m.counterKey(usedSpace), packCounter(used))\n}\n\nfunc (m *kvMeta) doFlushQuotas(ctx Context, quotas []*iQuota) error {\n\treturn m.txn(ctx, func(tx *kvTxn) error {\n\t\tkeys := make([][]byte, 0, len(quotas))\n\t\tqs := make([]*iQuota, 0, len(quotas))\n\t\tfor _, q := range quotas {\n\t\t\tkey, err := m.getQuotaKey(q.qtype, q.qkey)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tkeys = append(keys, key)\n\t\t\tqs = append(qs, q)\n\t\t}\n\t\tfor i, v := range tx.gets(keys...) {\n\t\t\tif len(v) == 0 {","sourceCodeStart":3637,"sourceCodeEnd":3673,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/tkv.go#L3637-L3673","documentation":"After recomputing total inodes/used space (quota usage sync), kvMeta persists the total-inode counter; if that setValue fails, the store error is wrapped as 'set total inodes: %w'. The subsequent usedSpace write is skipped, leaving counters potentially inconsistent until the next sync.","triggerScenarios":"Quota usage flush/sync (e.g. 'juicefs gc --sync' or periodic usage sync) failing to write the totalInodes counter key — store outage, transaction size limit, network error.","commonSituations":"etcd transaction size limits under large syncs; temporary metadata store unavailability; leader election/readonly mode in TiKV/etcd during the write.","solutions":["Re-run the usage sync command (juicefs gc/ quota sync) once the metadata store is healthy","Check the wrapped inner error for the store-level cause (connectivity, readonly, txn limits)","Verify the KV store is writable (not in readonly/maintenance mode) and has enough request-size headroom","Retry with backoff; the operation is idempotent since it recomputes from counters"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify store writability before syncing quota usage\nif err := canWriteCounterKey(ctx, meta); err != nil {\n\treturn fmt.Errorf(\"metadata store not writable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := syncUsage(ctx); err != nil {\n\tif strings.Contains(err.Error(), \"set total inodes\") {\n\t\t// retry with backoff; operation recomputes and is idempotent\n\t}\n}","preventionTips":["Ensure the KV store has adequate transaction/request size limits","Monitor store availability during gc/quota sync windows","Retry failed syncs; counters are recomputed from scratch","Check for readonly/leader-election states in etcd/TiKV"],"tags":["quota","counter","kv-store","write-failed"],"backgroundTag":"database-write-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}