fix(tsdb/cache): del from mem with time range

This commit is contained in:
Minglei Jin 2023-12-06 17:52:15 +08:00
parent 0ffc707f1b
commit a9309cb295
1 changed files with 14 additions and 7 deletions

View File

@ -1167,26 +1167,33 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
// taosThreadMutexLock(&pTsdb->lruMutex); // taosThreadMutexLock(&pTsdb->lruMutex);
bool erase = false;
LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[i], klen); LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[i], klen);
if (h) { if (h) {
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pTsdb->lruCache, h); SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pTsdb->lruCache, h);
if (pLastCol->dirty) { if (pLastCol->dirty && (pLastCol->ts <= eKey && pLastCol->ts >= sKey)) {
pLastCol->dirty = 0; pLastCol->dirty = 0;
erase = true;
} }
taosLRUCacheRelease(pTsdb->lruCache, h, true); taosLRUCacheRelease(pTsdb->lruCache, h, erase);
}
if (erase) {
taosLRUCacheErase(pTsdb->lruCache, keys_list[i], klen);
} }
taosLRUCacheErase(pTsdb->lruCache, keys_list[i], klen);
erase = false;
h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[num_keys + i], klen); h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[num_keys + i], klen);
if (h) { if (h) {
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pTsdb->lruCache, h); SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pTsdb->lruCache, h);
if (pLastCol->dirty) { if (pLastCol->dirty && (pLastCol->ts <= eKey && pLastCol->ts >= sKey)) {
pLastCol->dirty = 0; pLastCol->dirty = 0;
erase = true;
} }
taosLRUCacheRelease(pTsdb->lruCache, h, true); taosLRUCacheRelease(pTsdb->lruCache, h, erase);
}
if (erase) {
taosLRUCacheErase(pTsdb->lruCache, keys_list[num_keys + i], klen);
} }
taosLRUCacheErase(pTsdb->lruCache, keys_list[num_keys + i], klen);
// taosThreadMutexUnlock(&pTsdb->lruMutex); // taosThreadMutexUnlock(&pTsdb->lruMutex);
} }
for (int i = 0; i < num_keys; ++i) { for (int i = 0; i < num_keys; ++i) {