TDengine/source/dnode/vnode/src/vnd/vnodeSvr.c

482 lines
15 KiB
C
Raw Normal View History

2022-04-14 08:42:50 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2022-04-26 11:04:26 +00:00
#include "vnd.h"
2022-04-14 08:42:50 +00:00
2022-04-21 14:01:58 +00:00
static int vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp);
2022-04-21 03:47:58 +00:00
static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp);
2022-04-28 04:09:31 +00:00
static int vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
2022-04-22 09:42:31 +00:00
static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp);
2022-04-21 03:47:58 +00:00
static int vnodeProcessAlterTbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp);
2022-04-28 04:09:31 +00:00
static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
2022-04-25 11:38:05 +00:00
static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
2022-04-14 10:21:06 +00:00
2022-04-19 02:37:45 +00:00
int vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs, int64_t *version) {
2022-04-20 11:30:18 +00:00
#if 0
2022-04-14 08:42:50 +00:00
SNodeMsg *pMsg;
SRpcMsg *pRpc;
2022-04-19 02:37:45 +00:00
*version = pVnode->state.processed;
2022-04-14 08:42:50 +00:00
for (int i = 0; i < taosArrayGetSize(pMsgs); i++) {
pMsg = *(SNodeMsg **)taosArrayGet(pMsgs, i);
pRpc = &pMsg->rpcMsg;
// set request version
2022-04-19 02:37:45 +00:00
if (walWrite(pVnode->pWal, pVnode->state.processed++, pRpc->msgType, pRpc->pCont, pRpc->contLen) < 0) {
2022-04-16 07:50:05 +00:00
vError("vnode:%d write wal error since %s", TD_VID(pVnode), terrstr());
2022-04-19 02:37:45 +00:00
return -1;
2022-04-14 08:42:50 +00:00
}
}
walFsync(pVnode->pWal, false);
2022-04-19 02:37:45 +00:00
2022-04-20 11:30:18 +00:00
#endif
2022-04-19 02:37:45 +00:00
return 0;
2022-04-14 08:42:50 +00:00
}
2022-04-19 03:17:23 +00:00
int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp) {
2022-04-14 08:42:50 +00:00
void *ptr = NULL;
2022-04-20 08:50:45 +00:00
void *pReq;
int len;
2022-04-14 12:12:40 +00:00
int ret;
2022-04-14 08:42:50 +00:00
2022-04-29 07:55:52 +00:00
vTrace("vgId:%d start to process write request %s, version %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
2022-04-20 08:50:45 +00:00
version);
2022-04-14 08:42:50 +00:00
2022-04-21 03:47:58 +00:00
pVnode->state.applied = version;
2022-04-20 08:50:45 +00:00
// skip header
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
len = pMsg->contLen - sizeof(SMsgHead);
2022-04-14 08:42:50 +00:00
2022-04-19 02:37:45 +00:00
if (tqPushMsg(pVnode->pTq, pMsg->pCont, pMsg->contLen, pMsg->msgType, version) < 0) {
2022-04-29 07:55:52 +00:00
vError("vgId:%d failed to push msg to TQ since %s", TD_VID(pVnode), tstrerror(terrno));
2022-04-20 08:50:45 +00:00
return -1;
2022-04-14 08:42:50 +00:00
}
switch (pMsg->msgType) {
2022-04-20 08:50:45 +00:00
/* META */
2022-04-14 10:21:06 +00:00
case TDMT_VND_CREATE_STB:
2022-04-21 14:01:58 +00:00
if (vnodeProcessCreateStbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err;
2022-04-19 03:45:22 +00:00
break;
2022-04-14 10:21:06 +00:00
case TDMT_VND_ALTER_STB:
2022-04-21 03:47:58 +00:00
if (vnodeProcessAlterStbReq(pVnode, pReq, len, pRsp) < 0) goto _err;
2022-04-19 03:45:22 +00:00
break;
2022-04-14 08:42:50 +00:00
case TDMT_VND_DROP_STB:
2022-04-28 04:09:31 +00:00
if (vnodeProcessDropStbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err;
2022-04-14 08:42:50 +00:00
break;
2022-04-20 08:50:45 +00:00
case TDMT_VND_CREATE_TABLE:
2022-04-22 09:42:31 +00:00
if (vnodeProcessCreateTbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err;
2022-04-20 08:50:45 +00:00
break;
case TDMT_VND_ALTER_TABLE:
2022-04-21 03:47:58 +00:00
if (vnodeProcessAlterTbReq(pVnode, pReq, len, pRsp) < 0) goto _err;
2022-04-20 08:50:45 +00:00
break;
2022-04-14 08:42:50 +00:00
case TDMT_VND_DROP_TABLE:
2022-04-28 04:09:31 +00:00
if (vnodeProcessDropTbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err;
2022-04-14 08:42:50 +00:00
break;
2022-04-20 08:50:45 +00:00
case TDMT_VND_CREATE_SMA: { // timeRangeSMA
if (tsdbCreateTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) {
// TODO
}
} break;
/* TSDB */
2022-04-14 08:42:50 +00:00
case TDMT_VND_SUBMIT:
2022-04-25 11:38:05 +00:00
if (vnodeProcessSubmitReq(pVnode, version, pMsg->pCont, pMsg->contLen, pRsp) < 0) goto _err;
2022-04-19 03:45:22 +00:00
break;
2022-04-20 08:50:45 +00:00
/* TQ */
2022-04-20 13:36:55 +00:00
case TDMT_VND_MQ_VG_CHANGE:
if (tqProcessVgChangeReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
pMsg->contLen - sizeof(SMsgHead)) < 0) {
// TODO: handle error
}
break;
2022-04-14 08:42:50 +00:00
case TDMT_VND_TASK_DEPLOY: {
if (tqProcessTaskDeploy(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
pMsg->contLen - sizeof(SMsgHead)) < 0) {
}
} break;
case TDMT_VND_TASK_WRITE_EXEC: {
if (tqProcessTaskExec(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), pMsg->contLen - sizeof(SMsgHead),
0) < 0) {
}
} break;
2022-04-20 06:58:14 +00:00
case TDMT_VND_ALTER_VNODE:
break;
2022-04-14 08:42:50 +00:00
default:
ASSERT(0);
break;
}
2022-04-29 07:55:52 +00:00
vDebug("vgId:%d process %s request success, version: %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), version);
2022-04-14 08:42:50 +00:00
2022-04-24 07:34:53 +00:00
// commit if need
2022-04-20 08:50:45 +00:00
if (vnodeShouldCommit(pVnode)) {
2022-04-24 09:14:37 +00:00
vInfo("vgId:%d commit at version %" PRId64, TD_VID(pVnode), version);
2022-04-24 07:34:53 +00:00
// commit current change
vnodeCommit(pVnode);
// start a new one
vnodeBegin(pVnode);
2022-04-14 08:42:50 +00:00
}
return 0;
2022-04-21 03:47:58 +00:00
_err:
2022-04-29 07:55:52 +00:00
vDebug("vgId:%d process %s request failed since %s, version: %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
2022-04-21 03:47:58 +00:00
tstrerror(terrno), version);
return -1;
2022-04-14 08:42:50 +00:00
}
int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
2022-04-24 12:11:34 +00:00
vTrace("message in vnode query queue is processing");
#if 0
SReadHandle handle = {.reader = pVnode->pTsdb, .meta = pVnode->pMeta, .config = &pVnode->config, .vnode = pVnode};
#endif
SReadHandle handle = {.meta = pVnode->pMeta, .config = &pVnode->config, .vnode = pVnode};
2022-04-14 08:42:50 +00:00
switch (pMsg->msgType) {
case TDMT_VND_QUERY:
return qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg);
case TDMT_VND_QUERY_CONTINUE:
return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg);
default:
vError("unknown msg type:%d in query queue", pMsg->msgType);
return TSDB_CODE_VND_APP_ERROR;
}
}
int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
vTrace("message in fetch queue is processing");
char *msgstr = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
switch (pMsg->msgType) {
case TDMT_VND_FETCH:
return qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg);
case TDMT_VND_FETCH_RSP:
return qWorkerProcessFetchRsp(pVnode, pVnode->pQuery, pMsg);
case TDMT_VND_RES_READY:
return qWorkerProcessReadyMsg(pVnode, pVnode->pQuery, pMsg);
case TDMT_VND_TASKS_STATUS:
return qWorkerProcessStatusMsg(pVnode, pVnode->pQuery, pMsg);
case TDMT_VND_CANCEL_TASK:
return qWorkerProcessCancelMsg(pVnode, pVnode->pQuery, pMsg);
case TDMT_VND_DROP_TASK:
return qWorkerProcessDropMsg(pVnode, pVnode->pQuery, pMsg);
case TDMT_VND_TABLE_META:
return vnodeGetTableMeta(pVnode, pMsg);
case TDMT_VND_CONSUME:
return tqProcessPollReq(pVnode->pTq, pMsg, pInfo->workerId);
case TDMT_VND_TASK_PIPE_EXEC:
case TDMT_VND_TASK_MERGE_EXEC:
return tqProcessTaskExec(pVnode->pTq, msgstr, msgLen, 0);
case TDMT_VND_STREAM_TRIGGER:
return tqProcessStreamTrigger(pVnode->pTq, pMsg->pCont, pMsg->contLen, 0);
case TDMT_VND_QUERY_HEARTBEAT:
return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg);
default:
vError("unknown msg type:%d in fetch queue", pMsg->msgType);
return TSDB_CODE_VND_APP_ERROR;
}
}
// TODO: remove the function
void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
// TODO
// blockDebugShowData(data);
tsdbInsertTSmaData(((SVnode *)pVnode)->pTsdb, smaId, (const char *)data);
}
2022-04-19 07:43:24 +00:00
// sync integration
2022-04-14 08:42:50 +00:00
int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
if (syncEnvIsStart()) {
SSyncNode *pSyncNode = syncNodeAcquire(pVnode->sync);
assert(pSyncNode != NULL);
2022-04-19 07:43:24 +00:00
ESyncState state = syncGetMyRole(pVnode->sync);
SyncTerm currentTerm = syncGetMyTerm(pVnode->sync);
2022-04-19 07:43:24 +00:00
SMsgHead *pHead = pMsg->pCont;
2022-04-19 07:43:24 +00:00
char logBuf[512];
char *syncNodeStr = sync2SimpleStr(pVnode->sync);
snprintf(logBuf, sizeof(logBuf), "==vnodeProcessSyncReq== msgType:%d, syncNode: %s", pMsg->msgType, syncNodeStr);
syncRpcMsgLog2(logBuf, pMsg);
taosMemoryFree(syncNodeStr);
2022-04-19 07:43:24 +00:00
SRpcMsg *pRpcMsg = pMsg;
2022-04-19 07:43:24 +00:00
if (pRpcMsg->msgType == TDMT_VND_SYNC_TIMEOUT) {
SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pRpcMsg);
assert(pSyncMsg != NULL);
2022-04-19 07:43:24 +00:00
syncNodeOnTimeoutCb(pSyncNode, pSyncMsg);
syncTimeoutDestroy(pSyncMsg);
2022-04-19 07:43:24 +00:00
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_PING) {
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pRpcMsg);
assert(pSyncMsg != NULL);
2022-04-19 07:43:24 +00:00
syncNodeOnPingCb(pSyncNode, pSyncMsg);
syncPingDestroy(pSyncMsg);
2022-04-19 07:43:24 +00:00
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_PING_REPLY) {
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pRpcMsg);
assert(pSyncMsg != NULL);
2022-04-19 07:43:24 +00:00
syncNodeOnPingReplyCb(pSyncNode, pSyncMsg);
syncPingReplyDestroy(pSyncMsg);
2022-04-19 07:43:24 +00:00
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_CLIENT_REQUEST) {
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg);
assert(pSyncMsg != NULL);
2022-04-19 07:43:24 +00:00
syncNodeOnClientRequestCb(pSyncNode, pSyncMsg);
syncClientRequestDestroy(pSyncMsg);
2022-04-19 07:43:24 +00:00
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_REQUEST_VOTE) {
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pRpcMsg);
assert(pSyncMsg != NULL);
2022-04-19 07:43:24 +00:00
syncNodeOnRequestVoteCb(pSyncNode, pSyncMsg);
syncRequestVoteDestroy(pSyncMsg);
2022-04-19 07:43:24 +00:00
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_REQUEST_VOTE_REPLY) {
SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pRpcMsg);
assert(pSyncMsg != NULL);
2022-04-19 07:43:24 +00:00
syncNodeOnRequestVoteReplyCb(pSyncNode, pSyncMsg);
syncRequestVoteReplyDestroy(pSyncMsg);
2022-04-19 07:43:24 +00:00
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_APPEND_ENTRIES) {
SyncAppendEntries *pSyncMsg = syncAppendEntriesFromRpcMsg2(pRpcMsg);
assert(pSyncMsg != NULL);
2022-04-19 07:43:24 +00:00
syncNodeOnAppendEntriesCb(pSyncNode, pSyncMsg);
syncAppendEntriesDestroy(pSyncMsg);
2022-04-19 07:43:24 +00:00
} else if (pRpcMsg->msgType == TDMT_VND_SYNC_APPEND_ENTRIES_REPLY) {
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pRpcMsg);
assert(pSyncMsg != NULL);
syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
syncAppendEntriesReplyDestroy(pSyncMsg);
2022-04-19 07:43:24 +00:00
} else {
vError("==vnodeProcessSyncReq== error msg type:%d", pRpcMsg->msgType);
}
2022-04-19 07:43:24 +00:00
syncNodeRelease(pSyncNode);
} else {
vError("==vnodeProcessSyncReq== error syncEnv stop");
}
2022-04-14 08:42:50 +00:00
return 0;
2022-04-14 10:21:06 +00:00
}
2022-04-21 14:01:58 +00:00
static int vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp) {
2022-04-20 10:03:50 +00:00
SVCreateStbReq req = {0};
SCoder coder;
2022-04-21 03:47:58 +00:00
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
pRsp->code = TSDB_CODE_SUCCESS;
pRsp->pCont = NULL;
pRsp->contLen = 0;
// decode and process req
2022-04-20 10:03:50 +00:00
tCoderInit(&coder, TD_LITTLE_ENDIAN, pReq, len, TD_DECODER);
if (tDecodeSVCreateStbReq(&coder, &req) < 0) {
2022-04-21 03:47:58 +00:00
pRsp->code = terrno;
goto _err;
2022-04-20 10:03:50 +00:00
}
2022-04-22 05:30:15 +00:00
if (metaCreateSTable(pVnode->pMeta, version, &req) < 0) {
2022-04-21 03:47:58 +00:00
pRsp->code = terrno;
goto _err;
2022-04-14 10:21:06 +00:00
}
2022-04-27 11:49:04 +00:00
tsdbRegisterRSma(pVnode->pTsdb, pVnode->pMeta, &req);
2022-04-20 10:03:50 +00:00
tCoderClear(&coder);
2022-04-14 10:21:06 +00:00
return 0;
2022-04-21 03:47:58 +00:00
_err:
tCoderClear(&coder);
return -1;
2022-04-14 10:21:06 +00:00
}
2022-04-22 09:42:31 +00:00
static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp) {
SCoder coder = {0};
int rcode = 0;
SVCreateTbBatchReq req = {0};
SVCreateTbReq *pCreateReq;
2022-04-23 10:50:26 +00:00
SVCreateTbBatchRsp rsp = {0};
SVCreateTbRsp cRsp = {0};
char tbName[TSDB_TABLE_FNAME_LEN];
2022-04-27 11:49:04 +00:00
STbUidStore *pStore = NULL;
2022-04-21 03:47:58 +00:00
pRsp->msgType = TDMT_VND_CREATE_TABLE_RSP;
2022-04-23 10:50:26 +00:00
pRsp->code = TSDB_CODE_SUCCESS;
pRsp->pCont = NULL;
pRsp->contLen = 0;
2022-04-14 10:21:06 +00:00
2022-04-22 09:42:31 +00:00
// decode
tCoderInit(&coder, TD_LITTLE_ENDIAN, pReq, len, TD_DECODER);
if (tDecodeSVCreateTbBatchReq(&coder, &req) < 0) {
rcode = -1;
terrno = TSDB_CODE_INVALID_MSG;
goto _exit;
}
2022-04-14 10:21:06 +00:00
2022-04-23 10:50:26 +00:00
rsp.pArray = taosArrayInit(sizeof(cRsp), req.nReqs);
if (rsp.pArray == NULL) {
rcode = -1;
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
2022-04-22 09:42:31 +00:00
// loop to create table
for (int iReq = 0; iReq < req.nReqs; iReq++) {
pCreateReq = req.pReqs + iReq;
2022-04-23 10:50:26 +00:00
// validate hash
sprintf(tbName, "%s.%s", pVnode->config.dbname, pCreateReq->name);
if (vnodeValidateTableHash(pVnode, tbName) < 0) {
cRsp.code = TSDB_CODE_VND_HASH_MISMATCH;
taosArrayPush(rsp.pArray, &cRsp);
continue;
}
// do create table
2022-04-22 09:42:31 +00:00
if (metaCreateTable(pVnode->pMeta, version, pCreateReq) < 0) {
2022-04-23 10:50:26 +00:00
cRsp.code = terrno;
2022-04-14 10:21:06 +00:00
} else {
2022-04-23 10:50:26 +00:00
cRsp.code = TSDB_CODE_SUCCESS;
2022-04-27 11:49:04 +00:00
tsdbFetchTbUidList(pVnode->pTsdb, &pStore, pCreateReq->ctb.suid, pCreateReq->uid);
2022-04-14 10:21:06 +00:00
}
2022-04-23 10:50:26 +00:00
taosArrayPush(rsp.pArray, &cRsp);
2022-04-14 10:21:06 +00:00
}
2022-04-23 10:50:26 +00:00
tCoderClear(&coder);
2022-04-27 11:49:04 +00:00
tsdbUpdateTbUidList(pVnode->pTsdb, pStore);
tsdbUidStoreFree(pStore);
2022-04-22 09:42:31 +00:00
// prepare rsp
2022-04-27 09:39:54 +00:00
int32_t ret = 0;
tEncodeSize(tEncodeSVCreateTbBatchRsp, &rsp, pRsp->contLen, ret);
2022-04-23 10:50:26 +00:00
pRsp->pCont = rpcMallocCont(pRsp->contLen);
if (pRsp->pCont == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
rcode = -1;
goto _exit;
}
tCoderInit(&coder, TD_LITTLE_ENDIAN, pRsp->pCont, pRsp->contLen, TD_ENCODER);
tEncodeSVCreateTbBatchRsp(&coder, &rsp);
2022-04-14 10:21:06 +00:00
2022-04-22 09:42:31 +00:00
_exit:
2022-04-24 02:50:08 +00:00
taosArrayClear(rsp.pArray);
2022-04-22 09:42:31 +00:00
tCoderClear(&coder);
return rcode;
2022-04-14 10:21:06 +00:00
}
2022-04-21 03:47:58 +00:00
static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp) {
2022-04-26 07:05:15 +00:00
// ASSERT(0);
2022-04-21 03:47:58 +00:00
#if 0
2022-04-14 10:21:06 +00:00
SVCreateTbReq vAlterTbReq = {0};
2022-04-16 07:50:05 +00:00
vTrace("vgId:%d, process alter stb req", TD_VID(pVnode));
2022-04-14 10:21:06 +00:00
tDeserializeSVCreateTbReq(pReq, &vAlterTbReq);
// TODO: to encapsule a free API
taosMemoryFree(vAlterTbReq.stbCfg.pSchema);
taosMemoryFree(vAlterTbReq.stbCfg.pTagSchema);
if (vAlterTbReq.stbCfg.pRSmaParam) {
taosMemoryFree(vAlterTbReq.stbCfg.pRSmaParam);
}
taosMemoryFree(vAlterTbReq.name);
2022-04-21 03:47:58 +00:00
#endif
return 0;
}
2022-04-28 04:09:31 +00:00
static int vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
2022-04-28 06:20:00 +00:00
SVDropStbReq req = {0};
int rcode = TSDB_CODE_SUCCESS;
SCoder coder = {0};
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
pRsp->pCont = NULL;
pRsp->contLen = 0;
// decode request
tCoderInit(&coder, TD_LITTLE_ENDIAN, pReq, len, TD_DECODER);
if (tDecodeSVDropStbReq(&coder, &req) < 0) {
rcode = TSDB_CODE_INVALID_MSG;
goto _exit;
}
// process request
2022-04-28 08:39:33 +00:00
// if (metaDropSTable(pVnode->pMeta, version, &req) < 0) {
// rcode = terrno;
// goto _exit;
// }
2022-04-28 06:20:00 +00:00
// return rsp
_exit:
pRsp->code = rcode;
tCoderClear(&coder);
2022-04-21 03:47:58 +00:00
return 0;
}
static int vnodeProcessAlterTbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp) {
// TODO
ASSERT(0);
return 0;
}
2022-04-28 04:09:31 +00:00
static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
SVDropTbReq req = {0};
SVDropTbReq rsp = {0};
// decode req
// process req
// return rsp
2022-04-16 06:32:34 +00:00
return 0;
}
2022-04-25 11:38:05 +00:00
static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
SSubmitReq *pSubmitReq = (SSubmitReq *)pReq;
SSubmitRsp rsp = {0};
2022-04-16 06:32:34 +00:00
pRsp->code = 0;
2022-05-01 04:18:54 +00:00
tsdbTriggerRSma(pVnode->pTsdb, pReq, STREAM_DATA_TYPE_SUBMIT_BLOCK);
2022-04-16 06:32:34 +00:00
// handle the request
2022-04-25 11:38:05 +00:00
if (tsdbInsertData(pVnode->pTsdb, version, pSubmitReq, &rsp) < 0) {
2022-04-16 06:32:34 +00:00
pRsp->code = terrno;
return -1;
}
// pRsp->msgType = TDMT_VND_SUBMIT_RSP;
// vnodeProcessSubmitReq(pVnode, ptr, pRsp);
2022-05-01 04:18:54 +00:00
// tsdbTriggerRSma(pVnode->pTsdb, pReq, STREAM_DATA_TYPE_SUBMIT_BLOCK);
2022-04-16 06:32:34 +00:00
// encode the response (TODO)
pRsp->pCont = rpcMallocCont(sizeof(SSubmitRsp));
memcpy(pRsp->pCont, &rsp, sizeof(rsp));
pRsp->contLen = sizeof(SSubmitRsp);
2022-04-14 10:21:06 +00:00
return 0;
2022-04-20 13:36:55 +00:00
}