From 2b42000f4392a1b8f73778d8f220a28875279025 Mon Sep 17 00:00:00 2001 From: Nathan Bronson Date: Mon, 2 Nov 2015 09:23:39 -0800 Subject: [PATCH] incorrect batch group size computation for write throttling Summary: When a write batch can't join a batch group due to the total size of the contained batches, the write controller's GetDelay is passed a size value that includes the rejected batch. Test Plan: make check Reviewers: sdong, igor Reviewed By: igor Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D50343 --- db/write_thread.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/write_thread.cc b/db/write_thread.cc index 9b66af240..1e606eaa7 100644 --- a/db/write_thread.cc +++ b/db/write_thread.cc @@ -120,12 +120,13 @@ size_t WriteThread::EnterAsBatchGroupLeader( break; } - size += WriteBatchInternal::ByteSize(w->batch); - if (size > max_size) { + auto batch_size = WriteBatchInternal::ByteSize(w->batch); + if (size + batch_size > max_size) { // Do not make batch too big break; } + size += batch_size; write_batch_group->push_back(w->batch); w->in_batch_group = true; *last_writer = w;