add sma update
This commit is contained in:
parent
17f6275015
commit
eff9f9be4d
|
@ -1136,8 +1136,8 @@ int32_t tDeserializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp
|
||||||
void tFreeSTableMetaRsp(STableMetaRsp* pRsp);
|
void tFreeSTableMetaRsp(STableMetaRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SArray* pArray; // Array of STableMetaRsp
|
SArray* pMetaRsp; // Array of STableMetaRsp
|
||||||
STableIndexRsp* pIndexRsp;
|
SArray* pIndexRsp; // Array of STableIndexRsp;
|
||||||
} SSTbHbRsp;
|
} SSTbHbRsp;
|
||||||
|
|
||||||
int32_t tSerializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp);
|
int32_t tSerializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp);
|
||||||
|
@ -2514,6 +2514,8 @@ typedef struct {
|
||||||
} STableIndexInfo;
|
} STableIndexInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
char tbName[TSDB_TABLE_NAME_LEN];
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
uint64_t suid;
|
uint64_t suid;
|
||||||
int32_t version;
|
int32_t version;
|
||||||
SArray* pIndex;
|
SArray* pIndex;
|
||||||
|
|
|
@ -105,9 +105,9 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfBatchs = taosArrayGetSize(hbRsp.pArray);
|
int32_t numOfMeta = taosArrayGetSize(hbRsp.pMetaRsp);
|
||||||
for (int32_t i = 0; i < numOfBatchs; ++i) {
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
STableMetaRsp *rsp = taosArrayGet(hbRsp.pArray, i);
|
STableMetaRsp *rsp = taosArrayGet(hbRsp.pMetaRsp, i);
|
||||||
|
|
||||||
if (rsp->numOfColumns < 0) {
|
if (rsp->numOfColumns < 0) {
|
||||||
tscDebug("hb remove stb, db:%s, stb:%s", rsp->dbFName, rsp->stbName);
|
tscDebug("hb remove stb, db:%s, stb:%s", rsp->dbFName, rsp->stbName);
|
||||||
|
@ -124,6 +124,16 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t numOfIndex = taosArrayGetSize(hbRsp.pIndexRsp);
|
||||||
|
for (int32_t i = 0; i < numOfIndex; ++i) {
|
||||||
|
STableIndexRsp *rsp = taosArrayGet(hbRsp.pIndexRsp, i);
|
||||||
|
|
||||||
|
catalogUpdateTableIndex(pCatalog, rsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(hbRsp.pIndexRsp);
|
||||||
|
hbRsp.pIndexRsp = NULL;
|
||||||
|
|
||||||
tFreeSSTbHbRsp(&hbRsp);
|
tFreeSSTbHbRsp(&hbRsp);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2437,6 +2437,8 @@ int32_t tSerializeSTableIndexRsp(void *buf, int32_t bufLen, const STableIndexRsp
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pRsp->tbName) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pRsp->dbFName) < 0) return -1;
|
||||||
if (tEncodeU64(&encoder, pRsp->suid) < 0) return -1;
|
if (tEncodeU64(&encoder, pRsp->suid) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pRsp->version) < 0) return -1;
|
if (tEncodeI32(&encoder, pRsp->version) < 0) return -1;
|
||||||
int32_t num = taosArrayGetSize(pRsp->pIndex);
|
int32_t num = taosArrayGetSize(pRsp->pIndex);
|
||||||
|
@ -2473,6 +2475,8 @@ int32_t tDeserializeSTableIndexRsp(void *buf, int32_t bufLen, STableIndexRsp *pR
|
||||||
tDecoderInit(&decoder, buf, bufLen);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pRsp->tbName) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pRsp->dbFName) < 0) return -1;
|
||||||
if (tDecodeU64(&decoder, &pRsp->suid) < 0) return -1;
|
if (tDecodeU64(&decoder, &pRsp->suid) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pRsp->version) < 0) return -1;
|
if (tDecodeI32(&decoder, &pRsp->version) < 0) return -1;
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
|
@ -2640,12 +2644,30 @@ int32_t tSerializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) {
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
|
||||||
int32_t numOfBatch = taosArrayGetSize(pRsp->pArray);
|
int32_t numOfMeta = taosArrayGetSize(pRsp->pMetaRsp);
|
||||||
if (tEncodeI32(&encoder, numOfBatch) < 0) return -1;
|
if (tEncodeI32(&encoder, numOfMeta) < 0) return -1;
|
||||||
for (int32_t i = 0; i < numOfBatch; ++i) {
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
STableMetaRsp *pMetaRsp = taosArrayGet(pRsp->pArray, i);
|
STableMetaRsp *pMetaRsp = taosArrayGet(pRsp->pMetaRsp, i);
|
||||||
if (tEncodeSTableMetaRsp(&encoder, pMetaRsp) < 0) return -1;
|
if (tEncodeSTableMetaRsp(&encoder, pMetaRsp) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t numOfIndex = taosArrayGetSize(pRsp->pIndexRsp);
|
||||||
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
|
STableIndexRsp *pIndexRsp = taosArrayGet(pRsp->pIndexRsp, i);
|
||||||
|
if (tEncodeCStr(&encoder, pIndexRsp->tbName) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pIndexRsp->dbFName) < 0) return -1;
|
||||||
|
if (tEncodeU64(&encoder, pIndexRsp->suid) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pIndexRsp->version) < 0) return -1;
|
||||||
|
int32_t num = taosArrayGetSize(pIndexRsp->pIndex);
|
||||||
|
if (tEncodeI32(&encoder, num) < 0) return -1;
|
||||||
|
if (num > 0) {
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
STableIndexInfo *pInfo = (STableIndexInfo *)taosArrayGet(pIndexRsp->pIndex, i);
|
||||||
|
if (tSerializeSTableIndexInfo(&encoder, pInfo) < 0) return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -2671,20 +2693,53 @@ int32_t tDeserializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) {
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
|
||||||
int32_t numOfBatch = taosArrayGetSize(pRsp->pArray);
|
int32_t numOfMeta = taosArrayGetSize(pRsp->pMetaRsp);
|
||||||
if (tDecodeI32(&decoder, &numOfBatch) < 0) return -1;
|
if (tDecodeI32(&decoder, &numOfMeta) < 0) return -1;
|
||||||
|
|
||||||
pRsp->pArray = taosArrayInit(numOfBatch, sizeof(STableMetaRsp));
|
pRsp->pMetaRsp = taosArrayInit(numOfMeta, sizeof(STableMetaRsp));
|
||||||
if (pRsp->pArray == NULL) {
|
if (pRsp->pMetaRsp == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfBatch; ++i) {
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
STableMetaRsp tableMetaRsp = {0};
|
STableMetaRsp tableMetaRsp = {0};
|
||||||
if (tDecodeSTableMetaRsp(&decoder, &tableMetaRsp) < 0) return -1;
|
if (tDecodeSTableMetaRsp(&decoder, &tableMetaRsp) < 0) return -1;
|
||||||
taosArrayPush(pRsp->pArray, &tableMetaRsp);
|
taosArrayPush(pRsp->pMetaRsp, &tableMetaRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t numOfIndex = taosArrayGetSize(pRsp->pIndexRsp);
|
||||||
|
if (tDecodeI32(&decoder, &numOfIndex) < 0) return -1;
|
||||||
|
|
||||||
|
pRsp->pIndexRsp = taosArrayInit(numOfIndex, sizeof(STableIndexRsp));
|
||||||
|
if (pRsp->pIndexRsp == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfIndex; ++i) {
|
||||||
|
STableIndexRsp tableIndexRsp = {0};
|
||||||
|
if (tDecodeCStrTo(&decoder, tableIndexRsp.tbName) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, tableIndexRsp.dbFName) < 0) return -1;
|
||||||
|
if (tDecodeU64(&decoder, &tableIndexRsp.suid) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &tableIndexRsp.version) < 0) return -1;
|
||||||
|
int32_t num = 0;
|
||||||
|
if (tDecodeI32(&decoder, &num) < 0) return -1;
|
||||||
|
if (num > 0) {
|
||||||
|
tableIndexRsp.pIndex = taosArrayInit(num, sizeof(STableIndexInfo));
|
||||||
|
if (NULL == tableIndexRsp.pIndex) return -1;
|
||||||
|
STableIndexInfo info;
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
if (tDeserializeSTableIndexInfo(&decoder, &info) < 0) return -1;
|
||||||
|
if (NULL == taosArrayPush(tableIndexRsp.pIndex, &info)) {
|
||||||
|
taosMemoryFree(info.expr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taosArrayPush(pRsp->pIndexRsp, &tableIndexRsp);
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -2693,14 +2748,33 @@ int32_t tDeserializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) {
|
||||||
|
|
||||||
void tFreeSTableMetaRsp(STableMetaRsp *pRsp) { taosMemoryFreeClear(pRsp->pSchemas); }
|
void tFreeSTableMetaRsp(STableMetaRsp *pRsp) { taosMemoryFreeClear(pRsp->pSchemas); }
|
||||||
|
|
||||||
|
void tFreeSTableIndexRsp(void *info) {
|
||||||
|
if (NULL == info) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
STableIndexRsp *pInfo = (STableIndexRsp *)info;
|
||||||
|
|
||||||
|
taosArrayDestroyEx(pInfo->pIndex, tFreeSTableIndexInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void tFreeSSTbHbRsp(SSTbHbRsp *pRsp) {
|
void tFreeSSTbHbRsp(SSTbHbRsp *pRsp) {
|
||||||
int32_t numOfBatch = taosArrayGetSize(pRsp->pArray);
|
int32_t numOfMeta = taosArrayGetSize(pRsp->pMetaRsp);
|
||||||
for (int32_t i = 0; i < numOfBatch; ++i) {
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
STableMetaRsp *pMetaRsp = taosArrayGet(pRsp->pArray, i);
|
STableMetaRsp *pMetaRsp = taosArrayGet(pRsp->pMetaRsp, i);
|
||||||
tFreeSTableMetaRsp(pMetaRsp);
|
tFreeSTableMetaRsp(pMetaRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pRsp->pArray);
|
taosArrayDestroy(pRsp->pMetaRsp);
|
||||||
|
|
||||||
|
int32_t numOfIndex = taosArrayGetSize(pRsp->pIndexRsp);
|
||||||
|
for (int32_t i = 0; i < numOfIndex; ++i) {
|
||||||
|
STableIndexRsp *pIndexRsp = taosArrayGet(pRsp->pIndexRsp, i);
|
||||||
|
tFreeSTableIndexRsp(pIndexRsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pRsp->pIndexRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSShowRsp(void *buf, int32_t bufLen, SShowRsp *pRsp) {
|
int32_t tSerializeSShowRsp(void *buf, int32_t bufLen, SShowRsp *pRsp) {
|
||||||
|
|
|
@ -885,6 +885,8 @@ static int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strcpy(rsp->dbFName, pStb->db);
|
||||||
|
strcpy(rsp->tbName, pStb->name);
|
||||||
rsp->suid = pStb->uid;
|
rsp->suid = pStb->uid;
|
||||||
rsp->version = pStb->smaVer;
|
rsp->version = pStb->smaVer;
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
|
|
|
@ -1674,15 +1674,15 @@ _OVER:
|
||||||
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t numOfStbs, void **ppRsp,
|
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t numOfStbs, void **ppRsp,
|
||||||
int32_t *pRspLen) {
|
int32_t *pRspLen) {
|
||||||
SSTbHbRsp hbRsp = {0};
|
SSTbHbRsp hbRsp = {0};
|
||||||
hbRsp.pArray = taosArrayInit(numOfStbs, sizeof(STableMetaRsp));
|
hbRsp.pMetaRsp = taosArrayInit(numOfStbs, sizeof(STableMetaRsp));
|
||||||
if (hbRsp.pArray == NULL) {
|
if (hbRsp.pMetaRsp == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hbRsp.pIndexRsp = taosMemoryCalloc(1, sizeof(STableIndexRsp));
|
hbRsp.pIndexRsp = taosArrayInit(numOfStbs, sizeof(STableIndexRsp));
|
||||||
if (NULL == hbRsp.pIndexRsp) {
|
if (NULL == hbRsp.pIndexRsp) {
|
||||||
taosArrayDestroy(hbRsp.pArray);
|
taosArrayDestroy(hbRsp.pMetaRsp);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1700,12 +1700,12 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t
|
||||||
if (mndBuildStbSchema(pMnode, pStbVersion->dbFName, pStbVersion->stbName, &metaRsp, &smaVer) != 0) {
|
if (mndBuildStbSchema(pMnode, pStbVersion->dbFName, pStbVersion->stbName, &metaRsp, &smaVer) != 0) {
|
||||||
metaRsp.numOfColumns = -1;
|
metaRsp.numOfColumns = -1;
|
||||||
metaRsp.suid = pStbVersion->suid;
|
metaRsp.suid = pStbVersion->suid;
|
||||||
taosArrayPush(hbRsp.pArray, &metaRsp);
|
taosArrayPush(hbRsp.pMetaRsp, &metaRsp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStbVersion->sversion != metaRsp.sversion || pStbVersion->tversion != metaRsp.tversion) {
|
if (pStbVersion->sversion != metaRsp.sversion || pStbVersion->tversion != metaRsp.tversion) {
|
||||||
taosArrayPush(hbRsp.pArray, &metaRsp);
|
taosArrayPush(hbRsp.pMetaRsp, &metaRsp);
|
||||||
} else {
|
} else {
|
||||||
tFreeSTableMetaRsp(&metaRsp);
|
tFreeSTableMetaRsp(&metaRsp);
|
||||||
}
|
}
|
||||||
|
@ -1713,11 +1713,19 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t
|
||||||
if (pStbVersion->smaVer != smaVer) {
|
if (pStbVersion->smaVer != smaVer) {
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
STableIndexRsp indexRsp = {0};
|
||||||
sprintf(tbFName, "%s.%s", pStbVersion->dbFName, pStbVersion->stbName);
|
sprintf(tbFName, "%s.%s", pStbVersion->dbFName, pStbVersion->stbName);
|
||||||
int32_t code = mndGetTableSma(pMnode, tbFName, hbRsp.pIndexRsp, &exist);
|
int32_t code = mndGetTableSma(pMnode, tbFName, &indexRsp, &exist);
|
||||||
if (code || !exist) {
|
if (code || !exist) {
|
||||||
taosMemoryFreeClear(hbRsp.pIndexRsp);
|
indexRsp.suid = pStbVersion->suid;
|
||||||
|
indexRsp.version = -1;
|
||||||
|
indexRsp.pIndex = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strcpy(indexRsp->dbFName, pStbVersion->dbFName);
|
||||||
|
strcpy(indexRsp->tbName, pStbVersion->stbName);
|
||||||
|
|
||||||
|
taosArrayPush(hbRsp.pIndexRsp, &indexRsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -319,8 +319,6 @@ typedef struct SCtgUpdateUserMsg {
|
||||||
|
|
||||||
typedef struct SCtgUpdateTbIndexMsg {
|
typedef struct SCtgUpdateTbIndexMsg {
|
||||||
SCatalog* pCtg;
|
SCatalog* pCtg;
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
|
||||||
char tbName[TSDB_TABLE_NAME_LEN];
|
|
||||||
STableIndex* pIndex;
|
STableIndex* pIndex;
|
||||||
} SCtgUpdateTbIndexMsg;
|
} SCtgUpdateTbIndexMsg;
|
||||||
|
|
||||||
|
@ -503,7 +501,7 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId
|
||||||
int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput *output, bool syncReq);
|
int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput *output, bool syncReq);
|
||||||
int32_t ctgUpdateUserEnqueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syncReq);
|
int32_t ctgUpdateUserEnqueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syncReq);
|
||||||
int32_t ctgUpdateVgEpsetEnqueue(SCatalog* pCtg, char *dbFName, int32_t vgId, SEpSet* pEpSet);
|
int32_t ctgUpdateVgEpsetEnqueue(SCatalog* pCtg, char *dbFName, int32_t vgId, SEpSet* pEpSet);
|
||||||
int32_t ctgUpdateTbIndexEnqueue(SCatalog* pCtg, SName* pName, STableIndex *pIndex, bool syncOp);
|
int32_t ctgUpdateTbIndexEnqueue(SCatalog* pCtg, STableIndex *pIndex, bool syncOp);
|
||||||
int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type);
|
int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type);
|
||||||
int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size);
|
int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size);
|
||||||
int32_t ctgMetaRentGet(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size);
|
int32_t ctgMetaRentGet(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size);
|
||||||
|
|
|
@ -751,6 +751,30 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp *pRsp) {
|
||||||
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (NULL == pCtg || NULL == pRsp) {
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
STableIndex* pIndex = taosMemoryCalloc(1, sizeof(STableIndex));
|
||||||
|
if (NULL == pIndex) {
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(pIndex, pRsp, sizeof(STableIndex));
|
||||||
|
|
||||||
|
CTG_ERR_JRET(ctgUpdateTbIndexEnqueue(pCtg, &pIndex, false));
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
CTG_API_LEAVE(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t catalogRemoveTableMeta(SCatalog* pCtg, SName* pTableName) {
|
int32_t catalogRemoveTableMeta(SCatalog* pCtg, SName* pTableName) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -1153,16 +1177,36 @@ int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo *pConn, const SNam
|
||||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgReadTbIndexFromCache(pCtg, pTableName, pRes));
|
||||||
|
if (*pRes) {
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
STableIndex *pIndex = taosMemoryCalloc(1, sizeof(STableIndex));
|
||||||
|
if (NULL == pIndex) {
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
CTG_ERR_JRET(ctgGetTbIndexFromMnode(pCtg, pConn, (SName*)pTableName, pRes, NULL));
|
CTG_ERR_JRET(ctgGetTbIndexFromMnode(pCtg, pConn, (SName*)pTableName, pIndex, NULL));
|
||||||
|
|
||||||
SArray* pInfo = NULL;
|
SArray* pInfo = NULL;
|
||||||
CTG_ERR_JRET(ctgCloneTableIndex(*pRes, &pInfo));
|
CTG_ERR_JRET(ctgCloneTableIndex(pIndex->pIndex, &pInfo));
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgUpdateTbIndexEnqueue(pCtg, pTableName, pInfo, false));
|
*pRes = pInfo;
|
||||||
|
|
||||||
|
CTG_ERR_JRET(ctgUpdateTbIndexEnqueue(pCtg, pTableName, &pIndex, false));
|
||||||
|
|
||||||
|
CTG_API_LEAVE(code);
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
tFreeSTableIndexRsp(pIndex);
|
||||||
|
taosMemoryFree(pIndex);
|
||||||
|
|
||||||
|
taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo);
|
||||||
|
*pRes = NULL;
|
||||||
|
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -876,10 +876,9 @@ int32_t ctgHandleGetTbIndexRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf
|
||||||
SArray* pInfo = NULL;
|
SArray* pInfo = NULL;
|
||||||
CTG_ERR_JRET(ctgCloneTableIndex(pOut->pIndex, &pInfo));
|
CTG_ERR_JRET(ctgCloneTableIndex(pOut->pIndex, &pInfo));
|
||||||
pTask->res = pInfo;
|
pTask->res = pInfo;
|
||||||
pTask->msgCtx.out = NULL;
|
|
||||||
|
|
||||||
SCtgTbIndexCtx* ctx = pTask->taskCtx;
|
SCtgTbIndexCtx* ctx = pTask->taskCtx;
|
||||||
CTG_ERR_JRET(ctgUpdateTbIndexEnqueue(pTask->pJob->pCtg, ctx->pName, pOut, false));
|
CTG_ERR_JRET(ctgUpdateTbIndexEnqueue(pTask->pJob->pCtg, (STableIndex**)&pTask->msgCtx.out, false));
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
|
|
@ -838,7 +838,7 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgUpdateTbIndexEnqueue(SCatalog* pCtg, SName* pName, STableIndex *pIndex, bool syncOp) {
|
int32_t ctgUpdateTbIndexEnqueue(SCatalog* pCtg, STableIndex **pIndex, bool syncOp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgCacheOperation *op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation));
|
SCtgCacheOperation *op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation));
|
||||||
op->opId = CTG_OP_UPDATE_TB_INDEX;
|
op->opId = CTG_OP_UPDATE_TB_INDEX;
|
||||||
|
@ -851,19 +851,19 @@ int32_t ctgUpdateTbIndexEnqueue(SCatalog* pCtg, SName* pName, STableIndex *pInde
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->pCtg = pCtg;
|
msg->pCtg = pCtg;
|
||||||
msg->pIndex = pIndex;
|
msg->pIndex = *pIndex;
|
||||||
tNameGetFullDbName(pName, msg->dbFName);
|
|
||||||
strcpy(msg->tbName, pName->tname);
|
|
||||||
|
|
||||||
op->data = msg;
|
op->data = msg;
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgEnqueue(pCtg, op));
|
CTG_ERR_JRET(ctgEnqueue(pCtg, op));
|
||||||
|
|
||||||
|
*pIndex = NULL;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
taosArrayDestroyEx(pIndex, tFreeSTableIndexInfo);
|
taosArrayDestroyEx(*pIndex, tFreeSTableIndexInfo);
|
||||||
|
taosMemoryFreeClear(*pIndex);
|
||||||
taosMemoryFreeClear(msg);
|
taosMemoryFreeClear(msg);
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
|
@ -1745,12 +1745,12 @@ int32_t ctgOpUpdateTbIndex(SCtgCacheOperation *operation) {
|
||||||
STableIndex* pIndex = msg->pIndex;
|
STableIndex* pIndex = msg->pIndex;
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgGetAddDBCache(pCtg, msg->dbFName, 0, &dbCache));
|
CTG_ERR_JRET(ctgGetAddDBCache(pCtg, pIndex->dbFName, 0, &dbCache));
|
||||||
if (NULL == dbCache) {
|
if (NULL == dbCache) {
|
||||||
CTG_ERR_JRET(code);
|
CTG_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgWriteTbIndexToCache(pCtg, dbCache, msg->dbFName, msg->tbName, &pIndex));
|
CTG_ERR_JRET(ctgWriteTbIndexToCache(pCtg, dbCache, pIndex->dbFName, pIndex->tbName, &pIndex));
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
|
|
@ -431,7 +431,7 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *name, SArray** out, SCtgTask* pTask) {
|
int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *name, STableIndex* out, SCtgTask* pTask) {
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
int32_t msgLen = 0;
|
int32_t msgLen = 0;
|
||||||
int32_t reqType = TDMT_MND_GET_TABLE_INDEX;
|
int32_t reqType = TDMT_MND_GET_TABLE_INDEX;
|
||||||
|
@ -448,7 +448,11 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *n
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask) {
|
if (pTask) {
|
||||||
void* pOut = NULL;
|
void* pOut = taosMemoryCalloc(1, sizeof(STableIndex));
|
||||||
|
if (NULL == pOut) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)tbFName));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)tbFName));
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
|
|
@ -484,18 +484,12 @@ int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
|
||||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableIndexRsp *out = taosMemoryCalloc(1, sizeof(STableIndexRsp));
|
STableIndexRsp *out = (STableIndexRsp*)output;
|
||||||
if (NULL == out) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) {
|
if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) {
|
||||||
qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize);
|
qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize);
|
||||||
return TSDB_CODE_INVALID_MSG;
|
return TSDB_CODE_INVALID_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(void **)output = out;
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue