Files
zapdb/errors.go
T

115 lines
5.0 KiB
Go
Raw Normal View History

2017-09-28 18:54:33 +10:00
/*
* SPDX-FileCopyrightText: © 2017-2025 Istari Digital, Inc.
2025-02-05 17:00:32 -05:00
* SPDX-License-Identifier: Apache-2.0
2017-09-28 18:54:33 +10:00
*/
package badger
import (
stderrors "errors"
"math"
2017-09-28 18:54:33 +10:00
)
const (
// ValueThresholdLimit is the maximum permissible value of opt.ValueThreshold.
ValueThresholdLimit = math.MaxUint16 - 16 + 1
)
2017-09-28 18:54:33 +10:00
var (
2017-10-02 18:32:11 +11:00
// ErrValueLogSize is returned when opt.ValueLogFileSize option is not within the valid
// range.
ErrValueLogSize = stderrors.New("Invalid ValueLogFileSize, must be in range [1MB, 2GB)")
2017-10-02 18:32:11 +11:00
// ErrKeyNotFound is returned when key isn't found on a txn.Get.
ErrKeyNotFound = stderrors.New("Key not found")
2017-10-02 18:32:11 +11:00
// ErrTxnTooBig is returned if too many writes are fit into a single transaction.
ErrTxnTooBig = stderrors.New("Txn is too big to fit into one request")
2017-10-02 18:32:11 +11:00
2019-06-07 10:13:10 -07:00
// ErrConflict is returned when a transaction conflicts with another transaction. This can
// happen if the read rows had been updated concurrently by another transaction.
ErrConflict = stderrors.New("Transaction Conflict. Please retry")
2017-10-02 18:32:11 +11:00
// ErrReadOnlyTxn is returned if an update function is called on a read-only transaction.
ErrReadOnlyTxn = stderrors.New("No sets or deletes are allowed in a read-only transaction")
2017-10-02 18:32:11 +11:00
2025-12-12 03:40:19 +08:00
// ErrDiscardedTxn is returned if a previously discarded transaction is reused.
ErrDiscardedTxn = stderrors.New("This transaction has been discarded. Create a new one")
2017-10-04 18:20:27 +11:00
2017-10-02 18:32:11 +11:00
// ErrEmptyKey is returned if an empty key is passed on an update function.
ErrEmptyKey = stderrors.New("Key cannot be empty")
2017-10-02 18:32:11 +11:00
// ErrInvalidKey is returned if the key has a special !badger! prefix,
// reserved for internal usage.
ErrInvalidKey = stderrors.New("Key is using a reserved !badger! prefix")
// ErrBannedKey is returned if the read/write key belongs to any banned namespace.
ErrBannedKey = stderrors.New("Key is using the banned prefix")
2017-09-28 18:54:33 +10:00
// ErrThresholdZero is returned if threshold is set to zero, and value log GC is called.
// In such a case, GC can't be run.
ErrThresholdZero = stderrors.New(
2017-09-28 18:54:33 +10:00
"Value log GC can't run because threshold is set to zero")
// ErrNoRewrite is returned if a call for value log GC doesn't result in a log file rewrite.
ErrNoRewrite = stderrors.New(
2017-09-28 18:54:33 +10:00
"Value log GC attempt didn't result in any cleanup")
// ErrRejected is returned if a value log GC is called either while another GC is running, or
2017-10-04 21:55:56 +11:00
// after DB::Close has been called.
ErrRejected = stderrors.New("Value log GC request rejected")
2017-09-28 18:54:33 +10:00
// ErrInvalidRequest is returned if the user request is invalid.
ErrInvalidRequest = stderrors.New("Invalid request")
2017-10-23 16:27:36 +11:00
// ErrManagedTxn is returned if the user tries to use an API which isn't
2017-10-24 08:55:46 +05:30
// 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")
2017-12-11 16:02:56 +11:00
// ErrZeroBandwidth is returned if the user passes in zero bandwidth for sequence.
ErrZeroBandwidth = stderrors.New("Bandwidth must be greater than zero")
2017-12-06 11:10:54 +05:30
2018-03-07 19:45:33 -08:00
// ErrWindowsNotSupported is returned when opt.ReadOnly is used on Windows
ErrWindowsNotSupported = stderrors.New("Read-only mode is not supported on Windows")
2020-08-20 07:32:30 -04:00
// ErrPlan9NotSupported is returned when opt.ReadOnly is used on Plan 9
ErrPlan9NotSupported = stderrors.New("Read-only mode is not supported on Plan 9")
2020-08-20 07:32:30 -04:00
// 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")
2018-07-12 14:23:49 -07:00
// 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")
2019-09-24 19:36:36 +05:30
// ErrEncryptionKeyMismatch is returned when the storage key is not
// matched with the key previously given.
ErrEncryptionKeyMismatch = stderrors.New("Encryption key mismatch")
2019-09-24 19:36:36 +05:30
// ErrInvalidDataKeyID is returned if the datakey id is invalid.
ErrInvalidDataKeyID = stderrors.New("Invalid datakey id")
2019-09-24 19:36:36 +05:30
2020-08-26 15:33:36 +05:30
// ErrInvalidEncryptionKey is returned if length of encryption keys is invalid.
ErrInvalidEncryptionKey = stderrors.New("Encryption key's length should be" +
2019-09-24 19:36:36 +05:30
"either 16, 24, or 32 bytes")
2020-08-26 15:33:36 +05:30
// ErrGCInMemoryMode is returned when db.RunValueLogGC is called in in-memory mode.
ErrGCInMemoryMode = stderrors.New("Cannot run value log GC when DB is opened in InMemory mode")
2020-08-26 15:33:36 +05:30
// ErrDBClosed is returned when a get operation is performed after closing the DB.
ErrDBClosed = stderrors.New("DB Closed")
2017-09-28 18:54:33 +10:00
)