{"record":{"id":"5f532baa2ce1e8eb","repo":"gofr-dev/gofr","slug":"status-down","errorCode":null,"errorMessage":"status down","messagePattern":"status down","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/gofr/datasource/kv-store/badger/badger.go","lineNumber":15,"sourceCode":"package badger\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/dgraph-io/badger/v4\"\n\t\"go.opentelemetry.io/otel/attribute\"\n\t\"go.opentelemetry.io/otel/trace\"\n)\n\nvar errStatusDown = errors.New(\"status down\")\n\ntype Configs struct {\n\tDirPath string\n}\n\ntype Client struct {\n\tdb      *badger.DB\n\tconfigs *Configs\n\tlogger  Logger\n\tmetrics Metrics\n\ttracer  trace.Tracer\n}\n\nfunc New(configs Configs) *Client {\n\treturn &Client{configs: &configs}\n}\n\n// UseLogger sets the logger for the BadgerDB client which asserts the Logger interface.","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/kv-store/badger/badger.go#L1-L33","documentation":"errStatusDown is the sentinel error returned by the badger kv-store Client's HealthCheck when the embedded Badger database reports unhealthy status or the health check operation fails. Callers of the datasource health check receive this to signal the store is not currently usable.","triggerScenarios":"HealthCheck(ctx) when Badger's internal check errors — e.g. DB closed, corrupted LSM/MANIFEST, disk I/O failure, or locked directory.","commonSituations":"Two processes opening the same Badger directory (file lock); disk full or permission denied on DirPath; calling HealthCheck after Close(); corrupt database after crash.","solutions":["Verify DirPath exists, is writable, and is not locked by another process","Check disk space and permissions","Reopen/rebuild the Badger database if corrupted; restart the app","Check errors.Is(err, errStatusDown) and alert/skip dependent calls"],"exampleFix":"// before\nh := store.HealthCheck(ctx) // status down\n// after\nif err != nil {\n    logger.Errorf(\"badger down: %v\", err)\n    // verify DirPath & lock, then restart store\n}","handlingStrategy":"retry","validationCode":"if _, err := os.Stat(dirPath); err != nil {\n    return fmt.Errorf(\"badger dir unavailable: %w\", err)\n}","typeGuard":"func isStatusDown(err error) bool {\n    return errors.Is(err, ErrStatusDown) || err != nil && err.Error() == \"status down\"\n}","tryCatchPattern":"if err := store.HealthCheck(ctx); err != nil {\n    logger.Errorf(\"badger status down: %v\", err)\n    // verify DirPath/lock, restart, then retry with backoff\n}","preventionTips":["Ensure only one process opens the Badger directory","Monitor disk space and permissions on DirPath","Never use the store after Close without reopening","Alert on health check failures"],"tags":["badger","kv-store","health-check","availability","gofr"],"backgroundTag":"service-unhealthy","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}