storage/boltdb: update to etcd/bbolt v1.3.4

bbolt v1.3.4 has pointer usage fixes.

Change-Id: I5e0fc4782711d01c09ced579f25a4f8fbc8de85c
This commit is contained in:
Egon Elbre 2020-03-24 12:33:34 +02:00
parent f0aeda3091
commit 326c0cebde
3 changed files with 26 additions and 23 deletions

4
go.mod
View File

@ -6,7 +6,6 @@ require (
github.com/alessio/shellescape v0.0.0-20190409004728-b115ca0f9053 github.com/alessio/shellescape v0.0.0-20190409004728-b115ca0f9053
github.com/alicebob/miniredis/v2 v2.11.1 github.com/alicebob/miniredis/v2 v2.11.1
github.com/blang/semver v3.5.1+incompatible github.com/blang/semver v3.5.1+incompatible
github.com/boltdb/bolt v1.3.1
github.com/btcsuite/btcutil v1.0.1 github.com/btcsuite/btcutil v1.0.1
github.com/cheggaaa/pb/v3 v3.0.1 github.com/cheggaaa/pb/v3 v3.0.1
github.com/fatih/color v1.7.0 github.com/fatih/color v1.7.0
@ -36,10 +35,11 @@ require (
github.com/stripe/stripe-go v63.1.1+incompatible github.com/stripe/stripe-go v63.1.1+incompatible
github.com/vivint/infectious v0.0.0-20190108171102-2455b059135b github.com/vivint/infectious v0.0.0-20190108171102-2455b059135b
github.com/zeebo/errs v1.2.2 github.com/zeebo/errs v1.2.2
go.etcd.io/bbolt v1.3.4
go.uber.org/zap v1.14.1 go.uber.org/zap v1.14.1
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1 golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 golang.org/x/time v0.0.0-20191024005414-555d28b269f0
google.golang.org/grpc v1.27.1 google.golang.org/grpc v1.27.1
storj.io/common v0.0.0-20200323134045-2bd4d6e2dd7d storj.io/common v0.0.0-20200323134045-2bd4d6e2dd7d

7
go.sum
View File

@ -48,8 +48,6 @@ github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCS
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
@ -379,7 +377,10 @@ github.com/zeebo/incenc v0.0.0-20180505221441-0d92902eec54/go.mod h1:EI8LcOBDlSL
github.com/zeebo/structs v1.0.2 h1:kvcd7s2LqXuO9cdV5LqrGHCOAfCBXaZpKCA3jD9SJIc= github.com/zeebo/structs v1.0.2 h1:kvcd7s2LqXuO9cdV5LqrGHCOAfCBXaZpKCA3jD9SJIc=
github.com/zeebo/structs v1.0.2/go.mod h1:LphfpprlqJQcbCq+eA3iIK/NsejMwk9mlfH/tM1XuKQ= github.com/zeebo/structs v1.0.2/go.mod h1:LphfpprlqJQcbCq+eA3iIK/NsejMwk9mlfH/tM1XuKQ=
gitlab.com/nyarla/go-crypt v0.0.0-20160106005555-d9a5dc2b789b/go.mod h1:T3BPAOm2cqquPa0MKWeNkmOM5RQsRhkrwMWonFMN7fE= gitlab.com/nyarla/go-crypt v0.0.0-20160106005555-d9a5dc2b789b/go.mod h1:T3BPAOm2cqquPa0MKWeNkmOM5RQsRhkrwMWonFMN7fE=
go.etcd.io/bbolt v1.3.2 h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg=
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.mongodb.org/mongo-driver v1.1.0/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.0/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
@ -490,6 +491,8 @@ golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200107144601-ef85f5a75ddf/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200107144601-ef85f5a75ddf/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1 h1:gZpLHxUX5BdYLA08Lj4YCJNN/jk7KtquiArPoeX0WvA= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1 h1:gZpLHxUX5BdYLA08Lj4YCJNN/jk7KtquiArPoeX0WvA=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=

View File

@ -9,9 +9,9 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/boltdb/bolt"
"github.com/spacemonkeygo/monkit/v3" "github.com/spacemonkeygo/monkit/v3"
"github.com/zeebo/errs" "github.com/zeebo/errs"
"go.etcd.io/bbolt"
"storj.io/storj/storage" "storj.io/storj/storage"
) )
@ -23,7 +23,7 @@ var Error = errs.Class("boltdb error")
// Client is the entrypoint into a bolt data store // Client is the entrypoint into a bolt data store
type Client struct { type Client struct {
db *bolt.DB db *bbolt.DB
Path string Path string
Bucket []byte Bucket []byte
@ -39,12 +39,12 @@ const (
// New instantiates a new BoltDB client given db file path, and a bucket name // New instantiates a new BoltDB client given db file path, and a bucket name
func New(path, bucket string) (*Client, error) { func New(path, bucket string) (*Client, error) {
db, err := bolt.Open(path, fileMode, &bolt.Options{Timeout: defaultTimeout}) db, err := bbolt.Open(path, fileMode, &bbolt.Options{Timeout: defaultTimeout})
if err != nil { if err != nil {
return nil, Error.Wrap(err) return nil, Error.Wrap(err)
} }
err = Error.Wrap(db.Update(func(tx *bolt.Tx) error { err = Error.Wrap(db.Update(func(tx *bbolt.Tx) error {
_, err = tx.CreateBucketIfNotExists([]byte(bucket)) _, err = tx.CreateBucketIfNotExists([]byte(bucket))
return err return err
})) }))
@ -73,20 +73,20 @@ func (client *Client) SetLookupLimit(v int) { client.lookupLimit = v }
// LookupLimit returns the maximum limit that is allowed. // LookupLimit returns the maximum limit that is allowed.
func (client *Client) LookupLimit() int { return client.lookupLimit } func (client *Client) LookupLimit() int { return client.lookupLimit }
func (client *Client) update(fn func(*bolt.Bucket) error) error { func (client *Client) update(fn func(*bbolt.Bucket) error) error {
return Error.Wrap(client.db.Update(func(tx *bolt.Tx) error { return Error.Wrap(client.db.Update(func(tx *bbolt.Tx) error {
return fn(tx.Bucket(client.Bucket)) return fn(tx.Bucket(client.Bucket))
})) }))
} }
func (client *Client) batch(fn func(*bolt.Bucket) error) error { func (client *Client) batch(fn func(*bbolt.Bucket) error) error {
return Error.Wrap(client.db.Batch(func(tx *bolt.Tx) error { return Error.Wrap(client.db.Batch(func(tx *bbolt.Tx) error {
return fn(tx.Bucket(client.Bucket)) return fn(tx.Bucket(client.Bucket))
})) }))
} }
func (client *Client) view(fn func(*bolt.Bucket) error) error { func (client *Client) view(fn func(*bbolt.Bucket) error) error {
return Error.Wrap(client.db.View(func(tx *bolt.Tx) error { return Error.Wrap(client.db.View(func(tx *bbolt.Tx) error {
return fn(tx.Bucket(client.Bucket)) return fn(tx.Bucket(client.Bucket))
})) }))
} }
@ -103,7 +103,7 @@ func (client *Client) Put(ctx context.Context, key storage.Key, value storage.Va
return storage.ErrEmptyKey.New("") return storage.ErrEmptyKey.New("")
} }
err = client.batch(func(bucket *bolt.Bucket) error { err = client.batch(func(bucket *bbolt.Bucket) error {
return bucket.Put(key, value) return bucket.Put(key, value)
}) })
mon.IntVal("boltdb_batch_time_elapsed").Observe(int64(time.Since(start))) mon.IntVal("boltdb_batch_time_elapsed").Observe(int64(time.Since(start)))
@ -117,7 +117,7 @@ func (client *Client) PutAndCommit(ctx context.Context, key storage.Key, value s
return storage.ErrEmptyKey.New("") return storage.ErrEmptyKey.New("")
} }
return client.update(func(bucket *bolt.Bucket) error { return client.update(func(bucket *bbolt.Bucket) error {
return bucket.Put(key, value) return bucket.Put(key, value)
}) })
} }
@ -130,7 +130,7 @@ func (client *Client) Get(ctx context.Context, key storage.Key) (_ storage.Value
} }
var value storage.Value var value storage.Value
err = client.view(func(bucket *bolt.Bucket) error { err = client.view(func(bucket *bbolt.Bucket) error {
data := bucket.Get([]byte(key)) data := bucket.Get([]byte(key))
if len(data) == 0 { if len(data) == 0 {
return storage.ErrKeyNotFound.New("%q", key) return storage.ErrKeyNotFound.New("%q", key)
@ -148,7 +148,7 @@ func (client *Client) Delete(ctx context.Context, key storage.Key) (err error) {
return storage.ErrEmptyKey.New("") return storage.ErrEmptyKey.New("")
} }
return client.update(func(bucket *bolt.Bucket) error { return client.update(func(bucket *bbolt.Bucket) error {
return bucket.Delete(key) return bucket.Delete(key)
}) })
} }
@ -158,7 +158,7 @@ func (client *Client) DeleteMultiple(ctx context.Context, keys []storage.Key) (_
defer mon.Task()(&ctx, len(keys))(&err) defer mon.Task()(&ctx, len(keys))(&err)
var items storage.Items var items storage.Items
err = client.update(func(bucket *bolt.Bucket) error { err = client.update(func(bucket *bbolt.Bucket) error {
for _, key := range keys { for _, key := range keys {
value := bucket.Get(key) value := bucket.Get(key)
if len(value) == 0 { if len(value) == 0 {
@ -205,7 +205,7 @@ func (client *Client) GetAll(ctx context.Context, keys storage.Keys) (_ storage.
} }
vals := make(storage.Values, 0, len(keys)) vals := make(storage.Values, 0, len(keys))
err = client.view(func(bucket *bolt.Bucket) error { err = client.view(func(bucket *bbolt.Bucket) error {
for _, key := range keys { for _, key := range keys {
val := bucket.Get([]byte(key)) val := bucket.Get([]byte(key))
if val == nil { if val == nil {
@ -227,7 +227,7 @@ func (client *Client) Iterate(ctx context.Context, opts storage.IterateOptions,
opts.Limit = client.lookupLimit opts.Limit = client.lookupLimit
} }
return client.view(func(bucket *bolt.Bucket) error { return client.view(func(bucket *bbolt.Bucket) error {
var cursor advancer = forward{bucket.Cursor()} var cursor advancer = forward{bucket.Cursor()}
start := true start := true
@ -286,7 +286,7 @@ type advancer interface {
} }
type forward struct { type forward struct {
*bolt.Cursor *bbolt.Cursor
} }
func (cursor forward) PositionToFirst(prefix, first storage.Key) (key, value []byte) { func (cursor forward) PositionToFirst(prefix, first storage.Key) (key, value []byte) {
@ -311,7 +311,7 @@ func (client *Client) CompareAndSwap(ctx context.Context, key storage.Key, oldVa
return storage.ErrEmptyKey.New("") return storage.ErrEmptyKey.New("")
} }
return client.update(func(bucket *bolt.Bucket) error { return client.update(func(bucket *bbolt.Bucket) error {
data := bucket.Get([]byte(key)) data := bucket.Get([]byte(key))
if len(data) == 0 { if len(data) == 0 {
if oldValue != nil { if oldValue != nil {