Commit 4fa81d12 authored by Jeromy's avatar Jeromy

implement batching for leveldb

parent 9400d1f2
......@@ -99,7 +99,7 @@ func (fs *Datastore) makePrefixDirNoSync(dir string) error {
return nil
}
var putMaxRetries = 3
var putMaxRetries = 6
func (fs *Datastore) Put(key datastore.Key, value interface{}) error {
val, ok := value.([]byte)
......@@ -111,15 +111,15 @@ func (fs *Datastore) Put(key datastore.Key, value interface{}) error {
for i := 0; i < putMaxRetries; i++ {
err = fs.doPut(key, val)
if err == nil {
return nil
break
}
if !strings.Contains(err.Error(), "too many open files") {
return err
break
}
log.Errorf("too many open files, retrying in %dms", 100*i)
time.Sleep(time.Millisecond * 100 * time.Duration(i))
time.Sleep(time.Millisecond * 100 * time.Duration(i+1))
}
return err
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment