The length of submit message used to insert data to server is incorrect #673
This commit is contained in:
parent
afb33efc6a
commit
e124a54d50
|
@ -217,14 +217,19 @@ int tscSendMsgToServer(SSqlObj *pSql) {
|
||||||
int32_t totalMsgLen = pSql->cmd.payloadLen + tsRpcHeadSize + sizeof(STaosDigest);
|
int32_t totalMsgLen = pSql->cmd.payloadLen + tsRpcHeadSize + sizeof(STaosDigest);
|
||||||
|
|
||||||
// the memory will be released by taosProcessResponse, so no memory leak here
|
// the memory will be released by taosProcessResponse, so no memory leak here
|
||||||
char* buf = malloc(totalMsgLen);
|
char *buf = malloc(totalMsgLen);
|
||||||
memcpy(buf, pSql->cmd.payload, totalMsgLen);
|
if (NULL == buf) {
|
||||||
|
tscError("%p msg:%s malloc fail", pSql, taosMsg[pSql->cmd.msgType]);
|
||||||
|
return TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(buf, pSql->cmd.payload, (size_t) totalMsgLen);
|
||||||
tscTrace("%p msg:%s is sent to server", pSql, taosMsg[pSql->cmd.msgType]);
|
tscTrace("%p msg:%s is sent to server", pSql, taosMsg[pSql->cmd.msgType]);
|
||||||
char *pStart = taosBuildReqHeader(pSql->thandle, pSql->cmd.msgType, buf);
|
char *pStart = taosBuildReqHeader(pSql->thandle, pSql->cmd.msgType, buf);
|
||||||
if (pStart) {
|
if (pStart) {
|
||||||
if (tscUpdateVnodeMsg[pSql->cmd.command]) (*tscUpdateVnodeMsg[pSql->cmd.command])(pSql, buf);
|
if (tscUpdateVnodeMsg[pSql->cmd.command]) (*tscUpdateVnodeMsg[pSql->cmd.command])(pSql, buf);
|
||||||
int ret = taosSendMsgToPeerH(pSql->thandle, pStart, pSql->cmd.payloadLen, pSql);
|
int ret = taosSendMsgToPeerH(pSql->thandle, pStart, pSql->cmd.payloadLen, pSql);
|
||||||
|
|
||||||
if (ret >= 0) code = 0;
|
if (ret >= 0) code = 0;
|
||||||
tscTrace("%p send msg ret:%d code:%d sig:%p", pSql, ret, code, pSql->signature);
|
tscTrace("%p send msg ret:%d code:%d sig:%p", pSql, ret, code, pSql->signature);
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,11 +384,22 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
|
||||||
pCmd->count = pDataBlock->numOfMeters;
|
pCmd->count = pDataBlock->numOfMeters;
|
||||||
strncpy(pCmd->name, pDataBlock->meterId, TSDB_METER_ID_LEN);
|
strncpy(pCmd->name, pDataBlock->meterId, TSDB_METER_ID_LEN);
|
||||||
|
|
||||||
tscAllocPayloadWithSize(pCmd, pDataBlock->nAllocSize);
|
/*
|
||||||
|
* the submit message consists of : [RPC header|message body|digest]
|
||||||
|
* the dataBlock only includes the RPC Header buffer and actual submit messsage body, space for digest needs
|
||||||
|
* additional space.
|
||||||
|
*/
|
||||||
|
int ret = tscAllocPayloadWithSize(pCmd, pDataBlock->nAllocSize + sizeof(STaosDigest));
|
||||||
|
if (TSDB_CODE_SUCCESS != ret) return ret;
|
||||||
memcpy(pCmd->payload, pDataBlock->pData, pDataBlock->nAllocSize);
|
memcpy(pCmd->payload, pDataBlock->pData, pDataBlock->nAllocSize);
|
||||||
|
|
||||||
// set the message length
|
/*
|
||||||
pCmd->payloadLen = pDataBlock->nAllocSize;
|
* the payloadLen should be actual message body size
|
||||||
|
* the old value of payloadLen is the allocated payload size
|
||||||
|
*/
|
||||||
|
pCmd->payloadLen = pDataBlock->nAllocSize - tsRpcHeadSize;
|
||||||
|
|
||||||
|
assert(pCmd->allocSize >= pCmd->payloadLen + tsRpcHeadSize + sizeof(STaosDigest));
|
||||||
return tscGetMeterMeta(pSql, pCmd->name);
|
return tscGetMeterMeta(pSql, pCmd->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue