Skip to content

Commit a8c3260

Browse files
authored
Merge branch 'main' into dev-stream-change-max-size
2 parents acba512 + ca7c9d4 commit a8c3260

File tree

11 files changed

+50
-48
lines changed

11 files changed

+50
-48
lines changed

badger/cmd/bank.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121
"context"
2222
"errors"
23+
stderrors "errors"
2324
"fmt"
2425
"log"
2526
"math"
@@ -148,7 +149,7 @@ func min(a, b uint64) uint64 {
148149
return b
149150
}
150151

151-
var errAbandoned = errors.New("Transaction abandonded due to insufficient balance")
152+
var errAbandoned = stderrors.New("Transaction abandonded due to insufficient balance")
152153

153154
func moveMoney(db *badger.DB, from, to int) error {
154155
return db.Update(func(txn *badger.Txn) error {

db.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121
"context"
2222
"encoding/binary"
23+
stderrors "errors"
2324
"expvar"
2425
"fmt"
2526
"math"
@@ -1015,7 +1016,7 @@ func (db *DB) batchSetAsync(entries []*Entry, f func(error)) error {
10151016
return nil
10161017
}
10171018

1018-
var errNoRoom = errors.New("No room for write")
1019+
var errNoRoom = stderrors.New("No room for write")
10191020

10201021
// ensureRoomForWrite is always called serially.
10211022
func (db *DB) ensureRoomForWrite() error {

errors.go

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
package badger
1818

1919
import (
20+
stderrors "errors"
2021
"math"
21-
22-
"github.com/pkg/errors"
2322
)
2423

2524
const (
@@ -30,97 +29,97 @@ const (
3029
var (
3130
// ErrValueLogSize is returned when opt.ValueLogFileSize option is not within the valid
3231
// range.
33-
ErrValueLogSize = errors.New("Invalid ValueLogFileSize, must be in range [1MB, 2GB)")
32+
ErrValueLogSize = stderrors.New("Invalid ValueLogFileSize, must be in range [1MB, 2GB)")
3433

3534
// ErrKeyNotFound is returned when key isn't found on a txn.Get.
36-
ErrKeyNotFound = errors.New("Key not found")
35+
ErrKeyNotFound = stderrors.New("Key not found")
3736

3837
// ErrTxnTooBig is returned if too many writes are fit into a single transaction.
39-
ErrTxnTooBig = errors.New("Txn is too big to fit into one request")
38+
ErrTxnTooBig = stderrors.New("Txn is too big to fit into one request")
4039

4140
// ErrConflict is returned when a transaction conflicts with another transaction. This can
4241
// happen if the read rows had been updated concurrently by another transaction.
43-
ErrConflict = errors.New("Transaction Conflict. Please retry")
42+
ErrConflict = stderrors.New("Transaction Conflict. Please retry")
4443

4544
// ErrReadOnlyTxn is returned if an update function is called on a read-only transaction.
46-
ErrReadOnlyTxn = errors.New("No sets or deletes are allowed in a read-only transaction")
45+
ErrReadOnlyTxn = stderrors.New("No sets or deletes are allowed in a read-only transaction")
4746

4847
// ErrDiscardedTxn is returned if a previously discarded transaction is re-used.
49-
ErrDiscardedTxn = errors.New("This transaction has been discarded. Create a new one")
48+
ErrDiscardedTxn = stderrors.New("This transaction has been discarded. Create a new one")
5049

5150
// ErrEmptyKey is returned if an empty key is passed on an update function.
52-
ErrEmptyKey = errors.New("Key cannot be empty")
51+
ErrEmptyKey = stderrors.New("Key cannot be empty")
5352

5453
// ErrInvalidKey is returned if the key has a special !badger! prefix,
5554
// reserved for internal usage.
56-
ErrInvalidKey = errors.New("Key is using a reserved !badger! prefix")
55+
ErrInvalidKey = stderrors.New("Key is using a reserved !badger! prefix")
5756

5857
// ErrBannedKey is returned if the read/write key belongs to any banned namespace.
59-
ErrBannedKey = errors.New("Key is using the banned prefix")
58+
ErrBannedKey = stderrors.New("Key is using the banned prefix")
6059

6160
// ErrThresholdZero is returned if threshold is set to zero, and value log GC is called.
6261
// In such a case, GC can't be run.
63-
ErrThresholdZero = errors.New(
62+
ErrThresholdZero = stderrors.New(
6463
"Value log GC can't run because threshold is set to zero")
6564

6665
// ErrNoRewrite is returned if a call for value log GC doesn't result in a log file rewrite.
67-
ErrNoRewrite = errors.New(
66+
ErrNoRewrite = stderrors.New(
6867
"Value log GC attempt didn't result in any cleanup")
6968

7069
// ErrRejected is returned if a value log GC is called either while another GC is running, or
7170
// after DB::Close has been called.
72-
ErrRejected = errors.New("Value log GC request rejected")
71+
ErrRejected = stderrors.New("Value log GC request rejected")
7372

7473
// ErrInvalidRequest is returned if the user request is invalid.
75-
ErrInvalidRequest = errors.New("Invalid request")
74+
ErrInvalidRequest = stderrors.New("Invalid request")
7675

7776
// ErrManagedTxn is returned if the user tries to use an API which isn't
7877
// allowed due to external management of transactions, when using ManagedDB.
79-
ErrManagedTxn = errors.New(
78+
ErrManagedTxn = stderrors.New(
8079
"Invalid API request. Not allowed to perform this action using ManagedDB")
8180

8281
// ErrNamespaceMode is returned if the user tries to use an API which is allowed only when
8382
// NamespaceOffset is non-negative.
84-
ErrNamespaceMode = errors.New(
83+
ErrNamespaceMode = stderrors.New(
8584
"Invalid API request. Not allowed to perform this action when NamespaceMode is not set.")
8685

8786
// ErrInvalidDump if a data dump made previously cannot be loaded into the database.
88-
ErrInvalidDump = errors.New("Data dump cannot be read")
87+
ErrInvalidDump = stderrors.New("Data dump cannot be read")
8988

9089
// ErrZeroBandwidth is returned if the user passes in zero bandwidth for sequence.
91-
ErrZeroBandwidth = errors.New("Bandwidth must be greater than zero")
90+
ErrZeroBandwidth = stderrors.New("Bandwidth must be greater than zero")
9291

9392
// ErrWindowsNotSupported is returned when opt.ReadOnly is used on Windows
94-
ErrWindowsNotSupported = errors.New("Read-only mode is not supported on Windows")
93+
ErrWindowsNotSupported = stderrors.New("Read-only mode is not supported on Windows")
9594

9695
// ErrPlan9NotSupported is returned when opt.ReadOnly is used on Plan 9
97-
ErrPlan9NotSupported = errors.New("Read-only mode is not supported on Plan 9")
96+
ErrPlan9NotSupported = stderrors.New("Read-only mode is not supported on Plan 9")
9897

9998
// ErrTruncateNeeded is returned when the value log gets corrupt, and requires truncation of
10099
// corrupt data to allow Badger to run properly.
101-
ErrTruncateNeeded = errors.New(
100+
ErrTruncateNeeded = stderrors.New(
102101
"Log truncate required to run DB. This might result in data loss")
103102

104103
// ErrBlockedWrites is returned if the user called DropAll. During the process of dropping all
105104
// data from Badger, we stop accepting new writes, by returning this error.
106-
ErrBlockedWrites = errors.New("Writes are blocked, possibly due to DropAll or Close")
105+
ErrBlockedWrites = stderrors.New("Writes are blocked, possibly due to DropAll or Close")
107106

108107
// ErrNilCallback is returned when subscriber's callback is nil.
109-
ErrNilCallback = errors.New("Callback cannot be nil")
108+
ErrNilCallback = stderrors.New("Callback cannot be nil")
110109

111110
// ErrEncryptionKeyMismatch is returned when the storage key is not
112111
// matched with the key previously given.
113-
ErrEncryptionKeyMismatch = errors.New("Encryption key mismatch")
112+
ErrEncryptionKeyMismatch = stderrors.New("Encryption key mismatch")
114113

115114
// ErrInvalidDataKeyID is returned if the datakey id is invalid.
116-
ErrInvalidDataKeyID = errors.New("Invalid datakey id")
115+
ErrInvalidDataKeyID = stderrors.New("Invalid datakey id")
117116

118117
// ErrInvalidEncryptionKey is returned if length of encryption keys is invalid.
119-
ErrInvalidEncryptionKey = errors.New("Encryption key's length should be" +
118+
ErrInvalidEncryptionKey = stderrors.New("Encryption key's length should be" +
120119
"either 16, 24, or 32 bytes")
121120
// ErrGCInMemoryMode is returned when db.RunValueLogGC is called in in-memory mode.
122-
ErrGCInMemoryMode = errors.New("Cannot run value log GC when DB is opened in InMemory mode")
121+
ErrGCInMemoryMode = stderrors.New("Cannot run value log GC when DB is opened in InMemory mode")
123122

124123
// ErrDBClosed is returned when a get operation is performed after closing the DB.
125-
ErrDBClosed = errors.New("DB Closed")
124+
ErrDBClosed = stderrors.New("DB Closed")
126125
)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/gogo/protobuf v1.3.2
1010
github.com/golang/protobuf v1.5.4
1111
github.com/google/flatbuffers v24.3.25+incompatible
12-
github.com/klauspost/compress v1.17.10
12+
github.com/klauspost/compress v1.17.11
1313
github.com/pkg/errors v0.9.1
1414
github.com/spf13/cobra v1.8.1
1515
github.com/stretchr/testify v1.9.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
4949
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
5050
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
5151
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
52-
github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0=
53-
github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
52+
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
53+
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
5454
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
5555
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
5656
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

levels.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121
"context"
2222
"encoding/hex"
23+
stderrors "errors"
2324
"fmt"
2425
"math"
2526
"math/rand"
@@ -1512,7 +1513,7 @@ func tablesToString(tables []*table.Table) []string {
15121513
return res
15131514
}
15141515

1515-
var errFillTables = errors.New("Unable to fill tables")
1516+
var errFillTables = stderrors.New("Unable to fill tables")
15161517

15171518
// doCompact picks some table on level l and compacts it away to the next level.
15181519
func (s *levelsController) doCompact(id int, p compactionPriority) error {

manifest.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bufio"
2121
"bytes"
2222
"encoding/binary"
23+
stderrors "errors"
2324
"fmt"
2425
"hash/crc32"
2526
"io"
@@ -352,8 +353,8 @@ func (r *countingReader) ReadByte() (b byte, err error) {
352353
}
353354

354355
var (
355-
errBadMagic = errors.New("manifest has bad magic")
356-
errBadChecksum = errors.New("manifest has checksum mismatch")
356+
errBadMagic = stderrors.New("manifest has bad magic")
357+
errBadChecksum = stderrors.New("manifest has checksum mismatch")
357358
)
358359

359360
// ReplayManifestFile reads the manifest file and constructs two manifest objects. (We need one

merge.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
package badger
1818

1919
import (
20+
stderrors "errors"
2021
"sync"
2122
"time"
2223

23-
"github.com/pkg/errors"
24-
2524
"github.com/dgraph-io/badger/v4/y"
2625
"github.com/dgraph-io/ristretto/z"
2726
)
@@ -58,7 +57,7 @@ func (db *DB) GetMergeOperator(key []byte,
5857
return op
5958
}
6059

61-
var errNoMerge = errors.New("No need for merge")
60+
var errNoMerge = stderrors.New("No need for merge")
6261

6362
func (op *MergeOperator) iterateAndMerge() (newVal []byte, latest uint64, err error) {
6463
txn := op.db.NewTransaction(false)

value.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package badger
1919
import (
2020
"bytes"
2121
"context"
22+
stderrors "errors"
2223
"fmt"
2324
"hash"
2425
"hash/crc32"
@@ -63,8 +64,8 @@ const (
6364
vlogHeaderSize = 20
6465
)
6566

66-
var errStop = errors.New("Stop iteration")
67-
var errTruncate = errors.New("Do truncate")
67+
var errStop = stderrors.New("Stop iteration")
68+
var errTruncate = stderrors.New("Do truncate")
6869

6970
type logEntry func(e Entry, vp valuePointer) error
7071

y/checksum.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
package y
1818

1919
import (
20+
stderrors "errors"
2021
"hash/crc32"
2122

2223
"github.com/cespare/xxhash/v2"
23-
"github.com/pkg/errors"
2424

2525
"github.com/dgraph-io/badger/v4/pb"
2626
)
2727

2828
// ErrChecksumMismatch is returned at checksum mismatch.
29-
var ErrChecksumMismatch = errors.New("checksum mismatch")
29+
var ErrChecksumMismatch = stderrors.New("checksum mismatch")
3030

3131
// CalculateChecksum calculates checksum for data using ct checksum type.
3232
func CalculateChecksum(data []byte, ct pb.Checksum_Algorithm) uint64 {

0 commit comments

Comments
 (0)