Merge branch '3.0' into feature/TD-11274-3.0
This commit is contained in:
commit
55016293df
|
@ -2,7 +2,7 @@
|
||||||
# taosws-rs
|
# taosws-rs
|
||||||
ExternalProject_Add(taosws-rs
|
ExternalProject_Add(taosws-rs
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taosws-rs.git
|
GIT_REPOSITORY https://github.com/taosdata/taosws-rs.git
|
||||||
GIT_TAG 9fa7e2f
|
GIT_TAG 648cc62
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -448,7 +448,8 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vTrace("vgId:%d, sync msg:%p is processed, type:%s code:0x%x", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType), code);
|
vTrace("vgId:%d, sync msg:%p is processed, type:%s code:0x%x", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType),
|
||||||
|
code);
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
if (code != 0 && terrno == 0) {
|
if (code != 0 && terrno == 0) {
|
||||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
@ -629,8 +630,8 @@ static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void
|
||||||
static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
||||||
#ifdef USE_TSDB_SNAPSHOT
|
#ifdef USE_TSDB_SNAPSHOT
|
||||||
SVnode *pVnode = pFsm->data;
|
SVnode *pVnode = pFsm->data;
|
||||||
vInfo("vgId:%d, stop write vnode snapshot, apply:%d, index:%" PRId64 " term:%" PRIu64 " config:%" PRId64, pVnode->config.vgId, isApply,
|
vInfo("vgId:%d, stop write vnode snapshot, apply:%d, index:%" PRId64 " term:%" PRIu64 " config:%" PRId64,
|
||||||
pSnapshot->lastApplyIndex, pSnapshot->lastApplyTerm, pSnapshot->lastConfigIndex);
|
pVnode->config.vgId, isApply, pSnapshot->lastApplyIndex, pSnapshot->lastApplyTerm, pSnapshot->lastConfigIndex);
|
||||||
|
|
||||||
int32_t code = vnodeSnapWriterClose(pWriter, !isApply, pSnapshot);
|
int32_t code = vnodeSnapWriterClose(pWriter, !isApply, pSnapshot);
|
||||||
vInfo("vgId:%d, apply vnode snapshot finished, code:0x%x", pVnode->config.vgId, code);
|
vInfo("vgId:%d, apply vnode snapshot finished, code:0x%x", pVnode->config.vgId, code);
|
||||||
|
@ -707,7 +708,7 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setPingTimerMS(pVnode->sync, 5000);
|
setPingTimerMS(pVnode->sync, 5000);
|
||||||
setElectTimerMS(pVnode->sync, 1300);
|
setElectTimerMS(pVnode->sync, 2800);
|
||||||
setHeartbeatTimerMS(pVnode->sync, 900);
|
setHeartbeatTimerMS(pVnode->sync, 900);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,13 @@ extern "C" {
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
|
|
||||||
#define TIMER_MAX_MS 0x7FFFFFFF
|
#define TIMER_MAX_MS 0x7FFFFFFF
|
||||||
#define ENV_TICK_TIMER_MS 1000
|
#define ENV_TICK_TIMER_MS 1000
|
||||||
#define PING_TIMER_MS 5000
|
#define PING_TIMER_MS 5000
|
||||||
#define ELECT_TIMER_MS_MIN 1300
|
#define ELECT_TIMER_MS_MIN 5000
|
||||||
#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2)
|
#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2)
|
||||||
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
|
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
|
||||||
#define HEARTBEAT_TIMER_MS 900
|
#define HEARTBEAT_TIMER_MS 900
|
||||||
|
|
||||||
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
|
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
|
||||||
|
|
||||||
|
|
|
@ -730,7 +730,8 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg** pMsgPArr, bool* pIs
|
||||||
for (int i = 0; i < arrSize; ++i) {
|
for (int i = 0; i < arrSize; ++i) {
|
||||||
do {
|
do {
|
||||||
char eventLog[128];
|
char eventLog[128];
|
||||||
snprintf(eventLog, sizeof(eventLog), "propose message, type:%s batch:%d", TMSG_INFO(pMsgPArr[i]->msgType), arrSize);
|
snprintf(eventLog, sizeof(eventLog), "propose message, type:%s batch:%d", TMSG_INFO(pMsgPArr[i]->msgType),
|
||||||
|
arrSize);
|
||||||
syncNodeEventLog(pSyncNode, eventLog);
|
syncNodeEventLog(pSyncNode, eventLog);
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
@ -834,7 +835,8 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
|
||||||
rpcFreeCont(rpcMsg.pCont);
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
syncRespMgrDel(pSyncNode->pSyncRespMgr, seqNum);
|
syncRespMgrDel(pSyncNode->pSyncRespMgr, seqNum);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
sDebug("vgId:%d, sync optimize index:%" PRId64 ", type:%s", pSyncNode->vgId, retIndex, TMSG_INFO(pMsg->msgType));
|
sDebug("vgId:%d, sync optimize index:%" PRId64 ", type:%s", pSyncNode->vgId, retIndex,
|
||||||
|
TMSG_INFO(pMsg->msgType));
|
||||||
} else {
|
} else {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
@ -1114,7 +1116,7 @@ void syncNodeStart(SSyncNode* pSyncNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
ret = syncNodeStartPingTimer(pSyncNode);
|
// ret = syncNodeStartPingTimer(pSyncNode);
|
||||||
ASSERT(ret == 0);
|
ASSERT(ret == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1250,6 +1252,13 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
|
||||||
taosTmrReset(pSyncNode->FpElectTimerCB, pSyncNode->electTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
taosTmrReset(pSyncNode->FpElectTimerCB, pSyncNode->electTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||||
&pSyncNode->pElectTimer);
|
&pSyncNode->pElectTimer);
|
||||||
atomic_store_64(&pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser);
|
atomic_store_64(&pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser);
|
||||||
|
|
||||||
|
do {
|
||||||
|
char logBuf[128];
|
||||||
|
snprintf(logBuf, sizeof(logBuf), "elect timer reset, ms:%d", ms);
|
||||||
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
|
} while (0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sError("vgId:%d, start elect timer error, sync env is stop", pSyncNode->vgId);
|
sError("vgId:%d, start elect timer error, sync env is stop", pSyncNode->vgId);
|
||||||
}
|
}
|
||||||
|
@ -1281,6 +1290,14 @@ int32_t syncNodeResetElectTimer(SSyncNode* pSyncNode) {
|
||||||
electMS = syncUtilElectRandomMS(pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine);
|
electMS = syncUtilElectRandomMS(pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine);
|
||||||
}
|
}
|
||||||
ret = syncNodeRestartElectTimer(pSyncNode, electMS);
|
ret = syncNodeRestartElectTimer(pSyncNode, electMS);
|
||||||
|
|
||||||
|
do {
|
||||||
|
char logBuf[128];
|
||||||
|
snprintf(logBuf, sizeof(logBuf), "reset elect timer, min:%d, max:%d, ms:%d", pSyncNode->electBaseLine,
|
||||||
|
2 * pSyncNode->electBaseLine, electMS);
|
||||||
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
|
} while (0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1293,6 +1310,13 @@ int32_t syncNodeStartHeartbeatTimer(SSyncNode* pSyncNode) {
|
||||||
} else {
|
} else {
|
||||||
sError("vgId:%d, start heartbeat timer error, sync env is stop", pSyncNode->vgId);
|
sError("vgId:%d, start heartbeat timer error, sync env is stop", pSyncNode->vgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
char logBuf[128];
|
||||||
|
snprintf(logBuf, sizeof(logBuf), "start heartbeat timer, ms:%d", pSyncNode->heartbeatTimerMS);
|
||||||
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
|
} while (0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1304,6 +1328,13 @@ int32_t syncNodeStartNowHeartbeatTimer(SSyncNode* pSyncNode) {
|
||||||
} else {
|
} else {
|
||||||
sError("vgId:%d, start heartbeat timer error, sync env is stop", pSyncNode->vgId);
|
sError("vgId:%d, start heartbeat timer error, sync env is stop", pSyncNode->vgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
char logBuf[128];
|
||||||
|
snprintf(logBuf, sizeof(logBuf), "start heartbeat timer, ms:%d", 1);
|
||||||
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
|
} while (0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1312,6 +1343,8 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) {
|
||||||
atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1);
|
atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1);
|
||||||
taosTmrStop(pSyncNode->pHeartbeatTimer);
|
taosTmrStop(pSyncNode->pHeartbeatTimer);
|
||||||
pSyncNode->pHeartbeatTimer = NULL;
|
pSyncNode->pHeartbeatTimer = NULL;
|
||||||
|
sTrace("vgId:%d, stop heartbeat timer", pSyncNode->vgId);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1559,12 +1592,13 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
|
||||||
", sby:%d, "
|
", sby:%d, "
|
||||||
"stgy:%d, bch:%d, "
|
"stgy:%d, bch:%d, "
|
||||||
"r-num:%d, "
|
"r-num:%d, "
|
||||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d, %s",
|
"lcfg:%" PRId64 ", chging:%d, rsto:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s",
|
||||||
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||||
pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm,
|
pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm,
|
||||||
pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy, pSyncNode->pRaftCfg->batchSize,
|
pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy, pSyncNode->pRaftCfg->batchSize,
|
||||||
pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing,
|
pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing,
|
||||||
pSyncNode->restoreFinish, printStr);
|
pSyncNode->restoreFinish, pSyncNode->electTimerLogicClockUser, pSyncNode->heartbeatTimerLogicClockUser,
|
||||||
|
printStr);
|
||||||
} else {
|
} else {
|
||||||
snprintf(logBuf, sizeof(logBuf), "%s", str);
|
snprintf(logBuf, sizeof(logBuf), "%s", str);
|
||||||
}
|
}
|
||||||
|
@ -1894,7 +1928,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
|
||||||
|
|
||||||
// Raft 3.6.2 Committing entries from previous terms
|
// Raft 3.6.2 Committing entries from previous terms
|
||||||
syncNodeAppendNoop(pSyncNode);
|
syncNodeAppendNoop(pSyncNode);
|
||||||
#if 0 // simon
|
#if 0 // simon
|
||||||
syncNodeReplicate(pSyncNode);
|
syncNodeReplicate(pSyncNode);
|
||||||
#endif
|
#endif
|
||||||
syncMaybeAdvanceCommitIndex(pSyncNode);
|
syncMaybeAdvanceCommitIndex(pSyncNode);
|
||||||
|
|
|
@ -141,7 +141,8 @@ int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode) {
|
||||||
", match-index:%d, raftid:%" PRId64,
|
", match-index:%d, raftid:%" PRId64,
|
||||||
pSyncNode->vgId, nextIndex, newNextIndex, SYNC_INDEX_INVALID, pDestId->addr);
|
pSyncNode->vgId, nextIndex, newNextIndex, SYNC_INDEX_INVALID, pDestId->addr);
|
||||||
|
|
||||||
syncNodeRestartNowHeartbeatTimer(pSyncNode);
|
// syncNodeRestartNowHeartbeatTimer(pSyncNode);
|
||||||
|
syncNodeStartNowHeartbeatTimer(pSyncNode);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,14 +48,16 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) {
|
||||||
} else if (pMsg->timeoutType == SYNC_TIMEOUT_ELECTION) {
|
} else if (pMsg->timeoutType == SYNC_TIMEOUT_ELECTION) {
|
||||||
if (atomic_load_64(&ths->electTimerLogicClockUser) <= pMsg->logicClock) {
|
if (atomic_load_64(&ths->electTimerLogicClockUser) <= pMsg->logicClock) {
|
||||||
++(ths->electTimerCounter);
|
++(ths->electTimerCounter);
|
||||||
sInfo("vgId:%d, sync timeout, type:election count:%d", ths->vgId, ths->electTimerCounter);
|
sInfo("vgId:%d, sync timeout, type:election count:%d, electTimerLogicClockUser:%ld", ths->vgId,
|
||||||
|
ths->electTimerCounter, ths->electTimerLogicClockUser);
|
||||||
syncNodeElect(ths);
|
syncNodeElect(ths);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (pMsg->timeoutType == SYNC_TIMEOUT_HEARTBEAT) {
|
} else if (pMsg->timeoutType == SYNC_TIMEOUT_HEARTBEAT) {
|
||||||
if (atomic_load_64(&ths->heartbeatTimerLogicClockUser) <= pMsg->logicClock) {
|
if (atomic_load_64(&ths->heartbeatTimerLogicClockUser) <= pMsg->logicClock) {
|
||||||
++(ths->heartbeatTimerCounter);
|
++(ths->heartbeatTimerCounter);
|
||||||
sInfo("vgId:%d, sync timeout, type:replicate count:%d", ths->vgId, ths->heartbeatTimerCounter);
|
sInfo("vgId:%d, sync timeout, type:replicate count:%d, heartbeatTimerLogicClockUser:%ld", ths->vgId,
|
||||||
|
ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser);
|
||||||
syncNodeReplicate(ths);
|
syncNodeReplicate(ths);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -125,7 +125,10 @@ int32_t syncUtilRand(int32_t max) { return taosRand() % max; }
|
||||||
|
|
||||||
int32_t syncUtilElectRandomMS(int32_t min, int32_t max) {
|
int32_t syncUtilElectRandomMS(int32_t min, int32_t max) {
|
||||||
ASSERT(min > 0 && max > 0 && max >= min);
|
ASSERT(min > 0 && max > 0 && max >= min);
|
||||||
return min + syncUtilRand(max - min);
|
int32_t rdm = min + syncUtilRand(max - min);
|
||||||
|
|
||||||
|
// sDebug("random min:%d, max:%d, rdm:%d", min, max, rdm);
|
||||||
|
return rdm;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncUtilQuorum(int32_t replicaNum) { return replicaNum / 2 + 1; }
|
int32_t syncUtilQuorum(int32_t replicaNum) { return replicaNum / 2 + 1; }
|
||||||
|
|
|
@ -1339,8 +1339,9 @@ class Task():
|
||||||
0x03A1, # STable [does] not exist
|
0x03A1, # STable [does] not exist
|
||||||
0x03AA, # Tag already exists
|
0x03AA, # Tag already exists
|
||||||
0x0603, # Table already exists
|
0x0603, # Table already exists
|
||||||
0x2603, # Table does not exist
|
0x2603, # Table does not exist, replaced by 2662 below
|
||||||
0x260d, # Tags number not matched
|
0x260d, # Tags number not matched
|
||||||
|
0x2662, # Table does not exist #TODO: what about 2603 above?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,15 +4,15 @@
|
||||||
#include "taosudf.h"
|
#include "taosudf.h"
|
||||||
|
|
||||||
|
|
||||||
DLL_EXPORT int32_t bitwise_and_init() {
|
DLL_EXPORT int32_t bit_and_init() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT int32_t bitwise_and_destroy() {
|
DLL_EXPORT int32_t bit_and_destroy() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT int32_t bitwise_and(SUdfDataBlock* block, SUdfColumn *resultCol) {
|
DLL_EXPORT int32_t bit_and(SUdfDataBlock* block, SUdfColumn *resultCol) {
|
||||||
|
|
||||||
if (block->numOfCols < 2) {
|
if (block->numOfCols < 2) {
|
||||||
return TSDB_CODE_UDF_INVALID_INPUT;
|
return TSDB_CODE_UDF_INVALID_INPUT;
|
||||||
|
@ -37,6 +37,10 @@ DLL_EXPORT int32_t bitwise_and(SUdfDataBlock* block, SUdfColumn *resultCol) {
|
||||||
resultData->numOfRows = block->numOfRows;
|
resultData->numOfRows = block->numOfRows;
|
||||||
|
|
||||||
for (int32_t i = 0; i < resultData->numOfRows; ++i) {
|
for (int32_t i = 0; i < resultData->numOfRows; ++i) {
|
||||||
|
if (udfColDataIsNull(block->udfCols[0], i)) {
|
||||||
|
udfColDataSetNull(resultCol, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int32_t result = *(int32_t*)udfColDataGetData(block->udfCols[0], i);
|
int32_t result = *(int32_t*)udfColDataGetData(block->udfCols[0], i);
|
||||||
int j = 1;
|
int j = 1;
|
||||||
for (; j < block->numOfCols; ++j) {
|
for (; j < block->numOfCols; ++j) {
|
|
@ -0,0 +1,10 @@
|
||||||
|
set +e
|
||||||
|
|
||||||
|
rm -rf /tmp/udf/libbitand.so /tmp/udf/libsqrsum.so
|
||||||
|
mkdir -p /tmp/udf
|
||||||
|
echo "compile udf bit_and and sqr_sum"
|
||||||
|
gcc -fPIC -shared sh/bit_and.c -o /tmp/udf/libbitand.so
|
||||||
|
gcc -fPIC -shared sh/sqr_sum.c -o /tmp/udf/libsqrsum.so
|
||||||
|
echo "debug show /tmp/udf/*.so"
|
||||||
|
ls /tmp/udf/*.so
|
||||||
|
|
|
@ -5,22 +5,22 @@
|
||||||
|
|
||||||
#include "taosudf.h"
|
#include "taosudf.h"
|
||||||
|
|
||||||
DLL_EXPORT int32_t squares_sum_init() {
|
DLL_EXPORT int32_t sqr_sum_init() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT int32_t squares_sum_destroy() {
|
DLL_EXPORT int32_t sqr_sum_destroy() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT int32_t squares_sum_start(SUdfInterBuf *buf) {
|
DLL_EXPORT int32_t sqr_sum_start(SUdfInterBuf *buf) {
|
||||||
*(int64_t*)(buf->buf) = 0;
|
*(int64_t*)(buf->buf) = 0;
|
||||||
buf->bufLen = sizeof(double);
|
buf->bufLen = sizeof(double);
|
||||||
buf->numOfResult = 0;
|
buf->numOfResult = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT int32_t squares_sum(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf) {
|
DLL_EXPORT int32_t sqr_sum(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf) {
|
||||||
double sumSquares = *(double*)interBuf->buf;
|
double sumSquares = *(double*)interBuf->buf;
|
||||||
int8_t numNotNull = 0;
|
int8_t numNotNull = 0;
|
||||||
for (int32_t i = 0; i < block->numOfCols; ++i) {
|
for (int32_t i = 0; i < block->numOfCols; ++i) {
|
||||||
|
@ -67,7 +67,7 @@ DLL_EXPORT int32_t squares_sum(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUd
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT int32_t udf2_finish(SUdfInterBuf* buf, SUdfInterBuf *resultData) {
|
DLL_EXPORT int32_t sqr_sum_finish(SUdfInterBuf* buf, SUdfInterBuf *resultData) {
|
||||||
if (buf->numOfResult == 0) {
|
if (buf->numOfResult == 0) {
|
||||||
resultData->numOfResult = 0;
|
resultData->numOfResult = 0;
|
||||||
return 0;
|
return 0;
|
|
@ -0,0 +1,161 @@
|
||||||
|
system_content printf %OS%
|
||||||
|
if $system_content == Windows_NT then
|
||||||
|
return 0;
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1 -c udf -v 1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print ======== step1 udf
|
||||||
|
system sh/compile_udf.sh
|
||||||
|
sql create database udf vgroups 3;
|
||||||
|
sql use udf;
|
||||||
|
sql show databases;
|
||||||
|
|
||||||
|
sql create table t (ts timestamp, f int);
|
||||||
|
sql insert into t values(now, 1)(now+1s, 2);
|
||||||
|
|
||||||
|
system_content printf %OS%
|
||||||
|
if $system_content == Windows_NT then
|
||||||
|
return 0;
|
||||||
|
endi
|
||||||
|
if $system_content == Windows_NT then
|
||||||
|
sql create function bit_and as 'C:\\Windows\\Temp\\bitand.dll' outputtype int bufSize 8;
|
||||||
|
sql create aggregate function sqr_sum as 'C:\\Windows\\Temp\\sqrsum.dll' outputtype double bufSize 8;
|
||||||
|
else
|
||||||
|
sql create function bit_and as '/tmp/udf/libbitand.so' outputtype int bufSize 8;
|
||||||
|
sql create aggregate function sqr_sum as '/tmp/udf/libsqrsum.so' outputtype double bufSize 8;
|
||||||
|
endi
|
||||||
|
sql show functions;
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql select bit_and(f, f) from t;
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data10 != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sqr_sum(f) from t;
|
||||||
|
if $rows != 1 then
|
||||||
|
print expect 1, actual $rows
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != 2.236067977 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql create table t2 (ts timestamp, f1 int, f2 int);
|
||||||
|
sql insert into t2 values(now, 0, 0)(now+1s, 1, 1);
|
||||||
|
sql select bit_and(f1, f2) from t2;
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != 0 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data10 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sqr_sum(f1, f2) from t2;
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != 1.414213562 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql insert into t2 values(now+2s, 1, null)(now+3s, null, 2);
|
||||||
|
sql select bit_and(f1, f2) from t2;
|
||||||
|
print $rows , $data00 , $data10 , $data20 , $data30
|
||||||
|
if $rows != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != 0 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data10 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data20 != NULL then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data30 != NULL then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sqr_sum(f1, f2) from t2;
|
||||||
|
print $rows, $data00
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != 2.645751311 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql insert into t2 values(now+4s, 4, 8)(now+5s, 5, 9);
|
||||||
|
sql select sqr_sum(f1-f2), sqr_sum(f1+f2) from t2;
|
||||||
|
print $rows , $data00 , $data01
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1;
|
||||||
|
endi
|
||||||
|
if $data00 != 5.656854249 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data01 != 18.547236991 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sqr_sum(bit_and(f2, f1)), sqr_sum(bit_and(f1, f2)) from t2;
|
||||||
|
print $rows , $data00 , $data01
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != 1.414213562 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data01 != 1.414213562 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sqr_sum(f2) from udf.t2 group by 1-bit_and(f1, f2) order by 1-bit_and(f1,f2);
|
||||||
|
print $rows , $data00 , $data10 , $data20
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != 2.000000000 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data10 != 9.055385138 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data20 != 8.000000000 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql drop function bit_and;
|
||||||
|
sql show functions;
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != @sqr_sum@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql drop function sqr_sum;
|
||||||
|
sql show functions;
|
||||||
|
if $rows != 0 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -196,28 +196,28 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeStopFollowerLeader.py -N 5 -M 3
|
||||||
python3 ./test.py -f 6-cluster/5dnode3mnodeStop2Follower.py -N 5 -M 3
|
python3 ./test.py -f 6-cluster/5dnode3mnodeStop2Follower.py -N 5 -M 3
|
||||||
|
|
||||||
# vnode case
|
# vnode case
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_force_stop_all_dnodes.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_force_stop_all_dnodes.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py -N 4 -M 1
|
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_all_dnodes.py -N 4 -M 1
|
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_all_dnodes.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py -N 4 -M 1
|
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py -N 4 -M 1
|
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py -N 4 -M 1
|
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py -N 4 -M 1
|
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py -N 4 -M 1
|
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py -N 4 -M 1
|
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py -N 4 -M 1
|
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py -N 4 -M 1
|
||||||
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py -N 4 -M 1
|
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py -N 4 -M 1
|
||||||
|
|
||||||
|
|
||||||
python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3
|
python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3
|
||||||
|
|
Loading…
Reference in New Issue