提交 643a9dfa 编写于 作者: dengyihao's avatar dengyihao

fix crash when taosd quit

上级 0eb94d97
...@@ -109,7 +109,10 @@ void* streamBackendInit(const char* path) { ...@@ -109,7 +109,10 @@ void* streamBackendInit(const char* path) {
if (err != NULL) { if (err != NULL) {
qError("failed to open rocksdb, path:%s, reason:%s", path, err); qError("failed to open rocksdb, path:%s, reason:%s", path, err);
taosMemoryFreeClear(err); taosMemoryFreeClear(err);
rocksdb_list_column_families_destroy(cfs, nCf);
goto _EXIT;
} }
} else { } else {
/* /*
list all cf and get prefix list all cf and get prefix
...@@ -151,6 +154,11 @@ _EXIT: ...@@ -151,6 +154,11 @@ _EXIT:
} }
void streamBackendCleanup(void* arg) { void streamBackendCleanup(void* arg) {
SBackendHandle* pHandle = (SBackendHandle*)arg; SBackendHandle* pHandle = (SBackendHandle*)arg;
if (pHandle == NULL || pHandle->db == NULL) {
taosMemoryFree(pHandle);
return;
}
RocksdbCfInst** pIter = (RocksdbCfInst**)taosHashIterate(pHandle->cfInst, NULL); RocksdbCfInst** pIter = (RocksdbCfInst**)taosHashIterate(pHandle->cfInst, NULL);
while (pIter != NULL) { while (pIter != NULL) {
RocksdbCfInst* inst = *pIter; RocksdbCfInst* inst = *pIter;
...@@ -158,7 +166,6 @@ void streamBackendCleanup(void* arg) { ...@@ -158,7 +166,6 @@ void streamBackendCleanup(void* arg) {
taosHashIterate(pHandle->cfInst, pIter); taosHashIterate(pHandle->cfInst, pIter);
} }
taosHashCleanup(pHandle->cfInst); taosHashCleanup(pHandle->cfInst);
rocksdb_flushoptions_t* flushOpt = rocksdb_flushoptions_create(); rocksdb_flushoptions_t* flushOpt = rocksdb_flushoptions_create();
char* err = NULL; char* err = NULL;
rocksdb_flush(pHandle->db, flushOpt, &err); rocksdb_flush(pHandle->db, flushOpt, &err);
...@@ -167,8 +174,8 @@ void streamBackendCleanup(void* arg) { ...@@ -167,8 +174,8 @@ void streamBackendCleanup(void* arg) {
taosMemoryFree(err); taosMemoryFree(err);
} }
rocksdb_flushoptions_destroy(flushOpt); rocksdb_flushoptions_destroy(flushOpt);
rocksdb_close(pHandle->db); rocksdb_close(pHandle->db);
rocksdb_options_destroy(pHandle->dbOpt); rocksdb_options_destroy(pHandle->dbOpt);
rocksdb_env_destroy(pHandle->env); rocksdb_env_destroy(pHandle->env);
rocksdb_cache_destroy(pHandle->cache); rocksdb_cache_destroy(pHandle->cache);
...@@ -180,7 +187,6 @@ void streamBackendCleanup(void* arg) { ...@@ -180,7 +187,6 @@ void streamBackendCleanup(void* arg) {
taosMemoryFree(head); taosMemoryFree(head);
head = tdListPopHead(pHandle->list); head = tdListPopHead(pHandle->list);
} }
// rocksdb_compactionfilterfactory_destroy(pHandle->filterFactory);
tdListFree(pHandle->list); tdListFree(pHandle->list);
taosThreadMutexDestroy(&pHandle->cfMutex); taosThreadMutexDestroy(&pHandle->cfMutex);
......
...@@ -90,6 +90,10 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF ...@@ -90,6 +90,10 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
} }
pMeta->streamBackend = streamBackendInit(streamPath); pMeta->streamBackend = streamBackendInit(streamPath);
if (pMeta->streamBackend == NULL) {
terrno = -1;
goto _err;
}
pMeta->streamBackendRid = taosAddRef(streamBackendId, pMeta->streamBackend); pMeta->streamBackendRid = taosAddRef(streamBackendId, pMeta->streamBackend);
taosMemoryFree(streamPath); taosMemoryFree(streamPath);
...@@ -105,7 +109,6 @@ _err: ...@@ -105,7 +109,6 @@ _err:
if (pMeta->pTaskDb) tdbTbClose(pMeta->pTaskDb); if (pMeta->pTaskDb) tdbTbClose(pMeta->pTaskDb);
if (pMeta->pCheckpointDb) tdbTbClose(pMeta->pCheckpointDb); if (pMeta->pCheckpointDb) tdbTbClose(pMeta->pCheckpointDb);
if (pMeta->db) tdbClose(pMeta->db); if (pMeta->db) tdbClose(pMeta->db);
// if (pMeta->streamBackend) streamBackendCleanup(pMeta->streamBackend);
taosMemoryFree(pMeta); taosMemoryFree(pMeta);
qError("failed to open stream meta"); qError("failed to open stream meta");
return NULL; return NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册