Skip to content

Commit

Permalink
fix:Binlog is written repeatedly && not delete cache (#2485)
Browse files Browse the repository at this point in the history
* fix:Binlog is written repeatedly during the data migration process && not delete cache
---------

Co-authored-by: chejinge <[email protected]>
  • Loading branch information
2 people authored and luky116 committed Mar 18, 2024
1 parent 9508e19 commit f2eb41e
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 @@ -852,14 +852,14 @@ 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) {
LOG(INFO) << "Del key Srem key " << key;
int32_t res = 0;
std::string slotKey = GetSlotKey(GetSlotID(key));
LOG(INFO) << "Del key Srem key " << 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 @@ -873,6 +873,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 @@ -882,7 +888,6 @@ int DeleteKey(const std::string& key, const char key_type, const std::shared_ptr
LOG(WARNING) << "Del key: " << key << " at slot " << GetSlotID(key) << " error";
return -1;
}
WriteDelKeyToBinlog(key, db);

return 1;
}
Expand Down

0 comments on commit f2eb41e

Please sign in to comment.