dgraph-io/badger · error
ErrWindowsNotSupported
ErrWindowsNotSupported
Error message
Read-only mode is not supported on Windows
What it means
ErrWindowsNotSupported is returned when opt.ReadOnly is used on Windows, where read-only mode is not implemented. It surfaces from acquireDirectoryLock (dir_windows.go:62) during DB.Open, and some tests special-case it. Defined in errors.go.
Source
Thrown at errors.go:82
// ErrManagedTxn is returned if the user tries to use an API which isn't
// allowed due to external management of transactions, when using ManagedDB.
ErrManagedTxn = stderrors.New(
"Invalid API request. Not allowed to perform this action using ManagedDB")
// ErrNamespaceMode is returned if the user tries to use an API which is allowed only when
// NamespaceOffset is non-negative.
ErrNamespaceMode = stderrors.New(
"Invalid API request. Not allowed to perform this action when NamespaceMode is not set.")
// ErrInvalidDump if a data dump made previously cannot be loaded into the database.
ErrInvalidDump = stderrors.New("Data dump cannot be read")
// ErrZeroBandwidth is returned if the user passes in zero bandwidth for sequence.
ErrZeroBandwidth = stderrors.New("Bandwidth must be greater than zero")
// ErrWindowsNotSupported is returned when opt.ReadOnly is used on Windows
ErrWindowsNotSupported = stderrors.New("Read-only mode is not supported on Windows")
// ErrPlan9NotSupported is returned when opt.ReadOnly is used on Plan 9
ErrPlan9NotSupported = stderrors.New("Read-only mode is not supported on Plan 9")
// ErrTruncateNeeded is returned when the value log gets corrupt, and requires truncation of
// corrupt data to allow Badger to run properly.
ErrTruncateNeeded = stderrors.New(
"Log truncate required to run DB. This might result in data loss")
// ErrBlockedWrites is returned if the user called DropAll. During the process of dropping all
// data from Badger, we stop accepting new writes, by returning this error.
ErrBlockedWrites = stderrors.New("Writes are blocked, possibly due to DropAll or Close")
// ErrNilCallback is returned when subscriber's callback is nil.
ErrNilCallback = stderrors.New("Callback cannot be nil")
// ErrEncryptionKeyMismatch is returned when the storage key is not
// matched with the key previously given.View on GitHub (pinned to 2a001d466f)
Solutions
- Disable ReadOnly on Windows and open the DB read-write
- Move read-only workloads to Linux/Plan9-free environments
- Gate the WithReadOnly option behind a runtime.GOOS check in your config code
Example fix
// before
opts = append(opts, badger.WithReadOnly(true))
db, err := badger.Open(opts...)
// after
if runtime.GOOS != "windows" {
opts = append(opts, badger.WithReadOnly(true))
}
db, err := badger.Open(opts...) Defensive patterns
Strategy: validation
Validate before calling
if readOnly && runtime.GOOS == "windows" { return errors.New("ReadOnly unsupported on Windows") } Try / catch
db, err := badger.Open(opts)
if errors.Is(err, ErrWindowsNotSupported) {
// fall back to read-write mode or fail fast on Windows
} Prevention
- Gate WithReadOnly on runtime.GOOS in config code
- Test the full option matrix in CI including Windows
- Keep read-only replicas on supported platforms (Linux)
When it happens
Trigger: Opening a DB with badger.WithReadOnly(true) on a Windows host; the check fires immediately in acquireDirectoryLock during Open.
Common situations: Cross-platform applications using ReadOnly on a dev machine running Windows; CI matrix including Windows; running a read-replica deployment on Windows hosts.
Related errors
- ErrPlan9NotSupported
- ErrReadOnlyTxn
- ErrTruncateNeeded
- ErrGCInReadOnlyMode
- Cannot use GetSequence in read-only mode.
AI-assisted analysis of dgraph-io/badger@2a001d466f (2026-09-05).
Data as JSON: /api/errors/ab3abea7d2f63519.
Report an issue: GitHub.