Skip to content

Commit 78e3514

Browse files
committed
MB-49040: 5/n Update scope data-size during warmup
As we load the collection data size from disk call through to also update the scope data size. Change-Id: Ibc2892ec2a1450befb7cada37573b457b0aaeff4 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/164367 Tested-by: Build Bot <[email protected]> Reviewed-by: Paolo Cocchi <[email protected]>
1 parent c2e34fc commit 78e3514

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

engines/ep/src/warmup.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,9 @@ void Warmup::loadCollectionStatsForShard(uint16_t shardId) {
14771477
// Set the in memory high seqno - might be 0 in the case of the
14781478
// default collection so we have to reset the monotonic value
14791479
collection.second.resetHighSeqno(stats.highSeqno);
1480+
1481+
// And update the scope data size
1482+
wh.updateDataSize(collection.second.getScopeID(), stats.diskSize);
14801483
}
14811484
}
14821485

engines/ep/tests/module_tests/collections/evp_store_collections_test.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,7 @@ TEST_F(CollectionsWarmupTest, warmup) {
10271027
CollectionsManifest cm;
10281028
uint32_t uid = 0xface2;
10291029
cm.setUid(uid);
1030+
size_t scopeDataSize = 0;
10301031
{
10311032
auto vb = store->getVBucket(vbid);
10321033

@@ -1067,6 +1068,8 @@ TEST_F(CollectionsWarmupTest, warmup) {
10671068
EXPECT_EQ(3,
10681069
store->getVBucket(vbid)->lockCollections().getHighSeqno(
10691070
CollectionEntry::fruit));
1071+
scopeDataSize = store->getVBucket(vbid)->lockCollections().getDataSize(
1072+
ScopeID::Default);
10701073
} // VBucketPtr scope ends
10711074

10721075
resetEngineAndWarmup();
@@ -1086,6 +1089,10 @@ TEST_F(CollectionsWarmupTest, warmup) {
10861089
store->getVBucket(vbid)->lockCollections().getHighSeqno(
10871090
CollectionEntry::meat));
10881091

1092+
EXPECT_EQ(scopeDataSize,
1093+
store->getVBucket(vbid)->lockCollections().getDataSize(
1094+
ScopeID::Default));
1095+
10891096
{
10901097
Item item(StoredDocKey{"meat:beef", CollectionEntry::meat},
10911098
/*flags*/ 0,

engines/ep/tests/module_tests/collections/scope_data_limit_tests.cc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "ep_engine.h"
1919
#include "kv_bucket.h"
2020
#include "tests/mock/mock_dcp_consumer.h"
21+
#include "tests/module_tests/collections/collections_test.h"
22+
#include "tests/module_tests/test_helpers.h"
2123

2224
#include <utilities/test_manifest.h>
2325

@@ -218,4 +220,37 @@ TEST_P(CollectionsDcpParameterizedTest, active_updates_limit) {
218220
.lock()
219221
.getDataLimit(ScopeEntry::shop1)
220222
.value());
223+
}
224+
225+
TEST_F(CollectionsTest, ScopeWithManyCollectionsWarmup) {
226+
auto vb = store->getVBucket(vbid);
227+
228+
CollectionsManifest cm;
229+
cm.add(ScopeEntry::shop1);
230+
cm.add(CollectionEntry::fruit, ScopeEntry::shop1);
231+
cm.add(CollectionEntry::vegetable, ScopeEntry::shop1);
232+
cm.add(CollectionEntry::dairy, ScopeEntry::shop1);
233+
setCollections(cookie, cm);
234+
235+
store_items(
236+
2, vbid, makeStoredDocKey("f", CollectionEntry::fruit), "value");
237+
store_items(2,
238+
vbid,
239+
makeStoredDocKey("v", CollectionEntry::vegetable),
240+
"value");
241+
store_items(
242+
2, vbid, makeStoredDocKey("d", CollectionEntry::dairy), "value");
243+
244+
EXPECT_EQ(0, vb->getManifest().lock().getDataSize(ScopeEntry::shop1));
245+
246+
flushVBucketToDiskIfPersistent(vbid, 4 + 6);
247+
auto ds = vb->getManifest().lock().getDataSize(ScopeEntry::shop1);
248+
EXPECT_NE(0, ds);
249+
vb.reset();
250+
resetEngineAndWarmup();
251+
252+
// Data size comes back the same value
253+
EXPECT_EQ(ds,
254+
store->getVBucket(vbid)->getManifest().lock().getDataSize(
255+
ScopeEntry::shop1));
221256
}

0 commit comments

Comments
 (0)