{"record":{"id":"cc8bbeca34557e2f","repo":"Billionmail/BillionMail","slug":"scan-maildirsize-failed-w","errorCode":null,"errorMessage":"scan maildirsize failed: %w","messagePattern":"scan maildirsize failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/mail_boxes/update_used_space.go","lineNumber":232,"sourceCode":"\n\t\tif lineNo == 1 {\n\n\t\t\tcontinue\n\t\t}\n\n\t\tsizeStr := parts[0]\n\n\t\tsizeStr = strings.TrimSuffix(sizeStr, \"S\")\n\n\t\tv, err := strconv.ParseInt(sizeStr, 10, 64)\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"parse maildirsize line %d: invalid size '%s': %w\", lineNo, sizeStr, err)\n\t\t}\n\t\ttotal += v\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\treturn 0, fmt.Errorf(\"scan maildirsize failed: %w\", err)\n\t}\n\n\treturn total, nil\n}\n\n// domain.current_usage\nfunc aggregateDomainUsage(ctx context.Context) {\n\n\tif atomic.LoadInt32(&domainUsageColumnEnsured) == 0 {\n\t\tif _, err := g.DB().Exec(ctx, \"ALTER TABLE domain ADD COLUMN IF NOT EXISTS current_usage BIGINT NOT NULL DEFAULT 0\"); err != nil {\n\t\t\tg.Log().Warning(ctx, \"ensure domain.current_usage column failed\", err)\n\t\t}\n\t\tatomic.StoreInt32(&domainUsageColumnEnsured, 1)\n\t}\n\n\ttype dRow struct {\n\t\tDomain string\n\t\tUsage  int64","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/mail_boxes/update_used_space.go#L214-L250","documentation":"readMaildirsize scans the maildirsize file line by line with bufio.Scanner. This error propagates any non-EOF I/O error returned by scanner.Err() after the scan loop, indicating the file could not be fully read rather than parsed.","triggerScenarios":"scanner.Err() returns non-nil after reading maildirsize: OS-level read failure such as permission denied, I/O error, or interruption while reading the file.","commonSituations":"Mailbox files owned by the wrong user (vmail permissions); NFS stale handle or timeout on network storage; disk hardware errors on the mail volume.","solutions":["Check permissions/ownership of the maildirsize file (must be readable by the mail service user, e.g. vmail)","Test underlying storage health (dmesg for I/O errors, remount NFS)","Re-run the used-space update; the failure may be transient","Fall back to recomputing usage from the Maildir directory tree when maildirsize is unreadable"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"f, err := os.Open(path)\nif err != nil { return err }\nif info, err := f.Stat(); err != nil || !info.Mode().IsRegular() {\n    return fmt.Errorf(\"%s is not a readable regular file\", path)\n}","typeGuard":null,"tryCatchPattern":"total, err := readMaildirsize(path)\nif err != nil {\n    if strings.Contains(err.Error(), \"scan maildirsize failed\") {\n        // transient I/O — retry, then fall back to recalc\n        if total, rerr := readMaildirsize(path); rerr == nil { return total, nil }\n        return recalcUsageFromMaildir(filepath.Dir(path))\n    }\n    return err\n}","preventionTips":["Fix vmail/maildir ownership and read permissions","Watch NFS mounts for stale handles; use local storage for maildirsize where possible","Alert on kernel I/O errors for the mail volume"],"tags":["maildir","io","file-read","go"],"backgroundTag":"file-read-failed","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}