Skip to content

Commit dc531f2

Browse files
committed
MB-47139 magma-kvstore: Adapt to SetMaxOpenFiles API change
The global magma library method SetMaxOpenFiles() should be called only after initializing atleast one magma db instance. The data structures used by the method (memory guard switch) is only initialized during the db instance construction. The API is now moved to a db instance level method to avoid the ambiguity of the API usage. Change-Id: I75b60c85fc0590fbb722a7c604c6e445e66954da Reviewed-on: https://review.couchbase.org/c/kv_engine/+/172523 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]> Well-Formed: Restriction Checker
1 parent ac0da7c commit dc531f2

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

engines/ep/src/kvstore/magma-kvstore/magma-kvstore.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,6 @@ MagmaKVStore::MagmaKVStore(MagmaKVStoreConfig& configuration)
597597
configuration.getMagmaMemoryQuotaLowWaterMarkRatio();
598598

599599
configuration.setStore(this);
600-
{
601-
cb::UseArenaMallocSecondaryDomain domainGuard;
602-
magma::SetMaxOpenFiles(configuration.getMaxFileDescriptors());
603-
}
604600

605601
// To save memory only allocate counters for the number of vBuckets that
606602
// this shard will have to deal with
@@ -665,6 +661,7 @@ MagmaKVStore::MagmaKVStore(MagmaKVStoreConfig& configuration)
665661

666662
magma = std::make_unique<MagmaMemoryTrackingProxy>(configuration.magmaCfg);
667663

664+
magma->SetMaxOpenFiles(configuration.getMaxFileDescriptors());
668665
setMaxDataSize(configuration.getBucketQuota());
669666
setMagmaFragmentationPercentage(
670667
configuration.getMagmaFragmentationPercentage());

engines/ep/src/kvstore/magma-kvstore/magma-memory-tracking-proxy.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,11 @@ void MagmaMemoryTrackingProxy::EnableBlockCache(bool enable) {
363363
magma->EnableBlockCache(enable);
364364
}
365365

366+
void MagmaMemoryTrackingProxy::SetMaxOpenFiles(size_t n, bool blocking) {
367+
cb::UseArenaMallocSecondaryDomain domainGuard;
368+
magma->SetMaxOpenFiles(n, blocking);
369+
}
370+
366371
void MagmaMemoryTrackingProxy::SetMemoryQuota(const size_t quota) {
367372
cb::UseArenaMallocSecondaryDomain domainGuard;
368373
magma->SetMemoryQuota(quota);

engines/ep/src/kvstore/magma-kvstore/magma-memory-tracking-proxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class MagmaMemoryTrackingProxy {
176176
magma::Status Rollback(const magma::Magma::KVStoreID kvID,
177177
magma::Magma::SeqNo rollbackSeqno,
178178
magma::Magma::RollbackCallback callback);
179+
void SetMaxOpenFiles(size_t n, bool blocking = false);
179180
void SetFragmentationRatio(double fragRatio);
180181
void EnableBlockCache(bool enable);
181182
void SetMemoryQuota(const size_t quota);

0 commit comments

Comments
 (0)