vendor: Update github.com/syndtr/goleveldb

This commit is contained in:
Jakob Borg 2017-03-07 11:57:45 +01:00
parent 4e3fdfaeef
commit 151004d645
5 changed files with 19 additions and 4 deletions

View File

@ -289,7 +289,7 @@ func (db *DB) memCompaction() {
close(resumeC) close(resumeC)
resumeC = nil resumeC = nil
case <-db.closeC: case <-db.closeC:
return db.compactionExitTransact()
} }
var ( var (
@ -338,7 +338,7 @@ func (db *DB) memCompaction() {
case <-resumeC: case <-resumeC:
close(resumeC) close(resumeC)
case <-db.closeC: case <-db.closeC:
return db.compactionExitTransact()
} }
} }

View File

@ -7,6 +7,7 @@
package leveldb package leveldb
import ( import (
"errors"
"sync/atomic" "sync/atomic"
"time" "time"
@ -15,6 +16,10 @@ import (
"github.com/syndtr/goleveldb/leveldb/storage" "github.com/syndtr/goleveldb/leveldb/storage"
) )
var (
errHasFrozenMem = errors.New("has frozen mem")
)
type memDB struct { type memDB struct {
db *DB db *DB
*memdb.DB *memdb.DB
@ -126,7 +131,7 @@ func (db *DB) newMem(n int) (mem *memDB, err error) {
defer db.memMu.Unlock() defer db.memMu.Unlock()
if db.frozenMem != nil { if db.frozenMem != nil {
panic("still has frozen mem") return nil, errHasFrozenMem
} }
if db.journal == nil { if db.journal == nil {

View File

@ -32,15 +32,24 @@ func (db *DB) writeJournal(batches []*Batch, seq uint64, sync bool) error {
} }
func (db *DB) rotateMem(n int, wait bool) (mem *memDB, err error) { func (db *DB) rotateMem(n int, wait bool) (mem *memDB, err error) {
retryLimit := 3
retry:
// Wait for pending memdb compaction. // Wait for pending memdb compaction.
err = db.compTriggerWait(db.mcompCmdC) err = db.compTriggerWait(db.mcompCmdC)
if err != nil { if err != nil {
return return
} }
retryLimit--
// Create new memdb and journal. // Create new memdb and journal.
mem, err = db.newMem(n) mem, err = db.newMem(n)
if err != nil { if err != nil {
if err == errHasFrozenMem {
if retryLimit <= 0 {
panic("BUG: still has frozen memdb")
}
goto retry
}
return return
} }

View File

@ -581,6 +581,7 @@ func (r *Reader) readRawBlock(bh blockHandle, verifyChecksum bool) ([]byte, erro
case blockTypeSnappyCompression: case blockTypeSnappyCompression:
decLen, err := snappy.DecodedLen(data[:bh.length]) decLen, err := snappy.DecodedLen(data[:bh.length])
if err != nil { if err != nil {
r.bpool.Put(data)
return nil, r.newErrCorruptedBH(bh, err.Error()) return nil, r.newErrCorruptedBH(bh, err.Error())
} }
decData := r.bpool.Get(decLen) decData := r.bpool.Get(decLen)

2
vendor/manifest vendored
View File

@ -265,7 +265,7 @@
"importpath": "github.com/syndtr/goleveldb", "importpath": "github.com/syndtr/goleveldb",
"repository": "https://github.com/syndtr/goleveldb", "repository": "https://github.com/syndtr/goleveldb",
"vcs": "git", "vcs": "git",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "3c5717caf1475fd25964109a0fc640bd150fce43",
"branch": "master" "branch": "master"
}, },
{ {