dgraph-io/badger · error

ErrPlan9NotSupported

ErrPlan9NotSupported

Error message

Read-only mode is not supported on Plan 9

What it means

ErrPlan9NotSupported is returned when opt.ReadOnly is used on Plan 9, where read-only mode is not implemented. It surfaces from acquireDirectoryLock (dir_plan9.go:32) during DB.Open. Defined in errors.go.

Source

Thrown at errors.go:85

	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.
	ErrEncryptionKeyMismatch = stderrors.New("Encryption key mismatch")

	// ErrInvalidDataKeyID is returned if the datakey id is invalid.

View on GitHub (pinned to 2a001d466f)

Solutions

  1. Remove the WithReadOnly option on Plan 9 and open read-write
  2. Use a supported OS (Linux) for read-only replicas
  3. Gate WithReadOnly behind a runtime.GOOS check

Example fix

// before
opts = append(opts, badger.WithReadOnly(true))
db, err := badger.Open(opts...)
// after
if runtime.GOOS != "plan9" {
	opts = append(opts, badger.WithReadOnly(true))
}
db, err := badger.Open(opts...)
Defensive patterns

Strategy: validation

Validate before calling

if readOnly && runtime.GOOS == "plan9" { return errors.New("ReadOnly unsupported on Plan 9") }

Try / catch

db, err := badger.Open(opts)
if errors.Is(err, ErrPlan9NotSupported) {
	// drop ReadOnly option and reopen read-write
}

Prevention

When it happens

Trigger: Opening a DB with badger.WithReadOnly(true) on a Plan 9 host; the check fires in acquireDirectoryLock during Open.

Common situations: Very rare; only Plan 9 deployments attempting read-only mode, typically ported configs from Linux where ReadOnly works.

Related errors


AI-assisted analysis of dgraph-io/badger@2a001d466f (2026-09-05). Data as JSON: /api/errors/f71d82e8213ca32a. Report an issue: GitHub.