Skip to content
Permalink
Browse files

Ensure rewrite in vlog is within transactional limits (#911)

* Ensure rewrite in vlog is within transactional limits

With this commit the temporary list of entries built during value log
iteration is committed before it overflows transactional limits
(maxBatchSize and maxBatchCount).

Fixes #907
  • Loading branch information...
jarifibrahim committed Jul 4, 2019
1 parent 329b682 commit 740b849d305e62012c5454bbe7348851c8b69b26
Showing with 6 additions and 3 deletions.
  1. +6 −3 value.go
@@ -397,16 +397,19 @@ func (vlog *valueLog) rewrite(f *logFile, tr trace.Trace) error {
}

ne.Value = append([]byte{}, e.Value...)
wb = append(wb, ne)
size += int64(e.estimateSize(vlog.opt.ValueThreshold))
if size >= 64*mi {
es := int64(ne.estimateSize(vlog.opt.ValueThreshold))
// Ensure length and size of wb is within transaction limits.
if int64(len(wb)+1) > vlog.opt.maxBatchCount ||
size+es > vlog.opt.maxBatchSize {
tr.LazyPrintf("request has %d entries, size %d", len(wb), size)
if err := vlog.db.batchSet(wb); err != nil {
return err
}
size = 0
wb = wb[:0]
}
wb = append(wb, ne)
size += es
} else {
vlog.db.opt.Warningf("This entry should have been caught. %+v\n", e)
}

0 comments on commit 740b849

Please sign in to comment.
You can’t perform that action at this time.