@@ -237,27 +237,26 @@ ManifestUpdateStatus Manifest::update(VBucket& vb,
237
237
238
238
// If manifest was equal.
239
239
if (manifest.getUid () == manifestUid) {
240
- if (changes.empty ()) {
240
+ if (changes.none ()) {
241
241
return ManifestUpdateStatus::Success;
242
- } else if (changes.onlyScopesModified ()) {
243
- EP_LOG_WARN (" Manifest::update {} equal uid and {} scopes modified" ,
244
- vb.getId (),
245
- changes.scopesToModify .size ());
246
- } else {
247
- // Log verbosely for this case
242
+ } else if (changes.wouldCreateOrDrop ()) {
243
+ // Log verbosely for this case. An equal manifest should not change
244
+ // the scope or collection membership
248
245
EP_LOG_WARN (
249
246
" Manifest::update {} with equal uid:{:#x} but differences "
250
- " scopes+:{}, collections+:{}, scopes-:{}, collections-:{}, "
251
- " scopes-modified:{}" ,
247
+ " scopes+:{}, collections+:{}, scopes-:{}, collections-:{}" ,
252
248
vb.getId (),
253
249
manifestUid,
254
250
changes.scopesToCreate .size (),
255
251
changes.collectionsToCreate .size (),
256
252
changes.scopesToDrop .size (),
257
- changes.collectionsToDrop .size (),
258
- changes.scopesToModify .size ());
253
+ changes.collectionsToDrop .size ());
259
254
return ManifestUpdateStatus::EqualUidWithDifferences;
260
255
}
256
+ // else a scope modification or change of scopeWithDataLimitExists is
257
+ // allowed when the uid is equal
258
+ Expects (!changes.scopesToModify .empty () ||
259
+ changes.changeScopeWithDataLimitExists );
261
260
}
262
261
263
262
completeUpdate (std::move (upgradeLock), vb, changes);
@@ -292,25 +291,39 @@ void Manifest::completeUpdate(mutex_type::UpgradeHolder&& upgradeLock,
292
291
WriteHandle wHandle (*this , std::move (upgradeLock));
293
292
294
293
// Capture the UID
295
- if (changeset.empty ()) {
294
+ if (changeset.none ()) {
296
295
updateUid (changeset.uid , false /* reset*/ );
297
296
return ;
298
297
}
299
298
299
+ if (changeset.changeScopeWithDataLimitExists ) {
300
+ EP_LOG_INFO (
301
+ " Manifest::completeUpdate {} toggling scopeWithDataLimitExists "
302
+ " {} -> {}" ,
303
+ vb.getId (),
304
+ scopeWithDataLimitExists,
305
+ changeset.changeScopeWithDataLimitExists .value ());
306
+ scopeWithDataLimitExists =
307
+ changeset.changeScopeWithDataLimitExists .value ();
308
+ }
309
+
300
310
auto finalDeletion = applyDrops (wHandle, vb, changeset.collectionsToDrop );
301
311
if (finalDeletion) {
302
- auto uid = changeset.empty () ? changeset.uid : manifestUid;
303
- dropCollection (
304
- wHandle, vb, uid, *finalDeletion, OptionalSeqno{/* no-seqno*/ });
312
+ // if the changeset is now 'drained' of create/drop, then this is final
313
+ // the final change to make - so use changeset.uid
314
+ dropCollection (wHandle,
315
+ vb,
316
+ changeset.getUidForChange (manifestUid),
317
+ *finalDeletion,
318
+ OptionalSeqno{/* no-seqno*/ });
305
319
}
306
320
307
321
auto finalScopeCreate =
308
322
applyScopeCreates (wHandle, vb, changeset.scopesToCreate );
309
323
if (finalScopeCreate) {
310
- auto uid = changeset.empty () ? changeset.uid : manifestUid;
311
324
createScope (wHandle,
312
325
vb,
313
- uid ,
326
+ changeset. getUidForChange (manifestUid) ,
314
327
finalScopeCreate.value ().sid ,
315
328
finalScopeCreate.value ().name ,
316
329
finalScopeCreate.value ().dataLimit ,
@@ -321,10 +334,9 @@ void Manifest::completeUpdate(mutex_type::UpgradeHolder&& upgradeLock,
321
334
applyCreates (wHandle, vb, changeset.collectionsToCreate );
322
335
323
336
if (finalAddition) {
324
- auto uid = changeset.empty () ? changeset.uid : manifestUid;
325
337
createCollection (wHandle,
326
338
vb,
327
- uid ,
339
+ changeset. getUidForChange (manifestUid) ,
328
340
finalAddition.value ().identifiers ,
329
341
finalAddition.value ().name ,
330
342
finalAddition.value ().maxTtl ,
@@ -346,6 +358,7 @@ void Manifest::completeUpdate(mutex_type::UpgradeHolder&& upgradeLock,
346
358
// Can do the scope modifications last - these generate no events but will
347
359
// just sync any scope to the manifest
348
360
for (const auto & modified : changeset.scopesToModify ) {
361
+ // Here the changeset.uid is used as it's for logging
349
362
modifyScope (wHandle, vb, changeset.uid , modified);
350
363
}
351
364
}
@@ -696,6 +709,8 @@ Manifest::ManifestChanges Manifest::processManifest(
696
709
const Collections::Manifest& manifest) {
697
710
ManifestChanges rv{manifest.getUid ()};
698
711
712
+ bool scopeWithDataLimitExists{false };
713
+
699
714
// First iterate through the collections of this VB::Manifest
700
715
for (const auto & [cid, entry] : map) {
701
716
// Look-up the collection inside the new manifest
@@ -737,6 +752,10 @@ Manifest::ManifestChanges Manifest::processManifest(
737
752
}
738
753
}
739
754
755
+ if (scopeItr->second .dataLimit ) {
756
+ scopeWithDataLimitExists = true ;
757
+ }
758
+
740
759
for (const auto & m : scopeItr->second .collections ) {
741
760
auto mapItr = map.find (m.cid );
742
761
@@ -747,6 +766,10 @@ Manifest::ManifestChanges Manifest::processManifest(
747
766
}
748
767
}
749
768
769
+ if (this ->scopeWithDataLimitExists != scopeWithDataLimitExists) {
770
+ rv.changeScopeWithDataLimitExists = scopeWithDataLimitExists;
771
+ }
772
+
750
773
return rv;
751
774
}
752
775
@@ -1167,6 +1190,10 @@ bool Manifest::addScopeStats(Vbid vbid, const StatCollector& collector) const {
1167
1190
format_to (key, " vb_{}:manifest:uid" , vbid.get ());
1168
1191
collector.addStat (std::string_view (key.data (), key.size ()), manifestUid);
1169
1192
1193
+ format_to (key, " vb_{}:scope_data_limit" , vbid.get ());
1194
+ collector.addStat (std::string_view (key.data (), key.size ()),
1195
+ scopeWithDataLimitExists);
1196
+
1170
1197
for (const auto & [sid, value] : scopes) {
1171
1198
key.resize (0 );
1172
1199
format_to (key, " vb_{}:{}:name:" , vbid.get (), sid);
@@ -1273,6 +1300,10 @@ bool Manifest::operator!=(const Manifest& rhs) const {
1273
1300
1274
1301
cb::engine_errc Manifest::getScopeDataLimitStatus (
1275
1302
const container::const_iterator itr, size_t nBytes) const {
1303
+ if (!scopeWithDataLimitExists) {
1304
+ return cb::engine_errc::success;
1305
+ }
1306
+
1276
1307
const auto & entry = getScopeEntry (itr->second .getScopeID ());
1277
1308
1278
1309
if (entry.getDataLimit () &&
@@ -1446,6 +1477,8 @@ std::ostream& operator<<(std::ostream& os,
1446
1477
std::ostream& operator <<(std::ostream& os, const Manifest& manifest) {
1447
1478
os << " VB::Manifest: "
1448
1479
<< " uid:" << manifest.manifestUid
1480
+ << " scopeWithDataLimitExists:" << manifest.scopeWithDataLimitExists
1481
+ << " dropInProgress:" << manifest.dropInProgress .load ()
1449
1482
<< " , scopes.size:" << manifest.scopes .size ()
1450
1483
<< " , map.size:" << manifest.map .size () << std::endl;
1451
1484
for (const auto & [cid, entry] : manifest.map ) {
0 commit comments