Skip to content

Commit

Permalink
fix:Binlog is written repeatedly && not delete cache (OpenAtomFoundat…
Browse files Browse the repository at this point in the history
…ion#2485)

* fix:Binlog is written repeatedly during the data migration process && not delete cache
---------

Co-authored-by: chejinge <[email protected]>
  • Loading branch information
chejinge and brother-jin authored Mar 13, 2024
1 parent dded88b commit ba6548d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pika_slot_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -772,12 +772,12 @@ std::string GetSlotsTagKey(uint32_t crc) {
return SlotTagPrefix + std::to_string(crc);
}

// delete key from db
// delete key from db && cache
int DeleteKey(const std::string& key, const char key_type, const std::shared_ptr<DB>& db) {
int32_t res = 0;
std::string slotKey = GetSlotKey(GetSlotID(g_pika_conf->default_slot_num(), key));

// delete key from slot
// delete slotkey
std::vector<std::string> members;
members.emplace_back(key_type + key);
rocksdb::Status s = db->storage()->SRem(slotKey, members, &res);
Expand All @@ -791,6 +791,12 @@ int DeleteKey(const std::string& key, const char key_type, const std::shared_ptr
}
}

// delete from cache
if (PIKA_CACHE_NONE != g_pika_conf->cache_model()
&& PIKA_CACHE_STATUS_OK == db->cache()->CacheStatus()) {
db->cache()->Del(members);
}

// delete key from db
members.clear();
members.emplace_back(key);
Expand All @@ -800,7 +806,6 @@ int DeleteKey(const std::string& key, const char key_type, const std::shared_ptr
LOG(WARNING) << "Del key: " << key << " at slot " << GetSlotID(g_pika_conf->default_slot_num(), key) << " error";
return -1;
}
WriteDelKeyToBinlog(key, db);

return 1;
}
Expand Down

0 comments on commit ba6548d

Please sign in to comment.