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

get account error while read sdb file

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