aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@verizonmedia.com>2020-11-12 13:27:56 +0000
committerTor Brede Vekterli <vekterli@verizonmedia.com>2020-11-12 13:54:16 +0000
commit28f5f6d0a22ceef90246a159d77cc8acc1005b19 (patch)
treeb6071fff041bd9468ef61aff93c3aa3c6597d5f7
parent152d8f57d0d62506c83894907ca3c2e1fc56dfd6 (diff)
Enforce minimum bucked used bits at document metastore load time
-rw-r--r--persistence/src/vespa/persistence/spi/bucket_limits.h (renamed from storage/src/vespa/storage/common/bucket_limits.h)2
-rw-r--r--searchcore/src/tests/proton/documentmetastore/.gitignore1
-rw-r--r--searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp26
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp3
-rw-r--r--storage/src/vespa/storage/config/distributorconfiguration.cpp4
5 files changed, 32 insertions, 4 deletions
diff --git a/storage/src/vespa/storage/common/bucket_limits.h b/persistence/src/vespa/persistence/spi/bucket_limits.h
index f822c46c6e0..65b2660eb23 100644
--- a/storage/src/vespa/storage/common/bucket_limits.h
+++ b/persistence/src/vespa/persistence/spi/bucket_limits.h
@@ -2,7 +2,7 @@
#include <cstdint>
-namespace storage {
+namespace storage::spi {
/**
* Wrapper of constants that specify absolute lower and upper bounds for buckets
diff --git a/searchcore/src/tests/proton/documentmetastore/.gitignore b/searchcore/src/tests/proton/documentmetastore/.gitignore
index 619f7adbc6c..d1d05764ae6 100644
--- a/searchcore/src/tests/proton/documentmetastore/.gitignore
+++ b/searchcore/src/tests/proton/documentmetastore/.gitignore
@@ -3,4 +3,5 @@ Makefile
gidmapattribute_test
/documentmetastore2.dat
/documentmetastore3.dat
+/documentmetastore4.dat
searchcore_documentmetastore_test_app
diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
index b586b74ad00..326cfba97f4 100644
--- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
+++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/document/base/documentid.h>
+#include <vespa/persistence/spi/bucket_limits.h>
#include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h>
#include <vespa/searchcore/proton/bucketdb/checksumaggregators.h>
#include <vespa/searchcore/proton/bucketdb/i_bucket_create_listener.h>
@@ -629,6 +630,31 @@ TEST(DocumentMetaStoreTest, gids_can_be_saved_and_loaded)
}
}
+TEST(DocumentMetaStoreTest, bucket_used_bits_are_lbounded_at_load_time)
+{
+ DocumentMetaStore dms1(createBucketDB());
+ dms1.constructFreeList();
+
+ constexpr uint32_t lid = 1;
+ GlobalId gid = createGid(lid);
+ BucketId bucketId(gid.convertToBucketId());
+ bucketId.setUsedBits(storage::spi::BucketLimits::MinUsedBits - 1);
+ uint32_t added_lid = addGid(dms1, gid, bucketId, Timestamp(1000));
+ ASSERT_EQ(added_lid, lid);
+
+ TuneFileAttributes tuneFileAttributes;
+ DummyFileHeaderContext fileHeaderContext;
+ AttributeFileSaveTarget saveTarget(tuneFileAttributes, fileHeaderContext);
+ ASSERT_TRUE(dms1.save(saveTarget, "documentmetastore2"));
+
+ DocumentMetaStore dms2(createBucketDB(), "documentmetastore2");
+ ASSERT_TRUE(dms2.load());
+ ASSERT_EQ(dms2.getNumDocs(), 2); // Incl. zero LID
+
+ BucketId expected_bucket(storage::spi::BucketLimits::MinUsedBits, gid.convertToBucketId().getRawId());
+ assertGid(gid, lid, dms2, expected_bucket, Timestamp(1000));
+}
+
TEST(DocumentMetaStore, stats_are_updated)
{
DocumentMetaStore dms(createBucketDB());
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
index b3dfebfa9c0..2b36067a65c 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp
@@ -5,6 +5,7 @@
#include "operation_listener.h"
#include "search_context.h"
#include <vespa/fastos/file.h>
+#include <vespa/persistence/spi/bucket_limits.h>
#include <vespa/searchcore/proton/bucketdb/bucketsessionbase.h>
#include <vespa/searchcore/proton/bucketdb/joinbucketssession.h>
#include <vespa/searchcore/proton/bucketdb/splitbucketsession.h>
@@ -102,7 +103,7 @@ public:
uint8_t
getNextBucketUsedBits() {
- return _bucketUsedBitsReader.readHostOrder();
+ return std::max(_bucketUsedBitsReader.readHostOrder(), storage::spi::BucketLimits::MinUsedBits);
}
Timestamp
diff --git a/storage/src/vespa/storage/config/distributorconfiguration.cpp b/storage/src/vespa/storage/config/distributorconfiguration.cpp
index 5a1a0ca04a0..cc04f1d554c 100644
--- a/storage/src/vespa/storage/config/distributorconfiguration.cpp
+++ b/storage/src/vespa/storage/config/distributorconfiguration.cpp
@@ -2,7 +2,7 @@
#include "distributorconfiguration.h"
#include <vespa/document/select/parser.h>
#include <vespa/document/select/traversingvisitor.h>
-#include <vespa/storage/common/bucket_limits.h>
+#include <vespa/persistence/spi/bucket_limits.h>
#include <vespa/vespalib/util/exceptions.h>
#include <sstream>
@@ -126,7 +126,7 @@ DistributorConfiguration::configure(const vespa::config::content::core::StorDist
_docCountSplitLimit = config.splitcount;
_byteCountJoinLimit = config.joinsize;
_docCountJoinLimit = config.joincount;
- _minimalBucketSplit = std::max(config.minsplitcount, static_cast<int>(BucketLimits::MinUsedBits));
+ _minimalBucketSplit = std::max(config.minsplitcount, static_cast<int>(spi::BucketLimits::MinUsedBits));
_maxNodesPerMerge = config.maximumNodesPerMerge;
_max_consecutively_inhibited_maintenance_ticks = config.maxConsecutivelyInhibitedMaintenanceTicks;