diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 3c5724dde3..da5873039b 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -189,13 +189,16 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, SFsmCbMeta *pMeta) { goto _OUT; } + (void)taosThreadMutexLock(&pMnode->pSdb->filelock); code = sdbWriteWithoutFree(pMnode->pSdb, pRaw); if (code != 0) { mError("trans:%d, failed to write to sdb since %s", transId, terrstr()); // code = 0; + (void)taosThreadMutexUnlock(&pMnode->pSdb->filelock); pMeta->code = code; goto _OUT; } + (void)taosThreadMutexUnlock(&pMnode->pSdb->filelock); pTrans = mndAcquireTrans(pMnode, transId); if (pTrans == NULL) { diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index c488416287..03b45c25b4 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -148,13 +148,11 @@ static int32_t sdbGetkeySize(SSdb *pSdb, ESdbType type, const void *pKey) { static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) { int32_t type = pRow->type; - (void)taosThreadMutexLock(&pSdb->filelock); sdbWriteLock(pSdb, type); SSdbRow *pOldRow = taosHashGet(hash, pRow->pObj, keySize); if (pOldRow != NULL) { sdbUnLock(pSdb, type); - (void)taosThreadMutexUnlock(&pSdb->filelock); sdbFreeRow(pSdb, pRow, false); terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE; return terrno; @@ -166,7 +164,6 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) { sdbUnLock(pSdb, type); - (void)taosThreadMutexUnlock(&pSdb->filelock); sdbFreeRow(pSdb, pRow, false); terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; @@ -183,13 +180,11 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * sdbFreeRow(pSdb, pRow, false); terrno = code; sdbUnLock(pSdb, type); - (void)taosThreadMutexUnlock(&pSdb->filelock); return terrno; } } sdbUnLock(pSdb, type); - (void)taosThreadMutexUnlock(&pSdb->filelock); if (pSdb->keyTypes[pRow->type] == SDB_KEY_INT32) { pSdb->maxId[pRow->type] = TMAX(pSdb->maxId[pRow->type], *((int32_t *)pRow->pObj));