mirror of https://github.com/etcd-io/bbolt.git
parent
b2cf45b995
commit
33c86c78ca
|
@ -11,6 +11,5 @@ jobs:
|
||||||
- run: make fmt
|
- run: make fmt
|
||||||
- run: make race
|
- run: make race
|
||||||
- run: make test
|
- run: make test
|
||||||
# Enable when fixed (same as make lint)
|
- name: golangci-lint
|
||||||
# - name: golangci-lint
|
uses: golangci/golangci-lint-action@v3
|
||||||
# uses: golangci/golangci-lint-action@v2
|
|
||||||
|
|
|
@ -1631,7 +1631,11 @@ func (cmd *BenchCommand) startProfiling(options *BenchOptions) {
|
||||||
fmt.Fprintf(cmd.Stderr, "bench: could not create cpu profile %q: %v\n", options.CPUProfile, err)
|
fmt.Fprintf(cmd.Stderr, "bench: could not create cpu profile %q: %v\n", options.CPUProfile, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
pprof.StartCPUProfile(cpuprofile)
|
err = pprof.StartCPUProfile(cpuprofile)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(cmd.Stderr, "bench: could not start cpu profile %q: %v\n", options.CPUProfile, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start memory profiling.
|
// Start memory profiling.
|
||||||
|
@ -1664,13 +1668,19 @@ func (cmd *BenchCommand) stopProfiling() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if memprofile != nil {
|
if memprofile != nil {
|
||||||
pprof.Lookup("heap").WriteTo(memprofile, 0)
|
err := pprof.Lookup("heap").WriteTo(memprofile, 0)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(cmd.Stderr, "bench: could not write mem profile")
|
||||||
|
}
|
||||||
memprofile.Close()
|
memprofile.Close()
|
||||||
memprofile = nil
|
memprofile = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if blockprofile != nil {
|
if blockprofile != nil {
|
||||||
pprof.Lookup("block").WriteTo(blockprofile, 0)
|
err := pprof.Lookup("block").WriteTo(blockprofile, 0)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(cmd.Stderr, "bench: could not write block profile")
|
||||||
|
}
|
||||||
blockprofile.Close()
|
blockprofile.Close()
|
||||||
blockprofile = nil
|
blockprofile = nil
|
||||||
runtime.SetBlockProfileRate(0)
|
runtime.SetBlockProfileRate(0)
|
||||||
|
|
|
@ -12,7 +12,11 @@ func Compact(dst, src *DB, txMaxSize int64) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer tx.Rollback()
|
defer func() {
|
||||||
|
if tempErr := tx.Rollback(); tempErr != nil {
|
||||||
|
err = tempErr
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if err := walk(src, func(keys [][]byte, k, v []byte, seq uint64) error {
|
if err := walk(src, func(keys [][]byte, k, v []byte, seq uint64) error {
|
||||||
// On each key/value, check if we have exceeded tx size.
|
// On each key/value, check if we have exceeded tx size.
|
||||||
|
@ -73,8 +77,9 @@ func Compact(dst, src *DB, txMaxSize int64) error {
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
err = tx.Commit()
|
||||||
|
|
||||||
return tx.Commit()
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// walkFunc is the type of the function called for keys (buckets and "normal"
|
// walkFunc is the type of the function called for keys (buckets and "normal"
|
||||||
|
|
10
db_test.go
10
db_test.go
|
@ -647,8 +647,14 @@ func TestDB_Concurrent_WriteTo(t *testing.T) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
time.Sleep(time.Duration(rand.Intn(20)+1) * time.Millisecond)
|
time.Sleep(time.Duration(rand.Intn(20)+1) * time.Millisecond)
|
||||||
tx.WriteTo(f)
|
_, err = tx.WriteTo(f)
|
||||||
tx.Rollback()
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
err = tx.Rollback()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
snap := &DB{nil, f.Name(), o}
|
snap := &DB{nil, f.Name(), o}
|
||||||
snap.MustReopen()
|
snap.MustReopen()
|
||||||
|
|
2
tx.go
2
tx.go
|
@ -574,7 +574,7 @@ func (tx *Tx) write() error {
|
||||||
for i := range buf {
|
for i := range buf {
|
||||||
buf[i] = 0
|
buf[i] = 0
|
||||||
}
|
}
|
||||||
tx.db.pagePool.Put(buf)
|
tx.db.pagePool.Put(buf) //nolint:staticcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
10
tx_test.go
10
tx_test.go
|
@ -57,7 +57,10 @@ func TestTx_Check_ReadOnly(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Close the view transaction
|
// Close the view transaction
|
||||||
tx.Rollback()
|
err = tx.Rollback()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that committing a closed transaction returns an error.
|
// Ensure that committing a closed transaction returns an error.
|
||||||
|
@ -112,7 +115,10 @@ func TestTx_Commit_ErrTxNotWritable(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// Close the view transaction
|
// Close the view transaction
|
||||||
tx.Rollback()
|
err = tx.Rollback()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that a transaction can retrieve a cursor on the root bucket.
|
// Ensure that a transaction can retrieve a cursor on the root bucket.
|
||||||
|
|
|
@ -108,10 +108,10 @@ func skipOnMemlockLimitBelow(t *testing.T, memlockLimitRequest uint64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.Cur < memlockLimitRequest {
|
if info.Cur < memlockLimitRequest {
|
||||||
t.Skip(fmt.Sprintf(
|
t.Skipf(
|
||||||
"skipping as RLIMIT_MEMLOCK is unsufficient: %v < %v",
|
"skipping as RLIMIT_MEMLOCK is insufficient: %v < %v",
|
||||||
info.Cur,
|
info.Cur,
|
||||||
memlockLimitRequest,
|
memlockLimitRequest,
|
||||||
))
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue