Spin block service cache out of ShardDB

This started being a problem since the block service update log
entry does not fit in a UDP packet (it's like 100KB). I think this
approach makes more sense anyway. See comment for `getCache()` for
gotchas.
This commit is contained in:
Francesco Mazzoli
2024-03-13 10:15:40 +00:00
parent 52cc5c01df
commit 005121bcac
14 changed files with 444 additions and 433 deletions

View File

@@ -383,6 +383,7 @@ struct TempShardDB {
std::unique_ptr<Env> env;
ShardId shid;
std::unique_ptr<SharedRocksDB> sharedDB;
std::unique_ptr<BlockServicesCacheDB> blockServicesCacheDB;
std::unique_ptr<ShardDB> db;
TempShardDB(LogLevel level, ShardId shid_): logger(level, STDERR_FILENO, false, false), shid(shid_) {
@@ -393,7 +394,8 @@ struct TempShardDB {
std::shared_ptr<XmonAgent> xmon;
sharedDB = std::make_unique<SharedRocksDB>(logger, xmon);
initSharedDB();
db = std::make_unique<ShardDB>(logger, xmon, shid, DEFAULT_DEADLINE_INTERVAL, *sharedDB);
blockServicesCacheDB = std::make_unique<BlockServicesCacheDB>(logger, xmon, *sharedDB);
db = std::make_unique<ShardDB>(logger, xmon, shid, DEFAULT_DEADLINE_INTERVAL, *sharedDB, *blockServicesCacheDB);
}
// useful to test recovery
@@ -402,7 +404,8 @@ struct TempShardDB {
db->close();
sharedDB = std::make_unique<SharedRocksDB>(logger, xmon);
initSharedDB();
db = std::make_unique<ShardDB>(logger, xmon, shid, DEFAULT_DEADLINE_INTERVAL, *sharedDB);
blockServicesCacheDB = std::make_unique<BlockServicesCacheDB>(logger, xmon, *sharedDB);
db = std::make_unique<ShardDB>(logger, xmon, shid, DEFAULT_DEADLINE_INTERVAL, *sharedDB, *blockServicesCacheDB);
}
~TempShardDB() {
@@ -417,6 +420,7 @@ struct TempShardDB {
}
void initSharedDB() {
sharedDB->registerCFDescriptors(BlockServicesCacheDB::getColumnFamilyDescriptors());
sharedDB->registerCFDescriptors(ShardDB::getColumnFamilyDescriptors());
rocksdb::Options rocksDBOptions;
rocksDBOptions.create_if_missing = true;