{"record":{"id":"3eba585e05fb97fc","repo":"gastownhall/beads","slug":"measure-active-database-directory-q-w","errorCode":null,"errorMessage":"measure active database directory %q: %w","messagePattern":"measure active database directory %q: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/store.go","lineNumber":2867,"sourceCode":"\tif s.dbPath == \"\" {\n\t\treturn \"\"\n\t}\n\treturn filepath.Join(s.dbPath, s.database)\n}\n\n// ActiveDatabaseSize returns the approximate size of the active database.\n// External server instances have no authoritative local path and report the\n// capability as unsupported even if a stale client-local directory exists.\nfunc (s *DoltStore) ActiveDatabaseSize(ctx context.Context) (int64, error) {\n\tif s.localActiveDatabaseDir == \"\" {\n\t\treturn 0, &storage.ErrUnsupported{\n\t\t\tOp:      \"ActiveDatabaseSize\",\n\t\t\tBackend: \"dolt-server\",\n\t\t}\n\t}\n\tsize, err := storage.MeasureDirectorySize(ctx, s.localActiveDatabaseDir)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"measure active database directory %q: %w\", s.localActiveDatabaseDir, err)\n\t}\n\treturn size, nil\n}\n\n// DoltGC runs Dolt garbage collection to reclaim disk space.\n// Pins a single connection to avoid session state loss on pooled *sql.DB.\nfunc (s *DoltStore) DoltGC(ctx context.Context) error {\n\tconn, err := s.db.Conn(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"acquire connection for gc: %w\", err)\n\t}\n\tdefer conn.Close()\n\treturn versioncontrolops.DoltGC(ctx, conn)\n}\n\n// ListRemoteRefs returns the names of all cached remote-tracking refs.\nfunc (s *DoltStore) ListRemoteRefs(ctx context.Context) ([]string, error) {\n\treturn versioncontrolops.ListRemoteRefs(ctx, s.db)","sourceCodeStart":2849,"sourceCodeEnd":2885,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L2849-L2885","documentation":"ActiveDatabaseSize measures the on-disk size of the active Dolt database directory via storage.MeasureDirectorySize; this error wraps that failure and includes the directory path. It reflects filesystem-level problems (missing dir, permission, stat errors), not the SQL server.","triggerScenarios":"Calling ActiveDatabaseSize when s.localActiveDatabaseDir does not exist (embedded Dolt not yet initialized), the process lacks read permission on the directory, an I/O error occurs walking the directory, or ctx is canceled mid-measurement.","commonSituations":"Server-mode store (no local dir) incorrectly reporting size; deleted or moved .dolt data directory; running under a different user (container permission mismatch); disk I/O errors.","solutions":["Verify the directory exists and is readable: ls -la on s.localActiveDatabaseDir and fix permissions (chmod/chown)","If in server mode (no local dir), don't call ActiveDatabaseSize — the Op/Backend metadata in the surrounding code already guards this; ensure store mode is embedded","Recreate/re-initialize the database directory if it was deleted, then retry"],"exampleFix":"// before\nsize, err := store.ActiveDatabaseSize(ctx)\n// after\nif _, err := os.Stat(dbDir); err != nil {\n    // directory missing: initialize store first\n}\nsize, err := store.ActiveDatabaseSize(ctx)","handlingStrategy":"validation","validationCode":"// verify the database directory exists and is readable first\ninfo, err := os.Stat(s.localActiveDatabaseDir)\nif err != nil {\n    // directory missing: initialize the embedded store before sizing\n}\nif info != nil && !info.IsDir() {\n    return errors.New(\"active database path is not a directory\")\n}\nif f, err := os.Open(s.localActiveDatabaseDir); err != nil {\n    return fmt.Errorf(\"no read permission on %s\", s.localActiveDatabaseDir)\n} else {\n    f.Close()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call size measurement on embedded-mode stores with an initialized dir","Run the process as a user with read access to the data directory","Guard against deleted data dirs after backup/restore operations","Use a long-enough context for directory walks on large databases"],"tags":["go","filesystem","dolt","disk-usage"],"backgroundTag":"directory-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}