vendor: go.etcd.io/bbolt v1.3.6
Remove the replace rule, and use the version as specified by (indirect) dependencies: full diff: https://github.com/etcd-io/bbolt/compare/v1.3.5...v1.3.6 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
03f45fafc5
commit
40b8495735
14 changed files with 245 additions and 30 deletions
|
@ -176,7 +176,6 @@ replace (
|
||||||
github.com/prometheus/procfs => github.com/prometheus/procfs v0.0.11
|
github.com/prometheus/procfs => github.com/prometheus/procfs v0.0.11
|
||||||
github.com/stretchr/testify => github.com/stretchr/testify v1.3.0
|
github.com/stretchr/testify => github.com/stretchr/testify v1.3.0
|
||||||
github.com/vishvananda/netlink => github.com/vishvananda/netlink v1.1.0
|
github.com/vishvananda/netlink => github.com/vishvananda/netlink v1.1.0
|
||||||
go.etcd.io/bbolt => go.etcd.io/bbolt v1.3.5
|
|
||||||
go.opencensus.io => go.opencensus.io v0.22.3
|
go.opencensus.io => go.opencensus.io v0.22.3
|
||||||
golang.org/x/oauth2 => golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
golang.org/x/oauth2 => golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
||||||
google.golang.org/api => google.golang.org/api v0.8.0
|
google.golang.org/api => google.golang.org/api v0.8.0
|
||||||
|
|
|
@ -541,8 +541,11 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
|
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||||
|
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||||
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||||
|
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
|
||||||
|
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
|
||||||
go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg=
|
go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg=
|
||||||
go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk=
|
go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk=
|
||||||
go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8=
|
go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8=
|
||||||
|
@ -651,6 +654,7 @@ golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||||
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
|
2
vendor/go.etcd.io/bbolt/.gitignore
generated
vendored
2
vendor/go.etcd.io/bbolt/.gitignore
generated
vendored
|
@ -3,3 +3,5 @@
|
||||||
*.swp
|
*.swp
|
||||||
/bin/
|
/bin/
|
||||||
cover.out
|
cover.out
|
||||||
|
/.idea
|
||||||
|
*.iml
|
||||||
|
|
3
vendor/go.etcd.io/bbolt/.travis.yml
generated
vendored
3
vendor/go.etcd.io/bbolt/.travis.yml
generated
vendored
|
@ -4,9 +4,10 @@ go_import_path: go.etcd.io/bbolt
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.12
|
- 1.15
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
|
- go get -v golang.org/x/sys/unix
|
||||||
- go get -v honnef.co/go/tools/...
|
- go get -v honnef.co/go/tools/...
|
||||||
- go get -v github.com/kisielk/errcheck
|
- go get -v github.com/kisielk/errcheck
|
||||||
|
|
||||||
|
|
2
vendor/go.etcd.io/bbolt/Makefile
generated
vendored
2
vendor/go.etcd.io/bbolt/Makefile
generated
vendored
|
@ -2,8 +2,6 @@ BRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||||
COMMIT=`git rev-parse --short HEAD`
|
COMMIT=`git rev-parse --short HEAD`
|
||||||
GOLDFLAGS="-X main.branch $(BRANCH) -X main.commit $(COMMIT)"
|
GOLDFLAGS="-X main.branch $(BRANCH) -X main.commit $(COMMIT)"
|
||||||
|
|
||||||
default: build
|
|
||||||
|
|
||||||
race:
|
race:
|
||||||
@TEST_FREELIST_TYPE=hashmap go test -v -race -test.run="TestSimulate_(100op|1000op)"
|
@TEST_FREELIST_TYPE=hashmap go test -v -race -test.run="TestSimulate_(100op|1000op)"
|
||||||
@echo "array freelist test"
|
@echo "array freelist test"
|
||||||
|
|
5
vendor/go.etcd.io/bbolt/README.md
generated
vendored
5
vendor/go.etcd.io/bbolt/README.md
generated
vendored
|
@ -908,12 +908,14 @@ Below is a list of public, open source projects that use Bolt:
|
||||||
* [BoltStore](https://github.com/yosssi/boltstore) - Session store using Bolt.
|
* [BoltStore](https://github.com/yosssi/boltstore) - Session store using Bolt.
|
||||||
* [Boltdb Boilerplate](https://github.com/bobintornado/boltdb-boilerplate) - Boilerplate wrapper around bolt aiming to make simple calls one-liners.
|
* [Boltdb Boilerplate](https://github.com/bobintornado/boltdb-boilerplate) - Boilerplate wrapper around bolt aiming to make simple calls one-liners.
|
||||||
* [BoltDbWeb](https://github.com/evnix/boltdbweb) - A web based GUI for BoltDB files.
|
* [BoltDbWeb](https://github.com/evnix/boltdbweb) - A web based GUI for BoltDB files.
|
||||||
|
* [BoltDB Viewer](https://github.com/zc310/rich_boltdb) - A BoltDB Viewer Can run on Windows、Linux、Android system.
|
||||||
* [bleve](http://www.blevesearch.com/) - A pure Go search engine similar to ElasticSearch that uses Bolt as the default storage backend.
|
* [bleve](http://www.blevesearch.com/) - A pure Go search engine similar to ElasticSearch that uses Bolt as the default storage backend.
|
||||||
* [btcwallet](https://github.com/btcsuite/btcwallet) - A bitcoin wallet.
|
* [btcwallet](https://github.com/btcsuite/btcwallet) - A bitcoin wallet.
|
||||||
* [buckets](https://github.com/joyrexus/buckets) - a bolt wrapper streamlining
|
* [buckets](https://github.com/joyrexus/buckets) - a bolt wrapper streamlining
|
||||||
simple tx and key scans.
|
simple tx and key scans.
|
||||||
* [cayley](https://github.com/google/cayley) - Cayley is an open-source graph database using Bolt as optional backend.
|
* [cayley](https://github.com/google/cayley) - Cayley is an open-source graph database using Bolt as optional backend.
|
||||||
* [ChainStore](https://github.com/pressly/chainstore) - Simple key-value interface to a variety of storage engines organized as a chain of operations.
|
* [ChainStore](https://github.com/pressly/chainstore) - Simple key-value interface to a variety of storage engines organized as a chain of operations.
|
||||||
|
* [🌰 Chestnut](https://github.com/jrapoport/chestnut) - Chestnut is encrypted storage for Go.
|
||||||
* [Consul](https://github.com/hashicorp/consul) - Consul is service discovery and configuration made easy. Distributed, highly available, and datacenter-aware.
|
* [Consul](https://github.com/hashicorp/consul) - Consul is service discovery and configuration made easy. Distributed, highly available, and datacenter-aware.
|
||||||
* [DVID](https://github.com/janelia-flyem/dvid) - Added Bolt as optional storage engine and testing it against Basho-tuned leveldb.
|
* [DVID](https://github.com/janelia-flyem/dvid) - Added Bolt as optional storage engine and testing it against Basho-tuned leveldb.
|
||||||
* [dcrwallet](https://github.com/decred/dcrwallet) - A wallet for the Decred cryptocurrency.
|
* [dcrwallet](https://github.com/decred/dcrwallet) - A wallet for the Decred cryptocurrency.
|
||||||
|
@ -938,9 +940,8 @@ Below is a list of public, open source projects that use Bolt:
|
||||||
* [MetricBase](https://github.com/msiebuhr/MetricBase) - Single-binary version of Graphite.
|
* [MetricBase](https://github.com/msiebuhr/MetricBase) - Single-binary version of Graphite.
|
||||||
* [MuLiFS](https://github.com/dankomiocevic/mulifs) - Music Library Filesystem creates a filesystem to organise your music files.
|
* [MuLiFS](https://github.com/dankomiocevic/mulifs) - Music Library Filesystem creates a filesystem to organise your music files.
|
||||||
* [NATS](https://github.com/nats-io/nats-streaming-server) - NATS Streaming uses bbolt for message and metadata storage.
|
* [NATS](https://github.com/nats-io/nats-streaming-server) - NATS Streaming uses bbolt for message and metadata storage.
|
||||||
* [Operation Go: A Routine Mission](http://gocode.io) - An online programming game for Golang using Bolt for user accounts and a leaderboard.
|
|
||||||
* [photosite/session](https://godoc.org/bitbucket.org/kardianos/photosite/session) - Sessions for a photo viewing site.
|
|
||||||
* [Prometheus Annotation Server](https://github.com/oliver006/prom_annotation_server) - Annotation server for PromDash & Prometheus service monitoring system.
|
* [Prometheus Annotation Server](https://github.com/oliver006/prom_annotation_server) - Annotation server for PromDash & Prometheus service monitoring system.
|
||||||
|
* [Rain](https://github.com/cenkalti/rain) - BitTorrent client and library.
|
||||||
* [reef-pi](https://github.com/reef-pi/reef-pi) - reef-pi is an award winning, modular, DIY reef tank controller using easy to learn electronics based on a Raspberry Pi.
|
* [reef-pi](https://github.com/reef-pi/reef-pi) - reef-pi is an award winning, modular, DIY reef tank controller using easy to learn electronics based on a Raspberry Pi.
|
||||||
* [Request Baskets](https://github.com/darklynx/request-baskets) - A web service to collect arbitrary HTTP requests and inspect them via REST API or simple web UI, similar to [RequestBin](http://requestb.in/) service
|
* [Request Baskets](https://github.com/darklynx/request-baskets) - A web service to collect arbitrary HTTP requests and inspect them via REST API or simple web UI, similar to [RequestBin](http://requestb.in/) service
|
||||||
* [Seaweed File System](https://github.com/chrislusf/seaweedfs) - Highly scalable distributed key~file system with O(1) disk read.
|
* [Seaweed File System](https://github.com/chrislusf/seaweedfs) - Highly scalable distributed key~file system with O(1) disk read.
|
||||||
|
|
17
vendor/go.etcd.io/bbolt/bolt_unix.go
generated
vendored
17
vendor/go.etcd.io/bbolt/bolt_unix.go
generated
vendored
|
@ -7,6 +7,8 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// flock acquires an advisory lock on a file descriptor.
|
// flock acquires an advisory lock on a file descriptor.
|
||||||
|
@ -49,13 +51,13 @@ func funlock(db *DB) error {
|
||||||
// mmap memory maps a DB's data file.
|
// mmap memory maps a DB's data file.
|
||||||
func mmap(db *DB, sz int) error {
|
func mmap(db *DB, sz int) error {
|
||||||
// Map the data file to memory.
|
// Map the data file to memory.
|
||||||
b, err := syscall.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED|db.MmapFlags)
|
b, err := unix.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED|db.MmapFlags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advise the kernel that the mmap is accessed randomly.
|
// Advise the kernel that the mmap is accessed randomly.
|
||||||
err = madvise(b, syscall.MADV_RANDOM)
|
err = unix.Madvise(b, syscall.MADV_RANDOM)
|
||||||
if err != nil && err != syscall.ENOSYS {
|
if err != nil && err != syscall.ENOSYS {
|
||||||
// Ignore not implemented error in kernel because it still works.
|
// Ignore not implemented error in kernel because it still works.
|
||||||
return fmt.Errorf("madvise: %s", err)
|
return fmt.Errorf("madvise: %s", err)
|
||||||
|
@ -76,18 +78,9 @@ func munmap(db *DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmap using the original byte slice.
|
// Unmap using the original byte slice.
|
||||||
err := syscall.Munmap(db.dataref)
|
err := unix.Munmap(db.dataref)
|
||||||
db.dataref = nil
|
db.dataref = nil
|
||||||
db.data = nil
|
db.data = nil
|
||||||
db.datasz = 0
|
db.datasz = 0
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: This function is copied from stdlib because it is not available on darwin.
|
|
||||||
func madvise(b []byte, advice int) (err error) {
|
|
||||||
_, _, e1 := syscall.Syscall(syscall.SYS_MADVISE, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), uintptr(advice))
|
|
||||||
if e1 != 0 {
|
|
||||||
err = e1
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
114
vendor/go.etcd.io/bbolt/compact.go
generated
vendored
Normal file
114
vendor/go.etcd.io/bbolt/compact.go
generated
vendored
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
package bbolt
|
||||||
|
|
||||||
|
// Compact will create a copy of the source DB and in the destination DB. This may
|
||||||
|
// reclaim space that the source database no longer has use for. txMaxSize can be
|
||||||
|
// used to limit the transactions size of this process and may trigger intermittent
|
||||||
|
// commits. A value of zero will ignore transaction sizes.
|
||||||
|
// TODO: merge with: https://github.com/etcd-io/etcd/blob/b7f0f52a16dbf83f18ca1d803f7892d750366a94/mvcc/backend/backend.go#L349
|
||||||
|
func Compact(dst, src *DB, txMaxSize int64) error {
|
||||||
|
// commit regularly, or we'll run out of memory for large datasets if using one transaction.
|
||||||
|
var size int64
|
||||||
|
tx, err := dst.Begin(true)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer tx.Rollback()
|
||||||
|
|
||||||
|
if err := walk(src, func(keys [][]byte, k, v []byte, seq uint64) error {
|
||||||
|
// On each key/value, check if we have exceeded tx size.
|
||||||
|
sz := int64(len(k) + len(v))
|
||||||
|
if size+sz > txMaxSize && txMaxSize != 0 {
|
||||||
|
// Commit previous transaction.
|
||||||
|
if err := tx.Commit(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start new transaction.
|
||||||
|
tx, err = dst.Begin(true)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
size = 0
|
||||||
|
}
|
||||||
|
size += sz
|
||||||
|
|
||||||
|
// Create bucket on the root transaction if this is the first level.
|
||||||
|
nk := len(keys)
|
||||||
|
if nk == 0 {
|
||||||
|
bkt, err := tx.CreateBucket(k)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := bkt.SetSequence(seq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create buckets on subsequent levels, if necessary.
|
||||||
|
b := tx.Bucket(keys[0])
|
||||||
|
if nk > 1 {
|
||||||
|
for _, k := range keys[1:] {
|
||||||
|
b = b.Bucket(k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill the entire page for best compaction.
|
||||||
|
b.FillPercent = 1.0
|
||||||
|
|
||||||
|
// If there is no value then this is a bucket call.
|
||||||
|
if v == nil {
|
||||||
|
bkt, err := b.CreateBucket(k)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := bkt.SetSequence(seq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise treat it as a key/value pair.
|
||||||
|
return b.Put(k, v)
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return tx.Commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
// walkFunc is the type of the function called for keys (buckets and "normal"
|
||||||
|
// values) discovered by Walk. keys is the list of keys to descend to the bucket
|
||||||
|
// owning the discovered key/value pair k/v.
|
||||||
|
type walkFunc func(keys [][]byte, k, v []byte, seq uint64) error
|
||||||
|
|
||||||
|
// walk walks recursively the bolt database db, calling walkFn for each key it finds.
|
||||||
|
func walk(db *DB, walkFn walkFunc) error {
|
||||||
|
return db.View(func(tx *Tx) error {
|
||||||
|
return tx.ForEach(func(name []byte, b *Bucket) error {
|
||||||
|
return walkBucket(b, nil, name, nil, b.Sequence(), walkFn)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func walkBucket(b *Bucket, keypath [][]byte, k, v []byte, seq uint64, fn walkFunc) error {
|
||||||
|
// Execute callback.
|
||||||
|
if err := fn(keypath, k, v, seq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is not a bucket then stop.
|
||||||
|
if v != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate over each child key/value.
|
||||||
|
keypath = append(keypath, k)
|
||||||
|
return b.ForEach(func(k, v []byte) error {
|
||||||
|
if v == nil {
|
||||||
|
bkt := b.Bucket(k)
|
||||||
|
return walkBucket(bkt, keypath, k, nil, bkt.Sequence(), fn)
|
||||||
|
}
|
||||||
|
return walkBucket(b, keypath, k, v, b.Sequence(), fn)
|
||||||
|
})
|
||||||
|
}
|
66
vendor/go.etcd.io/bbolt/db.go
generated
vendored
66
vendor/go.etcd.io/bbolt/db.go
generated
vendored
|
@ -120,6 +120,12 @@ type DB struct {
|
||||||
// of truncate() and fsync() when growing the data file.
|
// of truncate() and fsync() when growing the data file.
|
||||||
AllocSize int
|
AllocSize int
|
||||||
|
|
||||||
|
// Mlock locks database file in memory when set to true.
|
||||||
|
// It prevents major page faults, however used memory can't be reclaimed.
|
||||||
|
//
|
||||||
|
// Supported only on Unix via mlock/munlock syscalls.
|
||||||
|
Mlock bool
|
||||||
|
|
||||||
path string
|
path string
|
||||||
openFile func(string, int, os.FileMode) (*os.File, error)
|
openFile func(string, int, os.FileMode) (*os.File, error)
|
||||||
file *os.File
|
file *os.File
|
||||||
|
@ -188,6 +194,7 @@ func Open(path string, mode os.FileMode, options *Options) (*DB, error) {
|
||||||
db.MmapFlags = options.MmapFlags
|
db.MmapFlags = options.MmapFlags
|
||||||
db.NoFreelistSync = options.NoFreelistSync
|
db.NoFreelistSync = options.NoFreelistSync
|
||||||
db.FreelistType = options.FreelistType
|
db.FreelistType = options.FreelistType
|
||||||
|
db.Mlock = options.Mlock
|
||||||
|
|
||||||
// Set default values for later DB operations.
|
// Set default values for later DB operations.
|
||||||
db.MaxBatchSize = DefaultMaxBatchSize
|
db.MaxBatchSize = DefaultMaxBatchSize
|
||||||
|
@ -337,7 +344,8 @@ func (db *DB) mmap(minsz int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the size is at least the minimum size.
|
// Ensure the size is at least the minimum size.
|
||||||
var size = int(info.Size())
|
fileSize := int(info.Size())
|
||||||
|
var size = fileSize
|
||||||
if size < minsz {
|
if size < minsz {
|
||||||
size = minsz
|
size = minsz
|
||||||
}
|
}
|
||||||
|
@ -346,6 +354,13 @@ func (db *DB) mmap(minsz int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if db.Mlock {
|
||||||
|
// Unlock db memory
|
||||||
|
if err := db.munlock(fileSize); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Dereference all mmap references before unmapping.
|
// Dereference all mmap references before unmapping.
|
||||||
if db.rwtx != nil {
|
if db.rwtx != nil {
|
||||||
db.rwtx.root.dereference()
|
db.rwtx.root.dereference()
|
||||||
|
@ -361,6 +376,13 @@ func (db *DB) mmap(minsz int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if db.Mlock {
|
||||||
|
// Don't allow swapping of data file
|
||||||
|
if err := db.mlock(fileSize); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save references to the meta pages.
|
// Save references to the meta pages.
|
||||||
db.meta0 = db.page(0).meta()
|
db.meta0 = db.page(0).meta()
|
||||||
db.meta1 = db.page(1).meta()
|
db.meta1 = db.page(1).meta()
|
||||||
|
@ -422,12 +444,36 @@ func (db *DB) mmapSize(size int) (int, error) {
|
||||||
return int(sz), nil
|
return int(sz), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *DB) munlock(fileSize int) error {
|
||||||
|
if err := munlock(db, fileSize); err != nil {
|
||||||
|
return fmt.Errorf("munlock error: " + err.Error())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DB) mlock(fileSize int) error {
|
||||||
|
if err := mlock(db, fileSize); err != nil {
|
||||||
|
return fmt.Errorf("mlock error: " + err.Error())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DB) mrelock(fileSizeFrom, fileSizeTo int) error {
|
||||||
|
if err := db.munlock(fileSizeFrom); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := db.mlock(fileSizeTo); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// init creates a new database file and initializes its meta pages.
|
// init creates a new database file and initializes its meta pages.
|
||||||
func (db *DB) init() error {
|
func (db *DB) init() error {
|
||||||
// Create two meta pages on a buffer.
|
// Create two meta pages on a buffer.
|
||||||
buf := make([]byte, db.pageSize*4)
|
buf := make([]byte, db.pageSize*4)
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
p := db.pageInBuffer(buf[:], pgid(i))
|
p := db.pageInBuffer(buf, pgid(i))
|
||||||
p.id = pgid(i)
|
p.id = pgid(i)
|
||||||
p.flags = metaPageFlag
|
p.flags = metaPageFlag
|
||||||
|
|
||||||
|
@ -444,13 +490,13 @@ func (db *DB) init() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write an empty freelist at page 3.
|
// Write an empty freelist at page 3.
|
||||||
p := db.pageInBuffer(buf[:], pgid(2))
|
p := db.pageInBuffer(buf, pgid(2))
|
||||||
p.id = pgid(2)
|
p.id = pgid(2)
|
||||||
p.flags = freelistPageFlag
|
p.flags = freelistPageFlag
|
||||||
p.count = 0
|
p.count = 0
|
||||||
|
|
||||||
// Write an empty leaf page at page 4.
|
// Write an empty leaf page at page 4.
|
||||||
p = db.pageInBuffer(buf[:], pgid(3))
|
p = db.pageInBuffer(buf, pgid(3))
|
||||||
p.id = pgid(3)
|
p.id = pgid(3)
|
||||||
p.flags = leafPageFlag
|
p.flags = leafPageFlag
|
||||||
p.count = 0
|
p.count = 0
|
||||||
|
@ -462,6 +508,7 @@ func (db *DB) init() error {
|
||||||
if err := fdatasync(db); err != nil {
|
if err := fdatasync(db); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
db.filesz = len(buf)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -973,6 +1020,12 @@ func (db *DB) grow(sz int) error {
|
||||||
if err := db.file.Sync(); err != nil {
|
if err := db.file.Sync(); err != nil {
|
||||||
return fmt.Errorf("file sync error: %s", err)
|
return fmt.Errorf("file sync error: %s", err)
|
||||||
}
|
}
|
||||||
|
if db.Mlock {
|
||||||
|
// unlock old file and lock new one
|
||||||
|
if err := db.mrelock(db.filesz, sz); err != nil {
|
||||||
|
return fmt.Errorf("mlock/munlock error: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
db.filesz = sz
|
db.filesz = sz
|
||||||
|
@ -1064,6 +1117,11 @@ type Options struct {
|
||||||
// OpenFile is used to open files. It defaults to os.OpenFile. This option
|
// OpenFile is used to open files. It defaults to os.OpenFile. This option
|
||||||
// is useful for writing hermetic tests.
|
// is useful for writing hermetic tests.
|
||||||
OpenFile func(string, int, os.FileMode) (*os.File, error)
|
OpenFile func(string, int, os.FileMode) (*os.File, error)
|
||||||
|
|
||||||
|
// Mlock locks database file in memory when set to true.
|
||||||
|
// It prevents potential page faults, however
|
||||||
|
// used memory can't be reclaimed. (UNIX only)
|
||||||
|
Mlock bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultOptions represent the options used if nil options are passed into Open().
|
// DefaultOptions represent the options used if nil options are passed into Open().
|
||||||
|
|
6
vendor/go.etcd.io/bbolt/freelist_hmap.go
generated
vendored
6
vendor/go.etcd.io/bbolt/freelist_hmap.go
generated
vendored
|
@ -4,7 +4,7 @@ import "sort"
|
||||||
|
|
||||||
// hashmapFreeCount returns count of free pages(hashmap version)
|
// hashmapFreeCount returns count of free pages(hashmap version)
|
||||||
func (f *freelist) hashmapFreeCount() int {
|
func (f *freelist) hashmapFreeCount() int {
|
||||||
// use the forwardmap to get the total count
|
// use the forwardMap to get the total count
|
||||||
count := 0
|
count := 0
|
||||||
for _, size := range f.forwardMap {
|
for _, size := range f.forwardMap {
|
||||||
count += int(size)
|
count += int(size)
|
||||||
|
@ -41,7 +41,7 @@ func (f *freelist) hashmapAllocate(txid txid, n int) pgid {
|
||||||
|
|
||||||
for pid := range bm {
|
for pid := range bm {
|
||||||
// remove the initial
|
// remove the initial
|
||||||
f.delSpan(pid, uint64(size))
|
f.delSpan(pid, size)
|
||||||
|
|
||||||
f.allocs[pid] = txid
|
f.allocs[pid] = txid
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ func (f *freelist) hashmapAllocate(txid txid, n int) pgid {
|
||||||
f.addSpan(pid+pgid(n), remain)
|
f.addSpan(pid+pgid(n), remain)
|
||||||
|
|
||||||
for i := pgid(0); i < pgid(n); i++ {
|
for i := pgid(0); i < pgid(n); i++ {
|
||||||
delete(f.cache, pid+pgid(i))
|
delete(f.cache, pid+i)
|
||||||
}
|
}
|
||||||
return pid
|
return pid
|
||||||
}
|
}
|
||||||
|
|
36
vendor/go.etcd.io/bbolt/mlock_unix.go
generated
vendored
Normal file
36
vendor/go.etcd.io/bbolt/mlock_unix.go
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package bbolt
|
||||||
|
|
||||||
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
// mlock locks memory of db file
|
||||||
|
func mlock(db *DB, fileSize int) error {
|
||||||
|
sizeToLock := fileSize
|
||||||
|
if sizeToLock > db.datasz {
|
||||||
|
// Can't lock more than mmaped slice
|
||||||
|
sizeToLock = db.datasz
|
||||||
|
}
|
||||||
|
if err := unix.Mlock(db.dataref[:sizeToLock]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//munlock unlocks memory of db file
|
||||||
|
func munlock(db *DB, fileSize int) error {
|
||||||
|
if db.dataref == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
sizeToUnlock := fileSize
|
||||||
|
if sizeToUnlock > db.datasz {
|
||||||
|
// Can't unlock more than mmaped slice
|
||||||
|
sizeToUnlock = db.datasz
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := unix.Munlock(db.dataref[:sizeToUnlock]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
11
vendor/go.etcd.io/bbolt/mlock_windows.go
generated
vendored
Normal file
11
vendor/go.etcd.io/bbolt/mlock_windows.go
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package bbolt
|
||||||
|
|
||||||
|
// mlock locks memory of db file
|
||||||
|
func mlock(_ *DB, _ int) error {
|
||||||
|
panic("mlock is supported only on UNIX systems")
|
||||||
|
}
|
||||||
|
|
||||||
|
//munlock unlocks memory of db file
|
||||||
|
func munlock(_ *DB, _ int) error {
|
||||||
|
panic("munlock is supported only on UNIX systems")
|
||||||
|
}
|
3
vendor/go.etcd.io/bbolt/tx.go
generated
vendored
3
vendor/go.etcd.io/bbolt/tx.go
generated
vendored
|
@ -188,7 +188,6 @@ func (tx *Tx) Commit() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If strict mode is enabled then perform a consistency check.
|
// If strict mode is enabled then perform a consistency check.
|
||||||
// Only the first consistency error is reported in the panic.
|
|
||||||
if tx.db.StrictMode {
|
if tx.db.StrictMode {
|
||||||
ch := tx.Check()
|
ch := tx.Check()
|
||||||
var errs []string
|
var errs []string
|
||||||
|
@ -393,7 +392,7 @@ func (tx *Tx) CopyFile(path string, mode os.FileMode) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tx.Copy(f)
|
_, err = tx.WriteTo(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = f.Close()
|
_ = f.Close()
|
||||||
return err
|
return err
|
||||||
|
|
3
vendor/modules.txt
vendored
3
vendor/modules.txt
vendored
|
@ -758,7 +758,7 @@ github.com/vishvananda/netlink/nl
|
||||||
github.com/vishvananda/netns
|
github.com/vishvananda/netns
|
||||||
# github.com/vmihailenco/msgpack v4.0.4+incompatible
|
# github.com/vmihailenco/msgpack v4.0.4+incompatible
|
||||||
## explicit
|
## explicit
|
||||||
# go.etcd.io/bbolt v1.3.6 => go.etcd.io/bbolt v1.3.5
|
# go.etcd.io/bbolt v1.3.6
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
go.etcd.io/bbolt
|
go.etcd.io/bbolt
|
||||||
# go.opencensus.io v0.23.0 => go.opencensus.io v0.22.3
|
# go.opencensus.io v0.23.0 => go.opencensus.io v0.22.3
|
||||||
|
@ -1011,7 +1011,6 @@ gotest.tools/v3/skip
|
||||||
# github.com/prometheus/procfs => github.com/prometheus/procfs v0.0.11
|
# github.com/prometheus/procfs => github.com/prometheus/procfs v0.0.11
|
||||||
# github.com/stretchr/testify => github.com/stretchr/testify v1.3.0
|
# github.com/stretchr/testify => github.com/stretchr/testify v1.3.0
|
||||||
# github.com/vishvananda/netlink => github.com/vishvananda/netlink v1.1.0
|
# github.com/vishvananda/netlink => github.com/vishvananda/netlink v1.1.0
|
||||||
# go.etcd.io/bbolt => go.etcd.io/bbolt v1.3.5
|
|
||||||
# go.opencensus.io => go.opencensus.io v0.22.3
|
# go.opencensus.io => go.opencensus.io v0.22.3
|
||||||
# golang.org/x/oauth2 => golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
# golang.org/x/oauth2 => golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
||||||
# google.golang.org/api => google.golang.org/api v0.8.0
|
# google.golang.org/api => google.golang.org/api v0.8.0
|
||||||
|
|
Loading…
Reference in a new issue