[TD-52] modify updatefp in sdb
This commit is contained in:
parent
13b44b30d5
commit
a3d4443a8b
|
@ -83,6 +83,12 @@ static int32_t mgmtDbActionDelete(SSdbOperDesc *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mgmtDbActionUpdate(SSdbOperDesc *pOper) {
|
static int32_t mgmtDbActionUpdate(SSdbOperDesc *pOper) {
|
||||||
|
SDbObj *pDb = pOper->pObj;
|
||||||
|
SDbObj *pSaved = mgmtGetDb(pDb->name);
|
||||||
|
if (pDb != pSaved) {
|
||||||
|
memcpy(pSaved, pDb, pOper->rowSize);
|
||||||
|
free(pDb);
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -335,25 +335,19 @@ static int32_t sdbProcessWriteFromWal(SSdbTable *pTable, SWalHead *pHead, int32_
|
||||||
SRowMeta *rowMeta = sdbGetRowMeta(pTable, pHead->cont);
|
SRowMeta *rowMeta = sdbGetRowMeta(pTable, pHead->cont);
|
||||||
assert(rowMeta != NULL && rowMeta->row != NULL);
|
assert(rowMeta != NULL && rowMeta->row != NULL);
|
||||||
|
|
||||||
SSdbOperDesc oper1 = {
|
SSdbOperDesc oper = {
|
||||||
.table = pTable,
|
|
||||||
.pObj = rowMeta->row,
|
|
||||||
};
|
|
||||||
sdbDeleteLocal(pTable, &oper1);
|
|
||||||
|
|
||||||
SSdbOperDesc oper2 = {
|
|
||||||
.rowSize = pHead->len,
|
.rowSize = pHead->len,
|
||||||
.rowData = pHead->cont,
|
.rowData = pHead->cont,
|
||||||
.table = pTable,
|
.table = pTable,
|
||||||
};
|
};
|
||||||
code = (*pTable->decodeFp)(&oper2);
|
code = (*pTable->decodeFp)(&oper);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
sdbTrace("table:%s, failed to decode %s record:%s from file, version:%" PRId64, pTable->tableName,
|
sdbTrace("table:%s, failed to decode %s record:%s from file, version:%" PRId64, pTable->tableName,
|
||||||
sdbGetActionStr(action), sdbGetkeyStr(pTable, pHead->cont), pHead->version);
|
sdbGetActionStr(action), sdbGetkeyStr(pTable, pHead->cont), pHead->version);
|
||||||
pthread_mutex_unlock(&tsSdbObj->mutex);
|
pthread_mutex_unlock(&tsSdbObj->mutex);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
code = sdbInsertLocal(pTable, &oper2);
|
code = sdbUpdateLocal(pTable, &oper);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&tsSdbObj->mutex);
|
pthread_mutex_unlock(&tsSdbObj->mutex);
|
||||||
|
|
|
@ -165,6 +165,19 @@ static int32_t mgmtChildTableActionDelete(SSdbOperDesc *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mgmtChildTableActionUpdate(SSdbOperDesc *pOper) {
|
static int32_t mgmtChildTableActionUpdate(SSdbOperDesc *pOper) {
|
||||||
|
SChildTableObj *pNew = pOper->pObj;
|
||||||
|
SChildTableObj *pTable = mgmtGetChildTable(pNew->info.tableId);
|
||||||
|
if (pTable != pNew) {
|
||||||
|
void *oldSql = pTable->sql;
|
||||||
|
void *oldSchema = pTable->schema;
|
||||||
|
memcpy(pTable, pNew, pOper->rowSize);
|
||||||
|
pTable->sql = pNew->sql;
|
||||||
|
pTable->schema = pNew->schema;
|
||||||
|
free(pNew);
|
||||||
|
free(oldSql);
|
||||||
|
free(oldSchema);
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,6 +384,16 @@ static int32_t mgmtSuperTableActionDelete(SSdbOperDesc *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mgmtSuperTableActionUpdate(SSdbOperDesc *pOper) {
|
static int32_t mgmtSuperTableActionUpdate(SSdbOperDesc *pOper) {
|
||||||
|
SChildTableObj *pNew = pOper->pObj;
|
||||||
|
SChildTableObj *pTable = mgmtGetChildTable(pNew->info.tableId);
|
||||||
|
if (pTable != pNew) {
|
||||||
|
void *oldSchema = pTable->schema;
|
||||||
|
memcpy(pTable, pNew, pOper->rowSize);
|
||||||
|
pTable->schema = pNew->schema;
|
||||||
|
free(pNew);
|
||||||
|
free(oldSchema);
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,12 @@ static int32_t mgmtUserActionDelete(SSdbOperDesc *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mgmtUserActionUpdate(SSdbOperDesc *pOper) {
|
static int32_t mgmtUserActionUpdate(SSdbOperDesc *pOper) {
|
||||||
|
SUserObj *pUser = pOper->pObj;
|
||||||
|
SUserObj *pSaved = mgmtGetUser(pUser->user);
|
||||||
|
if (pUser != pSaved) {
|
||||||
|
memcpy(pSaved, pUser, pOper->rowSize);
|
||||||
|
free(pUser);
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,14 +53,6 @@ static int32_t mgmtVgroupActionDestroy(SSdbOperDesc *pOper) {
|
||||||
tfree(pVgroup->tableList);
|
tfree(pVgroup->tableList);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
|
||||||
SDnodeObj *pDnode = clusterGetDnode(pVgroup->vnodeGid[i].dnodeId);
|
|
||||||
if (pDnode) {
|
|
||||||
atomic_sub_fetch_32(&pDnode->openVnodes, 1);
|
|
||||||
}
|
|
||||||
clusterReleaseDnode(pDnode);
|
|
||||||
}
|
|
||||||
|
|
||||||
tfree(pOper->pObj);
|
tfree(pOper->pObj);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -115,13 +107,27 @@ static int32_t mgmtVgroupActionDelete(SSdbOperDesc *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mgmtReleaseDb(pVgroup->pDb);
|
mgmtReleaseDb(pVgroup->pDb);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
||||||
|
SDnodeObj *pDnode = clusterGetDnode(pVgroup->vnodeGid[i].dnodeId);
|
||||||
|
if (pDnode) {
|
||||||
|
atomic_sub_fetch_32(&pDnode->openVnodes, 1);
|
||||||
|
}
|
||||||
|
clusterReleaseDnode(pDnode);
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mgmtVgroupActionUpdate(SSdbOperDesc *pOper) {
|
static int32_t mgmtVgroupActionUpdate(SSdbOperDesc *pOper) {
|
||||||
SVgObj *pVgroup = pOper->pObj;
|
SVgObj *pNew = pOper->pObj;
|
||||||
int32_t oldTables = taosIdPoolMaxSize(pVgroup->idPool);
|
SVgObj *pVgroup = mgmtGetVgroup(pNew->vgId);
|
||||||
|
if (pVgroup != pNew) {
|
||||||
|
memcpy(pVgroup, pNew, pOper->rowSize);
|
||||||
|
free(pNew);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t oldTables = taosIdPoolMaxSize(pVgroup->idPool);
|
||||||
SDbObj *pDb = pVgroup->pDb;
|
SDbObj *pDb = pVgroup->pDb;
|
||||||
if (pDb != NULL) {
|
if (pDb != NULL) {
|
||||||
if (pDb->cfg.maxSessions != oldTables) {
|
if (pDb->cfg.maxSessions != oldTables) {
|
||||||
|
|
Loading…
Reference in New Issue