gofr-dev/gofr · critical

status down

Error message

status down

What it means

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.

Source

Thrown at pkg/gofr/datasource/kv-store/badger/badger.go:15

package badger

import (
	"context"
	"errors"
	"fmt"
	"strings"
	"time"

	"github.com/dgraph-io/badger/v4"
	"go.opentelemetry.io/otel/attribute"
	"go.opentelemetry.io/otel/trace"
)

var errStatusDown = errors.New("status down")

type Configs struct {
	DirPath string
}

type Client struct {
	db      *badger.DB
	configs *Configs
	logger  Logger
	metrics Metrics
	tracer  trace.Tracer
}

func New(configs Configs) *Client {
	return &Client{configs: &configs}
}

// UseLogger sets the logger for the BadgerDB client which asserts the Logger interface.

View on GitHub (pinned to 187eb24962)

Solutions

  1. Verify DirPath exists, is writable, and is not locked by another process
  2. Check disk space and permissions
  3. Reopen/rebuild the Badger database if corrupted; restart the app
  4. Check errors.Is(err, errStatusDown) and alert/skip dependent calls

Example fix

// before
h := store.HealthCheck(ctx) // status down
// after
if err != nil {
    logger.Errorf("badger down: %v", err)
    // verify DirPath & lock, then restart store
}
Defensive patterns

Strategy: retry

Validate before calling

if _, err := os.Stat(dirPath); err != nil {
    return fmt.Errorf("badger dir unavailable: %w", err)
}

Type guard

func isStatusDown(err error) bool {
    return errors.Is(err, ErrStatusDown) || err != nil && err.Error() == "status down"
}

Try / catch

if err := store.HealthCheck(ctx); err != nil {
    logger.Errorf("badger status down: %v", err)
    // verify DirPath/lock, restart, then retry with backoff
}

Prevention

When it happens

Trigger: HealthCheck(ctx) when Badger's internal check errors — e.g. DB closed, corrupted LSM/MANIFEST, disk I/O failure, or locked directory.

Common situations: Two processes opening the same Badger directory (file lock); disk full or permission denied on DirPath; calling HealthCheck after Close(); corrupt database after crash.

Related errors


AI-assisted analysis of gofr-dev/gofr@187eb24962 (2026-09-01). Data as JSON: /api/errors/5f532baa2ce1e8eb. Report an issue: GitHub.