提交 d2f99132 编写于 作者: S Shengliang Guan

get account error while read sdb file

上级 f7908813
......@@ -116,9 +116,9 @@ typedef enum {
SDB_CLUSTER = 2,
SDB_DNODE = 3,
SDB_MNODE = 4,
SDB_ACCT = 5,
SDB_USER = 5,
SDB_AUTH = 6,
SDB_USER = 7,
SDB_ACCT = 7,
SDB_DB = 8,
SDB_VGROUP = 9,
SDB_STABLE = 10,
......@@ -148,9 +148,9 @@ int32_t sdbInit();
void sdbCleanup();
void sdbSetTable(SSdbTable table);
int32_t sdbRead();
int32_t sdbOpen();
void sdbClose();
int32_t sdbWrite(SSdbRaw *pRaw);
int32_t sdbCommit();
int32_t sdbDeploy();
void sdbUnDeploy();
......
......@@ -536,7 +536,7 @@ static int32_t dnodeOpenMnode() {
SMnodeCfg cfg = {.replica = 1};
cfg.replicas[0].port = tsServerPort;
tstrncpy(cfg.replicas[0].fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
return dnodeDeployMnode(&cfg);
code = dnodeDeployMnode(&cfg);
} else {
dInfo("start to open mnode");
return dnodeStartMnode();
......
......@@ -138,7 +138,7 @@ static int32_t mnodeAllocStartSteps() {
if (steps == NULL) return -1;
taosStepAdd(steps, "mnode-timer", mnodeInitTimer, NULL);
taosStepAdd(steps, "mnode-sdb-file", sdbRead, (CleanupFp)sdbCommit);
taosStepAdd(steps, "mnode-sdb-file", sdbOpen, sdbClose);
taosStepAdd(steps, "mnode-balance", mnodeInitBalance, mnodeCleanupBalance);
taosStepAdd(steps, "mnode-profile", mnodeInitProfile, mnodeCleanupProfile);
taosStepAdd(steps, "mnode-show", mnodeInitShow, mnodeCleanUpShow);
......
......@@ -58,10 +58,6 @@ int32_t sdbInit() {
}
void sdbCleanup() {
if (tsSdb.curVer != tsSdb.lastCommitVer) {
sdbCommit();
}
if (tsSdb.currDir != NULL) {
tfree(tsSdb.currDir);
}
......
......@@ -211,7 +211,7 @@ static int32_t sdbWriteDataFile() {
return code;
}
int32_t sdbRead() {
int32_t sdbOpen() {
mDebug("start to read mnode file");
if (sdbReadDataFile() != 0) {
......@@ -221,9 +221,18 @@ int32_t sdbRead() {
return 0;
}
int32_t sdbCommit() {
mDebug("start to write mnode file");
return sdbWriteDataFile();
void sdbClose() {
if (tsSdb.curVer != tsSdb.lastCommitVer) {
mDebug("start to write mnode file");
sdbWriteDataFile();
}
for (int32_t i = 0; i < SDB_MAX; ++i) {
SHashObj *hash = tsSdb.hashObjs[i];
if (hash != NULL) {
taosHashClear(hash);
}
}
}
int32_t sdbDeploy() {
......@@ -235,10 +244,11 @@ int32_t sdbDeploy() {
return -1;
}
if (sdbCommit() != 0) {
if (sdbWriteDataFile() != 0) {
return -1;
}
sdbClose();
return 0;
}
......
......@@ -55,6 +55,7 @@ static int32_t sdbInsertRow(SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_
if (pDstRow != NULL) {
terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE;
taosWUnLockLatch(pLock);
sdbFreeRow(pRow);
return -1;
}
......@@ -64,6 +65,7 @@ static int32_t sdbInsertRow(SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_
if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
taosWUnLockLatch(pLock);
sdbFreeRow(pRow);
return -1;
}
......@@ -75,6 +77,7 @@ static int32_t sdbInsertRow(SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_
taosWLockLatch(pLock);
taosHashRemove(hash, pRow->pObj, keySize);
taosWUnLockLatch(pLock);
sdbFreeRow(pRow);
return -1;
}
}
......@@ -98,11 +101,10 @@ static int32_t sdbUpdateRow(SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_
SdbUpdateFp updateFp = tsSdb.updateFps[pRow->sdb];
if (updateFp != NULL) {
if ((*updateFp)(pRow->pObj, pDstRow->pObj) != 0) {
return -1;
}
(*updateFp)(pRow->pObj, pDstRow->pObj);
}
sdbFreeRow(pRow);
return 0;
}
......@@ -111,23 +113,25 @@ static int32_t sdbDeleteRow(SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_
taosWLockLatch(pLock);
SSdbRow **ppDstRow = taosHashGet(hash, pRow->pObj, keySize);
if (ppDstRow == NULL || *ppDstRow) {
if (ppDstRow == NULL || *ppDstRow == NULL) {
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
taosWUnLockLatch(pLock);
sdbFreeRow(pRow);
return -1;
}
SSdbRow *pDstRow = *ppDstRow;
pRow->status = pRaw->status;
taosHashRemove(hash, pRow->pObj, keySize);
pDstRow->status = pRaw->status;
taosHashRemove(hash, pDstRow->pObj, keySize);
taosWUnLockLatch(pLock);
SdbDeleteFp deleteFp = tsSdb.deleteFps[pRow->sdb];
SdbDeleteFp deleteFp = tsSdb.deleteFps[pDstRow->sdb];
if (deleteFp != NULL) {
(void)(*deleteFp)(pRow->pObj);
(void)(*deleteFp)(pDstRow->pObj);
}
sdbRelease(pRow->pObj);
sdbRelease(pDstRow->pObj);
sdbFreeRow(pRow);
return 0;
}
......@@ -163,11 +167,7 @@ int32_t sdbWriteImp(SSdbRaw *pRaw) {
break;
}
if (code != 0) {
sdbFreeRow(pRow);
}
return 0;
return code;
}
int32_t sdbWrite(SSdbRaw *pRaw) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册