Skip to content

Commit 9ae6f6c

Browse files
author
Ibrahim Jarif
committed
GC: Consider size of value while rewriting (#1357)
The existing code doesn't consider the size of the value while calculating the size of the entry batch in rewrite method. This PR fixes it. Fixes #1292
1 parent 5d84f93 commit 9ae6f6c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

value.go

+5
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,11 @@ func (vlog *valueLog) rewrite(f *logFile, tr trace.Trace) error {
564564

565565
ne.Value = append([]byte{}, e.Value...)
566566
es := int64(ne.estimateSize(vlog.opt.ValueThreshold))
567+
// Consider size of value as well while considering the total size
568+
// of the batch. There have been reports of high memory usage in
569+
// rewrite because we don't consider the value size. See #1292.
570+
es += int64(len(e.Value))
571+
567572
// Ensure length and size of wb is within transaction limits.
568573
if int64(len(wb)+1) >= vlog.opt.maxBatchCount ||
569574
size+es >= vlog.opt.maxBatchSize {

0 commit comments

Comments
 (0)