server(tiering): load data on read (#2415)

* server(tiering): load data on read

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2024-01-17 16:13:56 +02:00 committed by GitHub
parent 8eda8226b2
commit 9f3b118b87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 401 additions and 231 deletions

View file

@ -195,8 +195,11 @@ class DbSlice {
AutoUpdater post_updater;
};
ItAndUpdater FindMutable(const Context& cntx, std::string_view key);
ItAndUpdater FindAndFetchMutable(const Context& cntx, std::string_view key);
OpResult<ItAndUpdater> FindMutable(const Context& cntx, std::string_view key,
unsigned req_obj_type);
OpResult<ItAndUpdater> FindAndFetchMutable(const Context& cntx, std::string_view key,
unsigned req_obj_type);
struct ItAndExpConst {
PrimeConstIterator it;
@ -205,6 +208,8 @@ class DbSlice {
ItAndExpConst FindReadOnly(const Context& cntx, std::string_view key);
OpResult<PrimeConstIterator> FindReadOnly(const Context& cntx, std::string_view key,
unsigned req_obj_type);
OpResult<PrimeConstIterator> FindAndFetchReadOnly(const Context& cntx, std::string_view key,
unsigned req_obj_type);
// Returns (iterator, args-index) if found, KEY_NOTFOUND otherwise.
// If multiple keys are found, returns the first index in the ArgSlice.
@ -222,6 +227,7 @@ class DbSlice {
};
AddOrFindResult AddOrFind(const Context& cntx, std::string_view key) noexcept(false);
AddOrFindResult AddOrFindAndFetch(const Context& cntx, std::string_view key) noexcept(false);
// Same as AddOrSkip, but overwrites in case entry exists.
AddOrFindResult AddOrUpdate(const Context& cntx, std::string_view key, PrimeValue obj,
@ -256,6 +262,7 @@ class DbSlice {
void ActivateDb(DbIndex db_ind);
bool Del(DbIndex db_ind, PrimeIterator it);
void RemoveFromTiered(PrimeIterator it, DbIndex index);
constexpr static DbIndex kDbAll = 0xFFFF;
@ -390,7 +397,7 @@ class DbSlice {
void TrackKeys(const facade::Connection::WeakRef&, const ArgSlice&);
// Delete a key referred by its iterator.
void PerformDeletion(PrimeIterator del_it, EngineShard* shard, DbTable* table);
void PerformDeletion(PrimeIterator del_it, DbTable* table);
// Releases a single key. `key` must have been normalized by GetLockKey().
void ReleaseNormalized(IntentLock::Mode m, DbIndex db_index, std::string_view key,
@ -412,8 +419,7 @@ class DbSlice {
// Invalidate all watched keys for given slots. Used on FlushSlots.
void InvalidateSlotWatches(const SlotSet& slot_ids);
void PerformDeletion(PrimeIterator del_it, ExpireIterator exp_it, EngineShard* shard,
DbTable* table);
void PerformDeletion(PrimeIterator del_it, ExpireIterator exp_it, DbTable* table);
// Send invalidation message to the clients that are tracking the change to a key.
void SendInvalidationTrackingMessage(std::string_view key);
@ -421,15 +427,28 @@ class DbSlice {
void CreateDb(DbIndex index);
size_t EvictObjects(size_t memory_to_free, PrimeIterator it, DbTable* table);
enum class FindInternalMode {
kUpdateReadStats,
kUpdateMutableStats,
enum class UpdateStatsMode {
kReadStats,
kMutableStats,
};
ItAndExp FindInternal(const Context& cntx, std::string_view key, FindInternalMode mode);
enum class LoadExternalMode {
kLoad,
kDontLoad,
};
OpResult<ItAndExp> FindInternal(const Context& cntx, std::string_view key,
std::optional<unsigned> req_obj_type, UpdateStatsMode stats_mode,
LoadExternalMode load_mode);
AddOrFindResult AddOrFindInternal(const Context& cntx, std::string_view key,
LoadExternalMode load_mode) noexcept(false);
OpResult<ItAndUpdater> FindMutableInternal(const Context& cntx, std::string_view key,
std::optional<unsigned> req_obj_type,
LoadExternalMode load_mode);
uint64_t NextVersion() {
return version_++;
}
void RemoveFromTiered(PrimeIterator it, DbTable* table);
private:
ShardId shard_id_;