diff --git a/value.go b/value.go index b68ef10ba..0f97375dc 100644 --- a/value.go +++ b/value.go @@ -564,6 +564,11 @@ func (vlog *valueLog) rewrite(f *logFile, tr trace.Trace) error { ne.Value = append([]byte{}, e.Value...) es := int64(ne.estimateSize(vlog.opt.ValueThreshold)) + // Consider size of value as well while considering the total size + // of the batch. There have been reports of high memory usage in + // rewrite because we don't consider the value size. See #1292. + es += int64(len(e.Value)) + // Ensure length and size of wb is within transaction limits. if int64(len(wb)+1) >= vlog.opt.maxBatchCount || size+es >= vlog.opt.maxBatchSize {