chore: Fix memcached flags not updated (#2787)

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
Vladislav 2024-03-29 12:10:58 +03:00 committed by GitHub
parent 05084354c7
commit c8724adddf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 15 deletions

View file

@ -830,14 +830,10 @@ bool DbSlice::UpdateExpire(DbIndex db_ind, PrimeIterator it, uint64_t at) {
void DbSlice::SetMCFlag(DbIndex db_ind, PrimeKey key, uint32_t flag) {
auto& db = *db_arr_[db_ind];
if (flag == 0) {
if (db.mcflag.Erase(key) == 0) {
LOG(ERROR) << "Internal error, inconsistent state, mcflag should be present but not found "
<< key.ToString();
}
db.mcflag.Erase(key);
} else {
auto [it, inserted] = db.mcflag.Insert(std::move(key), flag);
if (!inserted)
it->second = flag;
auto [it, _] = db.mcflag.Insert(std::move(key), flag);
it->second = flag;
}
}