Skip to content

Commit

Permalink
fix: fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Oleshko <[email protected]>
  • Loading branch information
dranikpg committed May 2, 2024
1 parent 54f16e8 commit 6e74862
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/server/string_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ OpStatus SetCmd::SetExisting(const SetParams& params, DbSlice::Iterator it,

// If value is external, mark it as deleted
if (prime_value.IsExternal()) {
shard->tiered_storage_v2()->Delete(op_args_.db_cntx.db_index, key, &prime_value);
shard->tiered_storage_v2()->Delete(&prime_value);
}

// overwrite existing entry.
Expand Down
18 changes: 10 additions & 8 deletions src/server/tiered_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ using namespace util;

using namespace tiering::literals;

using KeyRef = tiering::OpManager::KeyRef;

class TieredStorageV2::ShardOpManager : public tiering::OpManager {
friend class TieredStorageV2;

Expand Down Expand Up @@ -155,7 +157,7 @@ util::fb2::Future<string> TieredStorageV2::Read(DbIndex dbid, string_view key,
future.Resolve(*value);
return false;
};
op_manager_->Enqueue(std::make_pair(dbid, key), value.GetExternalSlice(), std::move(cb));
op_manager_->Enqueue(KeyRef(dbid, key), value.GetExternalSlice(), std::move(cb));
return future;
}

Expand All @@ -169,7 +171,7 @@ util::fb2::Future<T> TieredStorageV2::Modify(DbIndex dbid, std::string_view key,
future.Resolve(modf(value));
return true;
};
op_manager_->Enqueue(std::make_pair(dbid, key), value.GetExternalSlice(), std::move(cb));
op_manager_->Enqueue(KeyRef(dbid, key), value.GetExternalSlice(), std::move(cb));
return future;
}

Expand All @@ -186,8 +188,8 @@ void TieredStorageV2::Stash(DbIndex dbid, string_view key, PrimeValue* value) {

tiering::OpManager::EntryId id;
error_code ec;
if (value->Size() >= kMinOccupancySize) {
id = std::make_pair(dbid, key);
if (value->Size() >= kMinOccupancySize) { // large enough for own page
id = KeyRef(dbid, key);
ec = op_manager_->Stash(id, value_sv);
} else if (auto bin = bins_->Stash(dbid, key, value_sv); bin) {
id = bin->first;
Expand All @@ -199,10 +201,10 @@ void TieredStorageV2::Stash(DbIndex dbid, string_view key, PrimeValue* value) {
visit([this](auto id) { op_manager_->ClearIoPending(id); }, id);
}
}
void TieredStorageV2::Delete(DbIndex dbid, string_view key, PrimeValue* value) {
void TieredStorageV2::Delete(PrimeValue* value) {
DCHECK(value->IsExternal());
tiering::DiskSegment segment = value->GetExternalSlice();
if (segment.length >= kMinOccupancySize) {
if (segment.length >= kMinOccupancySize) { // large enough for own page
op_manager_->Delete(segment);
} else if (auto bin = bins_->Delete(segment); bin) {
op_manager_->Delete(*bin);
Expand All @@ -212,8 +214,8 @@ void TieredStorageV2::Delete(DbIndex dbid, string_view key, PrimeValue* value) {

void TieredStorageV2::CancelStash(DbIndex dbid, std::string_view key, PrimeValue* value) {
DCHECK(value->HasIoPending());
if (value->Size() >= kMinOccupancySize) {
op_manager_->Delete(std::make_pair(dbid, key));
if (value->Size() >= kMinOccupancySize) { // large enough for own page
op_manager_->Delete(KeyRef(dbid, key));
} else if (auto bin = bins_->Delete(dbid, key); bin) {
op_manager_->Delete(*bin);
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/tiered_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TieredStorageV2 {
void Stash(DbIndex dbid, std::string_view key, PrimeValue* value);

// Delete value, must be offloaded (external type)
void Delete(DbIndex dbid, std::string_view key, PrimeValue* value);
void Delete(PrimeValue* value);

// Cancel pending stash for value, must have IO_PENDING flag set
void CancelStash(DbIndex dbid, std::string_view key, PrimeValue* value);
Expand Down

0 comments on commit 6e74862

Please sign in to comment.