vendor: update leveldb to 211f780 (poolfix) (#15988)

This commit is contained in:
Martin Holst Swende 2018-01-29 15:17:59 +01:00 committed by Péter Szilágyi
parent dd7a715d73
commit 59a852e418
5 changed files with 27 additions and 22 deletions

View File

@ -1,12 +0,0 @@
language: go
go:
- 1.4
- 1.5
- 1.6
- 1.7
- tip
script:
- go test -timeout 1h ./...
- go test -timeout 30m -race -run "TestDB_(Concurrent|GoleveldbIssue74)" ./leveldb

View File

@ -10,13 +10,15 @@ Installation
Requirements
-----------
* Need at least `go1.4` or newer.
* Need at least `go1.5` or newer.
Usage
-----------
Create or open a database:
```go
// The returned DB instance is safe for concurrent use. Which mean that all
// DB's methods may be called concurrently from multiple goroutine.
db, err := leveldb.OpenFile("path/to/db", nil)
...
defer db.Close()

View File

@ -32,6 +32,11 @@ type DB struct {
// Need 64-bit alignment.
seq uint64
// Stats. Need 64-bit alignment.
cWriteDelay int64 // The cumulative duration of write delays
cWriteDelayN int32 // The cumulative number of write delays
aliveSnaps, aliveIters int32
// Session.
s *session
@ -49,9 +54,6 @@ type DB struct {
snapsMu sync.Mutex
snapsList *list.List
// Stats.
aliveSnaps, aliveIters int32
// Write.
batchPool sync.Pool
writeMergeC chan writeMerge
@ -321,7 +323,7 @@ func recoverTable(s *session, o *opt.Options) error {
}
}
err = iter.Error()
if err != nil {
if err != nil && !errors.IsCorrupted(err) {
return
}
err = tw.Close()
@ -392,7 +394,7 @@ func recoverTable(s *session, o *opt.Options) error {
}
imax = append(imax[:0], key...)
}
if err := iter.Error(); err != nil {
if err := iter.Error(); err != nil && !errors.IsCorrupted(err) {
iter.Release()
return err
}
@ -904,6 +906,8 @@ func (db *DB) GetSnapshot() (*Snapshot, error) {
// Returns the number of files at level 'n'.
// leveldb.stats
// Returns statistics of the underlying DB.
// leveldb.writedelay
// Returns cumulative write delay caused by compaction.
// leveldb.sstables
// Returns sstables list for each level.
// leveldb.blockpool
@ -955,6 +959,9 @@ func (db *DB) GetProperty(name string) (value string, err error) {
level, len(tables), float64(tables.size())/1048576.0, duration.Seconds(),
float64(read)/1048576.0, float64(write)/1048576.0)
}
case p == "writedelay":
writeDelayN, writeDelay := atomic.LoadInt32(&db.cWriteDelayN), time.Duration(atomic.LoadInt64(&db.cWriteDelay))
value = fmt.Sprintf("DelayN:%d Delay:%s", writeDelayN, writeDelay)
case p == "sstables":
for level, tables := range v.levels {
value += fmt.Sprintf("--- level %d ---\n", level)

View File

@ -7,6 +7,7 @@
package leveldb
import (
"sync/atomic"
"time"
"github.com/syndtr/goleveldb/leveldb/memdb"
@ -117,6 +118,8 @@ func (db *DB) flush(n int) (mdb *memDB, mdbFree int, err error) {
db.writeDelayN++
} else if db.writeDelayN > 0 {
db.logf("db@write was delayed N·%d T·%v", db.writeDelayN, db.writeDelay)
atomic.AddInt32(&db.cWriteDelayN, int32(db.writeDelayN))
atomic.AddInt64(&db.cWriteDelay, int64(db.writeDelay))
db.writeDelay = 0
db.writeDelayN = 0
}
@ -143,7 +146,7 @@ func (db *DB) unlockWrite(overflow bool, merged int, err error) {
}
}
// ourBatch if defined should equal with batch.
// ourBatch is batch that we can modify.
func (db *DB) writeLocked(batch, ourBatch *Batch, merge, sync bool) error {
// Try to flush memdb. This method would also trying to throttle writes
// if it is too fast and compaction cannot catch-up.
@ -212,6 +215,11 @@ func (db *DB) writeLocked(batch, ourBatch *Batch, merge, sync bool) error {
}
}
// Release ourBatch if any.
if ourBatch != nil {
defer db.batchPool.Put(ourBatch)
}
// Seq number.
seq := db.seq + 1

6
vendor/vendor.json vendored
View File

@ -394,10 +394,10 @@
"revisionTime": "2017-07-05T02:17:15Z"
},
{
"checksumSHA1": "yHbyLpI/Meh0DGrmi8x6FrDxxUY=",
"checksumSHA1": "rpu5ZHjXlV13UKA7L1d5MTOyQwA=",
"path": "github.com/syndtr/goleveldb/leveldb",
"revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2017-07-25T06:48:36Z"
"revision": "211f780988068502fe874c44dae530528ebd840f",
"revisionTime": "2018-01-28T14:04:16Z"
},
{
"checksumSHA1": "EKIow7XkgNdWvR/982ffIZxKG8Y=",