Skip to content

Commit

Permalink
implement batching for leveldb
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Jul 26, 2016
1 parent 9400d1f commit 4fa81d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions flatfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down

0 comments on commit 4fa81d1

Please sign in to comment.