vendor: pull in latest changes for goleveldb (#15090)

This commit is contained in:
Péter Szilágyi 2017-09-05 16:04:32 +03:00 committed by Felix Lange
parent c91f7beb53
commit cd6c861dc5
8 changed files with 68 additions and 35 deletions

View File

@ -844,7 +844,7 @@ func (db *DB) Get(key []byte, ro *opt.ReadOptions) (value []byte, err error) {
// Has returns true if the DB does contains the given key. // Has returns true if the DB does contains the given key.
// //
// It is safe to modify the contents of the argument after Get returns. // It is safe to modify the contents of the argument after Has returns.
func (db *DB) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error) { func (db *DB) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error) {
err = db.ok() err = db.ok()
if err != nil { if err != nil {

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

@ -8,6 +8,8 @@
// //
// Create or open a database: // Create or open a database:
// //
// // 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) // db, err := leveldb.OpenFile("path/to/db", nil)
// ... // ...
// defer db.Close() // defer db.Close()

View File

@ -234,14 +234,30 @@ func (fs *fileStorage) SetMeta(fd FileDesc) (err error) {
return return
} }
_, err = fmt.Fprintln(w, fsGenName(fd)) _, err = fmt.Fprintln(w, fsGenName(fd))
// Close the file first. if err != nil {
if cerr := w.Close(); cerr != nil { fs.log(fmt.Sprintf("write CURRENT.%d: %v", fd.Num, err))
fs.log(fmt.Sprintf("close CURRENT.%d: %v", fd.Num, cerr)) return
}
if err = w.Sync(); err != nil {
fs.log(fmt.Sprintf("flush CURRENT.%d: %v", fd.Num, err))
return
}
if err = w.Close(); err != nil {
fs.log(fmt.Sprintf("close CURRENT.%d: %v", fd.Num, err))
return
} }
if err != nil { if err != nil {
return return
} }
return rename(path, filepath.Join(fs.path, "CURRENT")) if err = rename(path, filepath.Join(fs.path, "CURRENT")); err != nil {
fs.log(fmt.Sprintf("rename CURRENT.%d: %v", fd.Num, err))
return
}
// Sync root directory.
if err = syncDir(fs.path); err != nil {
fs.log(fmt.Sprintf("syncDir: %v", err))
}
return
} }
func (fs *fileStorage) GetMeta() (fd FileDesc, err error) { func (fs *fileStorage) GetMeta() (fd FileDesc, err error) {

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)

54
vendor/vendor.json vendored
View File

@ -334,76 +334,76 @@
"revisionTime": "2016-06-18T19:32:21Z" "revisionTime": "2016-06-18T19:32:21Z"
}, },
{ {
"checksumSHA1": "QvOrAO5S37PL/6XZVWIVGyAbn60=", "checksumSHA1": "yHbyLpI/Meh0DGrmi8x6FrDxxUY=",
"path": "github.com/syndtr/goleveldb/leveldb", "path": "github.com/syndtr/goleveldb/leveldb",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "EKIow7XkgNdWvR/982ffIZxKG8Y=", "checksumSHA1": "EKIow7XkgNdWvR/982ffIZxKG8Y=",
"path": "github.com/syndtr/goleveldb/leveldb/cache", "path": "github.com/syndtr/goleveldb/leveldb/cache",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "5KPgnvCPlR0ysDAqo6jApzRQ3tw=", "checksumSHA1": "5KPgnvCPlR0ysDAqo6jApzRQ3tw=",
"path": "github.com/syndtr/goleveldb/leveldb/comparer", "path": "github.com/syndtr/goleveldb/leveldb/comparer",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "1DRAxdlWzS4U0xKN/yQ/fdNN7f0=", "checksumSHA1": "1DRAxdlWzS4U0xKN/yQ/fdNN7f0=",
"path": "github.com/syndtr/goleveldb/leveldb/errors", "path": "github.com/syndtr/goleveldb/leveldb/errors",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "eqKeD6DS7eNCtxVYZEHHRKkyZrw=", "checksumSHA1": "eqKeD6DS7eNCtxVYZEHHRKkyZrw=",
"path": "github.com/syndtr/goleveldb/leveldb/filter", "path": "github.com/syndtr/goleveldb/leveldb/filter",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "8dXuAVIsbtaMiGGuHjzGR6Ny/5c=", "checksumSHA1": "8dXuAVIsbtaMiGGuHjzGR6Ny/5c=",
"path": "github.com/syndtr/goleveldb/leveldb/iterator", "path": "github.com/syndtr/goleveldb/leveldb/iterator",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "gJY7bRpELtO0PJpZXgPQ2BYFJ88=", "checksumSHA1": "gJY7bRpELtO0PJpZXgPQ2BYFJ88=",
"path": "github.com/syndtr/goleveldb/leveldb/journal", "path": "github.com/syndtr/goleveldb/leveldb/journal",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "j+uaQ6DwJ50dkIdfMQu1TXdlQcY=", "checksumSHA1": "j+uaQ6DwJ50dkIdfMQu1TXdlQcY=",
"path": "github.com/syndtr/goleveldb/leveldb/memdb", "path": "github.com/syndtr/goleveldb/leveldb/memdb",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "UmQeotV+m8/FduKEfLOhjdp18rs=", "checksumSHA1": "UmQeotV+m8/FduKEfLOhjdp18rs=",
"path": "github.com/syndtr/goleveldb/leveldb/opt", "path": "github.com/syndtr/goleveldb/leveldb/opt",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "/Wvv9HeJTN9UUjdjwUlz7X4ioIo=", "checksumSHA1": "tQ2AqXXAEy9icbZI9dLVdZGvWMw=",
"path": "github.com/syndtr/goleveldb/leveldb/storage", "path": "github.com/syndtr/goleveldb/leveldb/storage",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "JTJA+u8zk7EXy1UUmpFPNGvtO2A=", "checksumSHA1": "gWFPMz8OQeul0t54RM66yMTX49g=",
"path": "github.com/syndtr/goleveldb/leveldb/table", "path": "github.com/syndtr/goleveldb/leveldb/table",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "4zil8Gwg8VPkDn1YzlgCvtukJFU=", "checksumSHA1": "4zil8Gwg8VPkDn1YzlgCvtukJFU=",
"path": "github.com/syndtr/goleveldb/leveldb/util", "path": "github.com/syndtr/goleveldb/leveldb/util",
"revision": "23851d93a2292dcc56e71a18ec9e0624d84a0f65", "revision": "b89cc31ef7977104127d34c1bd31ebd1a9db2199",
"revisionTime": "2016-12-27T11:05:19Z" "revisionTime": "2017-07-25T06:48:36Z"
}, },
{ {
"checksumSHA1": "TT1rac6kpQp2vz24m5yDGUNQ/QQ=", "checksumSHA1": "TT1rac6kpQp2vz24m5yDGUNQ/QQ=",