fix(tsdb/cache): not put null value to rocks

This commit is contained in:
Minglei Jin 2024-08-06 18:54:11 +08:00
parent 6fd580e476
commit f0f910d256
1 changed files with 12 additions and 11 deletions

View File

@ -484,6 +484,7 @@ static void tsdbCachePutBatch(SLastCol *pLastCol, const void *key, size_t klen,
code = tsdbCacheSerialize(pLastCol, &rocks_value, &vlen); code = tsdbCacheSerialize(pLastCol, &rocks_value, &vlen);
if (code) { if (code) {
tsdbError("tsdb/cache: vgId:%d, serialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); tsdbError("tsdb/cache: vgId:%d, serialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code));
return;
} }
(void)taosThreadMutexLock(&rCache->rMutex); (void)taosThreadMutexLock(&rCache->rMutex);
@ -1143,13 +1144,13 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
code = tsdbCacheSerialize(&lastColTmp, &value, &vlen); code = tsdbCacheSerialize(&lastColTmp, &value, &vlen);
if (code) { if (code) {
tsdbError("tsdb/cache: vgId:%d, serialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); tsdbError("tsdb/cache: vgId:%d, serialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code));
} } else {
(void)taosThreadMutexLock(&pTsdb->rCache.rMutex); (void)taosThreadMutexLock(&pTsdb->rCache.rMutex);
rocksdb_writebatch_put(wb, (char *)&idxKey->key, ROCKS_KEY_LEN, value, vlen); rocksdb_writebatch_put(wb, (char *)&idxKey->key, ROCKS_KEY_LEN, value, vlen);
(void)taosThreadMutexUnlock(&pTsdb->rCache.rMutex); (void)taosThreadMutexUnlock(&pTsdb->rCache.rMutex);
}
pLastCol = &lastColTmp; pLastCol = &lastColTmp;
SLastCol *pTmpLastCol = taosMemoryCalloc(1, sizeof(SLastCol)); SLastCol *pTmpLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
@ -1510,13 +1511,13 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
code = tsdbCacheSerialize(pLastCol, &value, &vlen); code = tsdbCacheSerialize(pLastCol, &value, &vlen);
if (code) { if (code) {
tsdbError("tsdb/cache: vgId:%d, serialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); tsdbError("tsdb/cache: vgId:%d, serialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code));
} } else {
SLastKey *key = &idxKey->key; SLastKey *key = &idxKey->key;
size_t klen = ROCKS_KEY_LEN; size_t klen = ROCKS_KEY_LEN;
rocksdb_writebatch_put(wb, (char *)key, klen, value, vlen); rocksdb_writebatch_put(wb, (char *)key, klen, value, vlen);
taosMemoryFree(value); taosMemoryFree(value);
} }
}
if (wb) { if (wb) {
rocksMayWrite(pTsdb, false, true, false); rocksMayWrite(pTsdb, false, true, false);