You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2017/01/19 00:16:40 UTC
kudu git commit: binary_plain_block: fix an incorrect vector.reserve()
Repository: kudu
Updated Branches:
refs/heads/master 6e683a00d -> 7d16929c4
binary_plain_block: fix an incorrect vector.reserve()
I noticed the following surprising stack trace on a tserver:
Thread 118 (Thread 0x7f9a865ff700 (LWP 1332)):
#0 0x0000003ae0a89b40 in _wordcopy_fwd_aligned () from /lib64/libc.so.6
#1 0x0000003ae0a83992 in memmove () from /lib64/libc.so.6
#2 0x0000000001018dee in void std::vector<unsigned int, std::allocator<unsigned int> >::_M_emplace_back_aux<unsigned int>(unsigned int&&) ()
#3 0x00000000018c8b15 in emplace_back<unsigned int> (this=0x7f9a858304b0) at /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/vector.tcc:101
#4 push_back (this=0x7f9a858304b0) at /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/stl_vector.h:932
#5 kudu::cfile::BinaryPlainBlockDecoder::ParseHeader (this=0x7f9a858304b0) at ../../src/kudu/cfile/binary_plain_block.cc:225
#6 0x00000000018d4ffa in kudu::cfile::CFileIterator::PrepareForNewSeek (this=0x7f9a858e4d00) at ../../src/kudu/cfile/cfile_reader.cc:724
This implied that the emplace_back calls in the block decoder were actually
causing reallocation. The issue is that the reserve() was not appropriately
large.
Change-Id: Id3688e2c9e71bd05b5386e939c9582b707e57ff3
Reviewed-on: http://gerrit.cloudera.org:8080/5734
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/7d16929c
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/7d16929c
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/7d16929c
Branch: refs/heads/master
Commit: 7d16929c4fdc0504c33c60805c044ecc451e8323
Parents: 6e683a0
Author: Todd Lipcon <to...@apache.org>
Authored: Wed Jan 18 13:26:40 2017 -0800
Committer: Adar Dembo <ad...@cloudera.com>
Committed: Thu Jan 19 00:11:10 2017 +0000
----------------------------------------------------------------------
src/kudu/cfile/binary_plain_block.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/7d16929c/src/kudu/cfile/binary_plain_block.cc
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/binary_plain_block.cc b/src/kudu/cfile/binary_plain_block.cc
index 6889382..ecc565f 100644
--- a/src/kudu/cfile/binary_plain_block.cc
+++ b/src/kudu/cfile/binary_plain_block.cc
@@ -184,7 +184,9 @@ Status BinaryPlainBlockDecoder::ParseHeader() {
const uint8_t *limit = data_.data() + data_.size();
offsets_.clear();
- offsets_.reserve(num_elems_);
+ // Reserve one extra element, which we'll fill in at the end
+ // with an offset past the last element.
+ offsets_.reserve(num_elems_ + 1);
size_t rem = num_elems_;
while (rem >= 4) {