summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-06-03 09:55:45 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-06-03 09:55:45 +0000
commit4babc05819a7bdf06a1082e238ad0751fbeacf0e (patch)
tree30b35b213a51d43a45c68f0e79baecef6d35190d /searchlib
parentb38a099eb79efa9cf1fa4c9fce68a4d7e3d423b5 (diff)
Protect against inconsistency when sampling size and capacity.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp b/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp
index cf159bccaca..46ed6f3cdf4 100644
--- a/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp
+++ b/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp
@@ -29,6 +29,12 @@ std::pair<BitVector::Index, BitVector::Index>
extract_size_capacity(const AllocatedBitVector & bv) {
BitVector::Index size = bv.size();
BitVector::Index capacity = bv.capacity();
+ while (capacity < size) {
+ // Since size and capacity might be changed in another thread we need
+ // this fallback to avoid inconsistency during shrink.
+ size = bv.size();
+ capacity = bv.capacity();
+ }
return std::pair<BitVector::Index, BitVector::Index>(size, capacity);
}