Merge branch '3.0' into feature/TD-11463-3.0
This commit is contained in:
commit
ab90c9f5d5
|
@ -377,7 +377,7 @@ void printConf(SRaftServerConfig *pConf) {
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
|
||||||
exe_name = argv[0];
|
exe_name = argv[0];
|
||||||
|
|
|
@ -132,7 +132,7 @@ static void proposeValue(struct raft *r) {
|
||||||
buf.base = raft_malloc(buf.len);
|
buf.base = raft_malloc(buf.len);
|
||||||
|
|
||||||
// mock ts value
|
// mock ts value
|
||||||
int vid = rand() % VNODE_COUNT;
|
int vid = taosRand() % VNODE_COUNT;
|
||||||
snprintf(buf.base, buf.len, "%d:value_%ld", vid, time(NULL));
|
snprintf(buf.base, buf.len, "%d:value_%ld", vid, time(NULL));
|
||||||
|
|
||||||
printf("propose value: %s \n", (char*)buf.base);
|
printf("propose value: %s \n", (char*)buf.base);
|
||||||
|
@ -174,7 +174,7 @@ void usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
|
|
||||||
exe_name = argv[0];
|
exe_name = argv[0];
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ void shuffle(char**lines, size_t n)
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < n - 1; i++)
|
for (i = 0; i < n - 1; i++)
|
||||||
{
|
{
|
||||||
size_t j = i + rand() / (RAND_MAX / (n - i) + 1);
|
size_t j = i + taosRand() / (RAND_MAX / (n - i) + 1);
|
||||||
char* t = lines[j];
|
char* t = lines[j];
|
||||||
lines[j] = lines[i];
|
lines[j] = lines[i];
|
||||||
lines[i] = t;
|
lines[i] = t;
|
||||||
|
|
|
@ -20,7 +20,16 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||||
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
|
#define rand RAND_FUNC_TAOS_FORBID
|
||||||
|
#define srand SRAND_FUNC_TAOS_FORBID
|
||||||
|
#define rand_r RANDR_FUNC_TAOS_FORBID
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void taosSeedRand(uint32_t seed);
|
||||||
uint32_t taosRand(void);
|
uint32_t taosRand(void);
|
||||||
|
uint32_t taosRandR(uint32_t *pSeed);
|
||||||
void taosRandStr(char* str, int32_t size);
|
void taosRandStr(char* str, int32_t size);
|
||||||
uint32_t taosSafeRand(void);
|
uint32_t taosSafeRand(void);
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ void taos_init_imp(void) {
|
||||||
atexit(taos_cleanup);
|
atexit(taos_cleanup);
|
||||||
|
|
||||||
errno = TSDB_CODE_SUCCESS;
|
errno = TSDB_CODE_SUCCESS;
|
||||||
srand(taosGetTimestampSec());
|
taosSeedRand(taosGetTimestampSec());
|
||||||
|
|
||||||
deltaToUtcInitOnce();
|
deltaToUtcInitOnce();
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ typedef struct {
|
||||||
SWalCfg walCfg;
|
SWalCfg walCfg;
|
||||||
uint32_t hashBegin;
|
uint32_t hashBegin;
|
||||||
uint32_t hashEnd;
|
uint32_t hashEnd;
|
||||||
int8_t hashMethod;
|
int8_t hashMethod;
|
||||||
} SVnodeCfg;
|
} SVnodeCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -202,6 +202,22 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
||||||
|
|
||||||
/* ------------------------- TQ READ --------------------------- */
|
/* ------------------------- TQ READ --------------------------- */
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TQ_STREAM_TOKEN__DATA = 1,
|
||||||
|
TQ_STREAM_TOKEN__WATERMARK,
|
||||||
|
TQ_STREAM_TOKEN__CHECKPOINT,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t type;
|
||||||
|
int8_t reserved[7];
|
||||||
|
union {
|
||||||
|
void *data;
|
||||||
|
int64_t wmTs;
|
||||||
|
int64_t checkpointId;
|
||||||
|
};
|
||||||
|
} STqStreamToken;
|
||||||
|
|
||||||
STqReadHandle *tqInitSubmitMsgScanner(SMeta *pMeta);
|
STqReadHandle *tqInitSubmitMsgScanner(SMeta *pMeta);
|
||||||
|
|
||||||
static FORCE_INLINE void tqReadHandleSetColIdList(STqReadHandle *pReadHandle, SArray *pColIdList) {
|
static FORCE_INLINE void tqReadHandleSetColIdList(STqReadHandle *pReadHandle, SArray *pColIdList) {
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
#ifndef _TQ_PUSH_H_
|
#ifndef _TQ_PUSH_H_
|
||||||
#define _TQ_PUSH_H_
|
#define _TQ_PUSH_H_
|
||||||
|
|
||||||
|
#include "executor.h"
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
|
#include "vnode.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -39,11 +41,12 @@ typedef struct {
|
||||||
} STqClientPusher;
|
} STqClientPusher;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
int8_t nodeType;
|
int8_t nodeType;
|
||||||
int8_t reserved[6];
|
int8_t reserved[6];
|
||||||
int64_t streamId;
|
int64_t streamId;
|
||||||
SEpSet epSet;
|
qTaskInfo_t task;
|
||||||
|
// TODO sync function
|
||||||
} STqStreamPusher;
|
} STqStreamPusher;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -67,6 +67,26 @@ void tqClose(STQ* pTq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tqPushMsg(STQ* pTq, void* msg, tmsg_t msgType, int64_t version) {
|
int tqPushMsg(STQ* pTq, void* msg, tmsg_t msgType, int64_t version) {
|
||||||
|
if (msgType != TDMT_VND_SUBMIT) return 0;
|
||||||
|
void* pIter = taosHashIterate(pTq->tqPushMgr->pHash, NULL);
|
||||||
|
while (pIter != NULL) {
|
||||||
|
STqPusher* pusher = *(STqPusher**)pIter;
|
||||||
|
if (pusher->type == TQ_PUSHER_TYPE__STREAM) {
|
||||||
|
STqStreamPusher* streamPusher = (STqStreamPusher*)pusher;
|
||||||
|
// repack
|
||||||
|
STqStreamToken* token = malloc(sizeof(STqStreamToken));
|
||||||
|
if (token == NULL) {
|
||||||
|
taosHashCancelIterate(pTq->tqPushMgr->pHash, pIter);
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
token->type = TQ_STREAM_TOKEN__DATA;
|
||||||
|
token->data = msg;
|
||||||
|
// set input
|
||||||
|
// exec
|
||||||
|
}
|
||||||
|
// send msg to ep
|
||||||
|
}
|
||||||
// iterate hash
|
// iterate hash
|
||||||
// process all msg
|
// process all msg
|
||||||
// if waiting
|
// if waiting
|
||||||
|
|
|
@ -73,7 +73,7 @@ STqStreamPusher* tqAddStreamPusher(STqPushMgr* pushMgr, int64_t streamId, SEpSet
|
||||||
streamPusher->type = TQ_PUSHER_TYPE__STREAM;
|
streamPusher->type = TQ_PUSHER_TYPE__STREAM;
|
||||||
streamPusher->nodeType = 0;
|
streamPusher->nodeType = 0;
|
||||||
streamPusher->streamId = streamId;
|
streamPusher->streamId = streamId;
|
||||||
memcpy(&streamPusher->epSet, pEpSet, sizeof(SEpSet));
|
/*memcpy(&streamPusher->epSet, pEpSet, sizeof(SEpSet));*/
|
||||||
|
|
||||||
if (taosHashPut(pushMgr->pHash, &streamId, sizeof(int64_t), &streamPusher, sizeof(void*)) < 0) {
|
if (taosHashPut(pushMgr->pHash, &streamId, sizeof(int64_t), &streamPusher, sizeof(void*)) < 0) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#define _DEFAULT_SOURCE
|
|
||||||
|
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
|
|
||||||
|
@ -37,6 +36,7 @@ int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t
|
||||||
pMsg->length = htonl(pMsg->length);
|
pMsg->length = htonl(pMsg->length);
|
||||||
pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
||||||
|
|
||||||
|
// iterate and convert
|
||||||
if (tInitSubmitMsgIter(pMsg, &pReadHandle->msgIter) < 0) return -1;
|
if (tInitSubmitMsgIter(pMsg, &pReadHandle->msgIter) < 0) return -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (tGetSubmitMsgNext(&pReadHandle->msgIter, &pReadHandle->pBlock) < 0) return -1;
|
if (tGetSubmitMsgNext(&pReadHandle->msgIter, &pReadHandle->pBlock) < 0) return -1;
|
||||||
|
|
|
@ -168,10 +168,10 @@ TEST_F(TqMetaUpdateAppendTest, intxnPersist) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TqMetaUpdateAppendTest, multiplePage) {
|
TEST_F(TqMetaUpdateAppendTest, multiplePage) {
|
||||||
srand(0);
|
taosSeedRand(0);
|
||||||
std::vector<int> v;
|
std::vector<int> v;
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
v.push_back(rand());
|
v.push_back(taosRand());
|
||||||
Foo foo;
|
Foo foo;
|
||||||
foo.a = v[i];
|
foo.a = v[i];
|
||||||
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
||||||
|
@ -202,10 +202,10 @@ TEST_F(TqMetaUpdateAppendTest, multiplePage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TqMetaUpdateAppendTest, multipleRewrite) {
|
TEST_F(TqMetaUpdateAppendTest, multipleRewrite) {
|
||||||
srand(0);
|
taosSeedRand(0);
|
||||||
std::vector<int> v;
|
std::vector<int> v;
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
v.push_back(rand());
|
v.push_back(taosRand());
|
||||||
Foo foo;
|
Foo foo;
|
||||||
foo.a = v[i];
|
foo.a = v[i];
|
||||||
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
||||||
|
@ -213,14 +213,14 @@ TEST_F(TqMetaUpdateAppendTest, multipleRewrite) {
|
||||||
|
|
||||||
for (int i = 0; i < 500; i++) {
|
for (int i = 0; i < 500; i++) {
|
||||||
tqHandleCommit(pMeta, i);
|
tqHandleCommit(pMeta, i);
|
||||||
v[i] = rand();
|
v[i] = taosRand();
|
||||||
Foo foo;
|
Foo foo;
|
||||||
foo.a = v[i];
|
foo.a = v[i];
|
||||||
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 500; i < 1000; i++) {
|
for (int i = 500; i < 1000; i++) {
|
||||||
v[i] = rand();
|
v[i] = taosRand();
|
||||||
Foo foo;
|
Foo foo;
|
||||||
foo.a = v[i];
|
foo.a = v[i];
|
||||||
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
||||||
|
@ -235,7 +235,7 @@ TEST_F(TqMetaUpdateAppendTest, multipleRewrite) {
|
||||||
ASSERT(pMeta);
|
ASSERT(pMeta);
|
||||||
|
|
||||||
for (int i = 500; i < 1000; i++) {
|
for (int i = 500; i < 1000; i++) {
|
||||||
v[i] = rand();
|
v[i] = taosRand();
|
||||||
Foo foo;
|
Foo foo;
|
||||||
foo.a = v[i];
|
foo.a = v[i];
|
||||||
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
||||||
|
@ -250,10 +250,10 @@ TEST_F(TqMetaUpdateAppendTest, multipleRewrite) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TqMetaUpdateAppendTest, dupCommit) {
|
TEST_F(TqMetaUpdateAppendTest, dupCommit) {
|
||||||
srand(0);
|
taosSeedRand(0);
|
||||||
std::vector<int> v;
|
std::vector<int> v;
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
v.push_back(rand());
|
v.push_back(taosRand());
|
||||||
Foo foo;
|
Foo foo;
|
||||||
foo.a = v[i];
|
foo.a = v[i];
|
||||||
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
tqHandleCopyPut(pMeta, i, &foo, sizeof(Foo));
|
||||||
|
|
|
@ -723,7 +723,7 @@ void *ctgTestGetDbVgroupThread(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctgTestEnableSleep) {
|
if (ctgTestEnableSleep) {
|
||||||
usleep(rand() % 5);
|
usleep(taosRand() % 5);
|
||||||
}
|
}
|
||||||
if (++n % ctgTestPrintNum == 0) {
|
if (++n % ctgTestPrintNum == 0) {
|
||||||
printf("Get:%d\n", n);
|
printf("Get:%d\n", n);
|
||||||
|
@ -747,7 +747,7 @@ void *ctgTestSetSameDbVgroupThread(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctgTestEnableSleep) {
|
if (ctgTestEnableSleep) {
|
||||||
usleep(rand() % 5);
|
usleep(taosRand() % 5);
|
||||||
}
|
}
|
||||||
if (++n % ctgTestPrintNum == 0) {
|
if (++n % ctgTestPrintNum == 0) {
|
||||||
printf("Set:%d\n", n);
|
printf("Set:%d\n", n);
|
||||||
|
@ -771,7 +771,7 @@ void *ctgTestSetDiffDbVgroupThread(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctgTestEnableSleep) {
|
if (ctgTestEnableSleep) {
|
||||||
usleep(rand() % 5);
|
usleep(taosRand() % 5);
|
||||||
}
|
}
|
||||||
if (++n % ctgTestPrintNum == 0) {
|
if (++n % ctgTestPrintNum == 0) {
|
||||||
printf("Set:%d\n", n);
|
printf("Set:%d\n", n);
|
||||||
|
@ -801,7 +801,7 @@ void *ctgTestGetCtableMetaThread(void *param) {
|
||||||
tfree(tbMeta);
|
tfree(tbMeta);
|
||||||
|
|
||||||
if (ctgTestEnableSleep) {
|
if (ctgTestEnableSleep) {
|
||||||
usleep(rand() % 5);
|
usleep(taosRand() % 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++n % ctgTestPrintNum == 0) {
|
if (++n % ctgTestPrintNum == 0) {
|
||||||
|
@ -838,7 +838,7 @@ void *ctgTestSetCtableMetaThread(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctgTestEnableSleep) {
|
if (ctgTestEnableSleep) {
|
||||||
usleep(rand() % 5);
|
usleep(taosRand() % 5);
|
||||||
}
|
}
|
||||||
if (++n % ctgTestPrintNum == 0) {
|
if (++n % ctgTestPrintNum == 0) {
|
||||||
printf("Set:%d\n", n);
|
printf("Set:%d\n", n);
|
||||||
|
|
|
@ -61,7 +61,7 @@ typedef enum SResultTsInterpType {
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static UNUSED_FUNC void *u_malloc (size_t __size) {
|
static UNUSED_FUNC void *u_malloc (size_t __size) {
|
||||||
uint32_t v = rand();
|
uint32_t v = taosRand();
|
||||||
|
|
||||||
if (v % 1000 <= 0) {
|
if (v % 1000 <= 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -71,7 +71,7 @@ static UNUSED_FUNC void *u_malloc (size_t __size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
|
static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
|
||||||
uint32_t v = rand();
|
uint32_t v = taosRand();
|
||||||
if (v % 1000 <= 0) {
|
if (v % 1000 <= 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -80,7 +80,7 @@ static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
|
static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
|
||||||
uint32_t v = rand();
|
uint32_t v = taosRand();
|
||||||
if (v % 5 <= 1) {
|
if (v % 5 <= 1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -869,7 +869,7 @@ TEST(testCase, external_sort_Test) {
|
||||||
#if 0
|
#if 0
|
||||||
su* v = static_cast<su*>(calloc(1000000, sizeof(su)));
|
su* v = static_cast<su*>(calloc(1000000, sizeof(su)));
|
||||||
for(int32_t i = 0; i < 1000000; ++i) {
|
for(int32_t i = 0; i < 1000000; ++i) {
|
||||||
v[i].v = rand();
|
v[i].v = taosRand();
|
||||||
v[i].c = static_cast<char*>(malloc(4));
|
v[i].c = static_cast<char*>(malloc(4));
|
||||||
*(int32_t*) v[i].c = i;
|
*(int32_t*) v[i].c = i;
|
||||||
}
|
}
|
||||||
|
@ -882,7 +882,7 @@ TEST(testCase, external_sort_Test) {
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
|
|
||||||
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
||||||
SOrder o = {0};
|
SOrder o = {0};
|
||||||
|
@ -943,7 +943,7 @@ TEST(testCase, external_sort_Test) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, sorted_merge_Test) {
|
TEST(testCase, sorted_merge_Test) {
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
|
|
||||||
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
||||||
SOrder o = {0};
|
SOrder o = {0};
|
||||||
|
@ -1015,7 +1015,7 @@ TEST(testCase, sorted_merge_Test) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, time_interval_Operator_Test) {
|
TEST(testCase, time_interval_Operator_Test) {
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
|
|
||||||
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
|
||||||
SOrder o = {0};
|
SOrder o = {0};
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
|
||||||
TEST(testCase, linear_hash_Tests) {
|
TEST(testCase, linear_hash_Tests) {
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
|
|
||||||
_hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
|
_hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -699,7 +699,7 @@ class IndexObj {
|
||||||
for (int i = 0; i < numOfTable; i++) {
|
for (int i = 0; i < numOfTable; i++) {
|
||||||
for (int k = 0; k < 10 && k < colVal.size(); k++) {
|
for (int k = 0; k < 10 && k < colVal.size(); k++) {
|
||||||
// opt
|
// opt
|
||||||
tColVal[rand() % colValSize] = 'a' + k % 26;
|
tColVal[taosRand() % colValSize] = 'a' + k % 26;
|
||||||
}
|
}
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
tColVal.c_str(), tColVal.size());
|
tColVal.c_str(), tColVal.size());
|
||||||
|
|
|
@ -266,7 +266,7 @@ int32_t qwtCreateExecTask(void* tsdb, int32_t vgId, struct SSubplan* pPlan, qTas
|
||||||
int32_t idx = abs((++qwtTestCaseIdx) % qwtTestCaseNum);
|
int32_t idx = abs((++qwtTestCaseIdx) % qwtTestCaseNum);
|
||||||
|
|
||||||
qwtTestSinkBlockNum = 0;
|
qwtTestSinkBlockNum = 0;
|
||||||
qwtTestSinkMaxBlockNum = rand() % 100 + 1;
|
qwtTestSinkMaxBlockNum = taosRand() % 100 + 1;
|
||||||
qwtTestSinkQueryEnd = false;
|
qwtTestSinkQueryEnd = false;
|
||||||
|
|
||||||
if (0 == idx) {
|
if (0 == idx) {
|
||||||
|
@ -295,15 +295,15 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
|
||||||
} else {
|
} else {
|
||||||
if (qwtTestSinkQueryEnd) {
|
if (qwtTestSinkQueryEnd) {
|
||||||
*pRes = NULL;
|
*pRes = NULL;
|
||||||
*useconds = rand() % 10;
|
*useconds = taosRand() % 10;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
endExec = rand() % 5;
|
endExec = taosRand() % 5;
|
||||||
|
|
||||||
int32_t runTime = 0;
|
int32_t runTime = 0;
|
||||||
if (qwtTestEnableSleep && qwtTestMaxExecTaskUsec > 0) {
|
if (qwtTestEnableSleep && qwtTestMaxExecTaskUsec > 0) {
|
||||||
runTime = rand() % qwtTestMaxExecTaskUsec;
|
runTime = taosRand() % qwtTestMaxExecTaskUsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
|
@ -314,10 +314,10 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
|
||||||
|
|
||||||
if (endExec) {
|
if (endExec) {
|
||||||
*pRes = (SSDataBlock*)calloc(1, sizeof(SSDataBlock));
|
*pRes = (SSDataBlock*)calloc(1, sizeof(SSDataBlock));
|
||||||
(*pRes)->info.rows = rand() % 1000;
|
(*pRes)->info.rows = taosRand() % 1000;
|
||||||
} else {
|
} else {
|
||||||
*pRes = NULL;
|
*pRes = NULL;
|
||||||
*useconds = rand() % 10;
|
*useconds = taosRand() % 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ void qwtGetDataLength(DataSinkHandle handle, int32_t* pLen, bool* pQueryEnd) {
|
||||||
|
|
||||||
taosWLockLatch(&qwtTestSinkLock);
|
taosWLockLatch(&qwtTestSinkLock);
|
||||||
if (qwtTestSinkBlockNum > 0) {
|
if (qwtTestSinkBlockNum > 0) {
|
||||||
*pLen = rand() % 100 + 1;
|
*pLen = taosRand() % 100 + 1;
|
||||||
qwtTestSinkBlockNum--;
|
qwtTestSinkBlockNum--;
|
||||||
} else {
|
} else {
|
||||||
*pLen = 0;
|
*pLen = 0;
|
||||||
|
@ -392,7 +392,7 @@ void qwtGetDataLength(DataSinkHandle handle, int32_t* pLen, bool* pQueryEnd) {
|
||||||
int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
|
int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
|
||||||
taosWLockLatch(&qwtTestSinkLock);
|
taosWLockLatch(&qwtTestSinkLock);
|
||||||
if (qwtTestSinkLastLen > 0) {
|
if (qwtTestSinkLastLen > 0) {
|
||||||
pOutput->numOfRows = rand() % 10 + 1;
|
pOutput->numOfRows = taosRand() % 10 + 1;
|
||||||
pOutput->compressed = 1;
|
pOutput->compressed = 1;
|
||||||
pOutput->queryEnd = qwtTestSinkQueryEnd;
|
pOutput->queryEnd = qwtTestSinkQueryEnd;
|
||||||
if (qwtTestSinkBlockNum == 0) {
|
if (qwtTestSinkBlockNum == 0) {
|
||||||
|
@ -402,7 +402,7 @@ int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
|
||||||
} else {
|
} else {
|
||||||
pOutput->bufStatus = DS_BUF_FULL;
|
pOutput->bufStatus = DS_BUF_FULL;
|
||||||
}
|
}
|
||||||
pOutput->useconds = rand() % 10 + 1;
|
pOutput->useconds = taosRand() % 10 + 1;
|
||||||
pOutput->precision = 1;
|
pOutput->precision = 1;
|
||||||
} else if (qwtTestSinkLastLen == 0) {
|
} else if (qwtTestSinkLastLen == 0) {
|
||||||
pOutput->numOfRows = 0;
|
pOutput->numOfRows = 0;
|
||||||
|
@ -416,7 +416,7 @@ int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
|
||||||
} else {
|
} else {
|
||||||
pOutput->bufStatus = DS_BUF_FULL;
|
pOutput->bufStatus = DS_BUF_FULL;
|
||||||
}
|
}
|
||||||
pOutput->useconds = rand() % 10 + 1;
|
pOutput->useconds = taosRand() % 10 + 1;
|
||||||
pOutput->precision = 1;
|
pOutput->precision = 1;
|
||||||
} else {
|
} else {
|
||||||
assert(0);
|
assert(0);
|
||||||
|
@ -590,7 +590,7 @@ void *queryThread(void *param) {
|
||||||
qwtBuildQueryReqMsg(&queryRpc);
|
qwtBuildQueryReqMsg(&queryRpc);
|
||||||
qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
|
qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
usleep(rand()%5);
|
usleep(taosRand()%5);
|
||||||
}
|
}
|
||||||
if (++n % qwtTestPrintNum == 0) {
|
if (++n % qwtTestPrintNum == 0) {
|
||||||
printf("query:%d\n", n);
|
printf("query:%d\n", n);
|
||||||
|
@ -612,7 +612,7 @@ void *readyThread(void *param) {
|
||||||
qwtBuildReadyReqMsg(&readyMsg, &readyRpc);
|
qwtBuildReadyReqMsg(&readyMsg, &readyRpc);
|
||||||
code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
|
code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
usleep(rand()%5);
|
usleep(taosRand()%5);
|
||||||
}
|
}
|
||||||
if (++n % qwtTestPrintNum == 0) {
|
if (++n % qwtTestPrintNum == 0) {
|
||||||
printf("ready:%d\n", n);
|
printf("ready:%d\n", n);
|
||||||
|
@ -634,7 +634,7 @@ void *fetchThread(void *param) {
|
||||||
qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc);
|
qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc);
|
||||||
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc);
|
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
usleep(rand()%5);
|
usleep(taosRand()%5);
|
||||||
}
|
}
|
||||||
if (++n % qwtTestPrintNum == 0) {
|
if (++n % qwtTestPrintNum == 0) {
|
||||||
printf("fetch:%d\n", n);
|
printf("fetch:%d\n", n);
|
||||||
|
@ -656,7 +656,7 @@ void *dropThread(void *param) {
|
||||||
qwtBuildDropReqMsg(&dropMsg, &dropRpc);
|
qwtBuildDropReqMsg(&dropMsg, &dropRpc);
|
||||||
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
|
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
usleep(rand()%5);
|
usleep(taosRand()%5);
|
||||||
}
|
}
|
||||||
if (++n % qwtTestPrintNum == 0) {
|
if (++n % qwtTestPrintNum == 0) {
|
||||||
printf("drop:%d\n", n);
|
printf("drop:%d\n", n);
|
||||||
|
@ -678,7 +678,7 @@ void *statusThread(void *param) {
|
||||||
qwtBuildStatusReqMsg(&statusMsg, &statusRpc);
|
qwtBuildStatusReqMsg(&statusMsg, &statusRpc);
|
||||||
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
|
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
|
||||||
if (qwtTestEnableSleep) {
|
if (qwtTestEnableSleep) {
|
||||||
usleep(rand()%5);
|
usleep(taosRand()%5);
|
||||||
}
|
}
|
||||||
if (++n % qwtTestPrintNum == 0) {
|
if (++n % qwtTestPrintNum == 0) {
|
||||||
printf("status:%d\n", n);
|
printf("status:%d\n", n);
|
||||||
|
@ -748,7 +748,7 @@ void *queryQueueThread(void *param) {
|
||||||
|
|
||||||
|
|
||||||
if (qwtTestEnableSleep && qwtTestReqMaxDelayUsec > 0) {
|
if (qwtTestEnableSleep && qwtTestReqMaxDelayUsec > 0) {
|
||||||
int32_t delay = rand() % qwtTestReqMaxDelayUsec;
|
int32_t delay = taosRand() % qwtTestReqMaxDelayUsec;
|
||||||
|
|
||||||
if (delay) {
|
if (delay) {
|
||||||
usleep(delay);
|
usleep(delay);
|
||||||
|
@ -804,7 +804,7 @@ void *fetchQueueThread(void *param) {
|
||||||
taosWUnLockLatch(&qwtTestFetchQueueLock);
|
taosWUnLockLatch(&qwtTestFetchQueueLock);
|
||||||
|
|
||||||
if (qwtTestEnableSleep && qwtTestReqMaxDelayUsec > 0) {
|
if (qwtTestEnableSleep && qwtTestReqMaxDelayUsec > 0) {
|
||||||
int32_t delay = rand() % qwtTestReqMaxDelayUsec;
|
int32_t delay = taosRand() % qwtTestReqMaxDelayUsec;
|
||||||
|
|
||||||
if (delay) {
|
if (delay) {
|
||||||
usleep(delay);
|
usleep(delay);
|
||||||
|
@ -963,7 +963,7 @@ TEST(seqTest, randCase) {
|
||||||
stubSetRpcSendResponse();
|
stubSetRpcSendResponse();
|
||||||
stubSetCreateExecTask();
|
stubSetCreateExecTask();
|
||||||
|
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
@ -971,7 +971,7 @@ TEST(seqTest, randCase) {
|
||||||
int32_t t = 0;
|
int32_t t = 0;
|
||||||
int32_t maxr = 10001;
|
int32_t maxr = 10001;
|
||||||
while (true) {
|
while (true) {
|
||||||
int32_t r = rand() % maxr;
|
int32_t r = taosRand() % maxr;
|
||||||
|
|
||||||
if (r >= 0 && r < maxr/5) {
|
if (r >= 0 && r < maxr/5) {
|
||||||
printf("Query,%d\n", t++);
|
printf("Query,%d\n", t++);
|
||||||
|
@ -1025,7 +1025,7 @@ TEST(seqTest, multithreadRand) {
|
||||||
stubSetStringToPlan();
|
stubSetStringToPlan();
|
||||||
stubSetRpcSendResponse();
|
stubSetRpcSendResponse();
|
||||||
|
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
@ -1076,7 +1076,7 @@ TEST(rcTest, shortExecshortDelay) {
|
||||||
stubSetPutDataBlock();
|
stubSetPutDataBlock();
|
||||||
stubSetGetDataBlock();
|
stubSetGetDataBlock();
|
||||||
|
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
qwtTestStop = false;
|
qwtTestStop = false;
|
||||||
qwtTestQuitThreadNum = 0;
|
qwtTestQuitThreadNum = 0;
|
||||||
|
|
||||||
|
@ -1157,7 +1157,7 @@ TEST(rcTest, longExecshortDelay) {
|
||||||
stubSetPutDataBlock();
|
stubSetPutDataBlock();
|
||||||
stubSetGetDataBlock();
|
stubSetGetDataBlock();
|
||||||
|
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
qwtTestStop = false;
|
qwtTestStop = false;
|
||||||
qwtTestQuitThreadNum = 0;
|
qwtTestQuitThreadNum = 0;
|
||||||
|
|
||||||
|
@ -1240,7 +1240,7 @@ TEST(rcTest, shortExeclongDelay) {
|
||||||
stubSetPutDataBlock();
|
stubSetPutDataBlock();
|
||||||
stubSetGetDataBlock();
|
stubSetGetDataBlock();
|
||||||
|
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
qwtTestStop = false;
|
qwtTestStop = false;
|
||||||
qwtTestQuitThreadNum = 0;
|
qwtTestQuitThreadNum = 0;
|
||||||
|
|
||||||
|
@ -1324,7 +1324,7 @@ TEST(rcTest, dropTest) {
|
||||||
stubSetPutDataBlock();
|
stubSetPutDataBlock();
|
||||||
stubSetGetDataBlock();
|
stubSetGetDataBlock();
|
||||||
|
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
|
|
||||||
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
@ -1358,7 +1358,7 @@ TEST(rcTest, dropTest) {
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1286,7 +1286,7 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) {
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1427,7 +1427,7 @@ TEST(columnTest, greater_and_lower) {
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,7 +532,7 @@ void* schtRunJobThread(void *aa) {
|
||||||
|
|
||||||
void* schtFreeJobThread(void *aa) {
|
void* schtFreeJobThread(void *aa) {
|
||||||
while (!schtTestStop) {
|
while (!schtTestStop) {
|
||||||
usleep(rand() % 100);
|
usleep(taosRand() % 100);
|
||||||
schtFreeQueryJob(1);
|
schtFreeQueryJob(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -713,7 +713,7 @@ TEST(multiThread, forceFree) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ static void doSyncEnvStopTimer(SSyncEnv *pSyncEnv, tmr_h *pTimer);
|
||||||
|
|
||||||
int32_t syncEnvStart() {
|
int32_t syncEnvStart() {
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
gSyncEnv = (SSyncEnv *)malloc(sizeof(SSyncEnv));
|
gSyncEnv = (SSyncEnv *)malloc(sizeof(SSyncEnv));
|
||||||
assert(gSyncEnv != NULL);
|
assert(gSyncEnv != NULL);
|
||||||
ret = doSyncEnvStart(gSyncEnv);
|
ret = doSyncEnvStart(gSyncEnv);
|
||||||
|
|
|
@ -44,7 +44,7 @@ int32_t syncIOStart(char *host, uint16_t port) {
|
||||||
gSyncIO = syncIOCreate(host, port);
|
gSyncIO = syncIOCreate(host, port);
|
||||||
assert(gSyncIO != NULL);
|
assert(gSyncIO != NULL);
|
||||||
|
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
int32_t ret = syncIOStartInternal(gSyncIO);
|
int32_t ret = syncIOStartInternal(gSyncIO);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ void syncUtilbufCopyDeep(const SSyncBuffer* src, SSyncBuffer* dest) {
|
||||||
|
|
||||||
// ---- misc ----
|
// ---- misc ----
|
||||||
|
|
||||||
int32_t syncUtilRand(int32_t max) { return rand() % max; }
|
int32_t syncUtilRand(int32_t max) { return taosRand() % max; }
|
||||||
|
|
||||||
int32_t syncUtilElectRandomMS() { return ELECT_TIMER_MS_MIN + syncUtilRand(ELECT_TIMER_MS_RANGE); }
|
int32_t syncUtilElectRandomMS() { return ELECT_TIMER_MS_MIN + syncUtilRand(ELECT_TIMER_MS_RANGE); }
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
|
||||||
((uint64_t *)fileid)[0] = stDev;
|
((uint64_t *)fileid)[0] = stDev;
|
||||||
((uint64_t *)fileid)[1] = stIno;
|
((uint64_t *)fileid)[1] = stIno;
|
||||||
if (unique) {
|
if (unique) {
|
||||||
((uint64_t *)fileid)[2] = rand();
|
((uint64_t *)fileid)[2] = taosRand();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -749,7 +749,7 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
|
||||||
memcpy(pConn->user, pHead->user, tListLen(pConn->user));
|
memcpy(pConn->user, pHead->user, tListLen(pConn->user));
|
||||||
pConn->pRpc = pRpc;
|
pConn->pRpc = pRpc;
|
||||||
pConn->sid = sid;
|
pConn->sid = sid;
|
||||||
pConn->tranId = (uint16_t)(rand() & 0xFFFF);
|
pConn->tranId = (uint16_t)(taosRand() & 0xFFFF);
|
||||||
pConn->ownId = htonl(pConn->sid);
|
pConn->ownId = htonl(pConn->sid);
|
||||||
pConn->linkUid = pHead->linkUid;
|
pConn->linkUid = pHead->linkUid;
|
||||||
if (pRpc->afp) {
|
if (pRpc->afp) {
|
||||||
|
|
|
@ -34,9 +34,6 @@ int32_t walCommit(SWal *pWal, int64_t ver) {
|
||||||
int32_t walRollback(SWal *pWal, int64_t ver) {
|
int32_t walRollback(SWal *pWal, int64_t ver) {
|
||||||
int code;
|
int code;
|
||||||
char fnameStr[WAL_FILE_LEN];
|
char fnameStr[WAL_FILE_LEN];
|
||||||
if (ver == pWal->vers.lastVer) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (ver > pWal->vers.lastVer || ver < pWal->vers.commitVer) {
|
if (ver > pWal->vers.lastVer || ver < pWal->vers.commitVer) {
|
||||||
terrno = TSDB_CODE_WAL_INVALID_VER;
|
terrno = TSDB_CODE_WAL_INVALID_VER;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -124,13 +124,8 @@ class WalRetentionEnv : public ::testing::Test {
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
SWalCfg cfg;
|
SWalCfg cfg;
|
||||||
cfg.rollPeriod = -1,
|
cfg.rollPeriod = -1, cfg.segSize = -1, cfg.retentionPeriod = -1, cfg.retentionSize = 0, cfg.rollPeriod = 0,
|
||||||
cfg.segSize = -1,
|
cfg.vgId = 0, cfg.level = TAOS_WAL_FSYNC;
|
||||||
cfg.retentionPeriod = -1,
|
|
||||||
cfg.retentionSize = 0,
|
|
||||||
cfg.rollPeriod = 0,
|
|
||||||
cfg.vgId = 0,
|
|
||||||
cfg.level = TAOS_WAL_FSYNC;
|
|
||||||
pWal = walOpen(pathName, &cfg);
|
pWal = walOpen(pathName, &cfg);
|
||||||
ASSERT(pWal != NULL);
|
ASSERT(pWal != NULL);
|
||||||
}
|
}
|
||||||
|
@ -241,6 +236,12 @@ TEST_F(WalCleanEnv, rollback) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(pWal->vers.lastVer, i);
|
ASSERT_EQ(pWal->vers.lastVer, i);
|
||||||
}
|
}
|
||||||
|
code = walRollback(pWal, 12);
|
||||||
|
ASSERT_NE(code, 0);
|
||||||
|
ASSERT_EQ(pWal->vers.lastVer, 9);
|
||||||
|
code = walRollback(pWal, 9);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
ASSERT_EQ(pWal->vers.lastVer, 8);
|
||||||
code = walRollback(pWal, 5);
|
code = walRollback(pWal, 5);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(pWal->vers.lastVer, 4);
|
ASSERT_EQ(pWal->vers.lastVer, 4);
|
||||||
|
@ -299,7 +300,7 @@ TEST_F(WalKeepEnv, readHandleRead) {
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
int ver = rand() % 100;
|
int ver = taosRand() % 100;
|
||||||
code = walReadWithHandle(pRead, ver);
|
code = walReadWithHandle(pRead, ver);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -324,7 +325,7 @@ TEST_F(WalKeepEnv, readHandleRead) {
|
||||||
TEST_F(WalRetentionEnv, repairMeta1) {
|
TEST_F(WalRetentionEnv, repairMeta1) {
|
||||||
walResetEnv();
|
walResetEnv();
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 100; i++) {
|
for (i = 0; i < 100; i++) {
|
||||||
char newStr[100];
|
char newStr[100];
|
||||||
|
@ -336,14 +337,14 @@ TEST_F(WalRetentionEnv, repairMeta1) {
|
||||||
|
|
||||||
TearDown();
|
TearDown();
|
||||||
|
|
||||||
//getchar();
|
// getchar();
|
||||||
char buf[100];
|
char buf[100];
|
||||||
sprintf(buf, "%s/meta-ver%d", pathName, 0);
|
sprintf(buf, "%s/meta-ver%d", pathName, 0);
|
||||||
taosRemoveFile(buf);
|
taosRemoveFile(buf);
|
||||||
sprintf(buf, "%s/meta-ver%d", pathName, 1);
|
sprintf(buf, "%s/meta-ver%d", pathName, 1);
|
||||||
taosRemoveFile(buf);
|
taosRemoveFile(buf);
|
||||||
SetUp();
|
SetUp();
|
||||||
//getchar();
|
// getchar();
|
||||||
|
|
||||||
ASSERT_EQ(pWal->vers.lastVer, 99);
|
ASSERT_EQ(pWal->vers.lastVer, 99);
|
||||||
|
|
||||||
|
@ -351,7 +352,7 @@ TEST_F(WalRetentionEnv, repairMeta1) {
|
||||||
ASSERT(pRead != NULL);
|
ASSERT(pRead != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
int ver = rand() % 100;
|
int ver = taosRand() % 100;
|
||||||
code = walReadWithHandle(pRead, ver);
|
code = walReadWithHandle(pRead, ver);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -381,7 +382,7 @@ TEST_F(WalRetentionEnv, repairMeta1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
int ver = rand() % 200;
|
int ver = taosRand() % 200;
|
||||||
code = walReadWithHandle(pRead, ver);
|
code = walReadWithHandle(pRead, ver);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
@ -401,5 +402,4 @@ TEST_F(WalRetentionEnv, repairMeta1) {
|
||||||
EXPECT_EQ(newStr[j], pRead->pHead->head.body[j]);
|
EXPECT_EQ(newStr[j], pRead->pHead->head.body[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ float tsNumOfCores = 0;
|
||||||
int64_t tsTotalMemoryKB = 0;
|
int64_t tsTotalMemoryKB = 0;
|
||||||
|
|
||||||
void osInit() {
|
void osInit() {
|
||||||
srand(taosSafeRand());
|
taosSeedRand(taosSafeRand());
|
||||||
taosGetSystemLocale(tsLocale, tsCharset);
|
taosGetSystemLocale(tsLocale, tsCharset);
|
||||||
taosGetSystemTimezone(tsTimezone);
|
taosGetSystemTimezone(tsTimezone);
|
||||||
taosSetSystemTimezone(tsTimezone, tsTimezone, &tsDaylight);
|
taosSetSystemTimezone(tsTimezone, tsTimezone, &tsDaylight);
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#define ALLOW_FORBID_FUNC
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
|
@ -21,8 +21,12 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void taosSeedRand(uint32_t seed) { return srand(seed); }
|
||||||
|
|
||||||
uint32_t taosRand(void) { return rand(); }
|
uint32_t taosRand(void) { return rand(); }
|
||||||
|
|
||||||
|
uint32_t taosRandR(uint32_t *pSeed) { return rand_r(pSeed); }
|
||||||
|
|
||||||
uint32_t taosSafeRand(void) {
|
uint32_t taosSafeRand(void) {
|
||||||
TdFilePtr pFile;
|
TdFilePtr pFile;
|
||||||
int seed;
|
int seed;
|
||||||
|
|
|
@ -32,7 +32,7 @@ void process_message(uint8_t* message_piece, uint8_t* processed_piece, key_set*
|
||||||
#if 0
|
#if 0
|
||||||
int64_t taosDesGenKey() {
|
int64_t taosDesGenKey() {
|
||||||
uint32_t iseed = (uint32_t)time(NULL);
|
uint32_t iseed = (uint32_t)time(NULL);
|
||||||
srand(iseed);
|
taosSeedRand(iseed);
|
||||||
|
|
||||||
uint8_t key[8] = {0};
|
uint8_t key[8] = {0};
|
||||||
generate_key(key);
|
generate_key(key);
|
||||||
|
|
|
@ -51,7 +51,7 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _
|
||||||
pSkipList->len = keyLen;
|
pSkipList->len = keyLen;
|
||||||
pSkipList->flags = flags;
|
pSkipList->flags = flags;
|
||||||
pSkipList->keyFn = fn;
|
pSkipList->keyFn = fn;
|
||||||
pSkipList->seed = rand();
|
pSkipList->seed = taosRand();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// the function getkeycomparfunc is defined in common
|
// the function getkeycomparfunc is defined in common
|
||||||
|
@ -82,7 +82,7 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srand((uint32_t)time(NULL));
|
taosSeedRand((uint32_t)time(NULL));
|
||||||
|
|
||||||
#if SKIP_LIST_RECORD_PERFORMANCE
|
#if SKIP_LIST_RECORD_PERFORMANCE
|
||||||
pSkipList->state.nTotalMemSize += sizeof(SSkipList);
|
pSkipList->state.nTotalMemSize += sizeof(SSkipList);
|
||||||
|
@ -560,9 +560,9 @@ static FORCE_INLINE int32_t getSkipListNodeRandomHeight(SSkipList *pSkipList) {
|
||||||
|
|
||||||
int32_t n = 1;
|
int32_t n = 1;
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
while ((rand() % factor) == 0 && n <= pSkipList->maxLevel) {
|
while ((taosRand() % factor) == 0 && n <= pSkipList->maxLevel) {
|
||||||
#else
|
#else
|
||||||
while ((rand_r(&(pSkipList->seed)) % factor) == 0 && n <= pSkipList->maxLevel) {
|
while ((taosRandR(&(pSkipList->seed)) % factor) == 0 && n <= pSkipList->maxLevel) {
|
||||||
#endif
|
#endif
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ static bool test_variant_int64(int64_t value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(codingTest, fixed_encode_decode) {
|
TEST(codingTest, fixed_encode_decode) {
|
||||||
srand(time(0));
|
taosSeedRand(time(0));
|
||||||
|
|
||||||
// uint16_t
|
// uint16_t
|
||||||
for (uint16_t value = 0; value <= UINT16_MAX; value++) {
|
for (uint16_t value = 0; value <= UINT16_MAX; value++) {
|
||||||
|
@ -204,7 +204,7 @@ TEST(codingTest, fixed_encode_decode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(codingTest, variant_encode_decode) {
|
TEST(codingTest, variant_encode_decode) {
|
||||||
srand(time(0));
|
taosSeedRand(time(0));
|
||||||
|
|
||||||
// uint16_t
|
// uint16_t
|
||||||
for (uint16_t value = 0; value <= UINT16_MAX; value++) {
|
for (uint16_t value = 0; value <= UINT16_MAX; value++) {
|
||||||
|
|
|
@ -161,7 +161,7 @@ void recyclePageTest() {
|
||||||
|
|
||||||
|
|
||||||
TEST(testCase, resultBufferTest) {
|
TEST(testCase, resultBufferTest) {
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
simpleTest();
|
simpleTest();
|
||||||
writeDownTest();
|
writeDownTest();
|
||||||
recyclePageTest();
|
recyclePageTest();
|
||||||
|
|
|
@ -47,7 +47,7 @@ void doubleSkipListTest() {
|
||||||
SSkipListKey sk;
|
SSkipListKey sk;
|
||||||
for (int32_t i = 0; i < 100; ++i) {
|
for (int32_t i = 0; i < 100; ++i) {
|
||||||
sk.nType = TSDB_DATA_TYPE_DOUBLE;
|
sk.nType = TSDB_DATA_TYPE_DOUBLE;
|
||||||
int32_t idx = abs((i * rand()) % 1000);
|
int32_t idx = abs((i * taosRand()) % 1000);
|
||||||
|
|
||||||
sk.dKey = doubleVal[idx];
|
sk.dKey = doubleVal[idx];
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ void randKeyTest() {
|
||||||
false, getkey);
|
false, getkey);
|
||||||
|
|
||||||
int32_t size = 200000;
|
int32_t size = 200000;
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
|
|
||||||
printf("generated %d keys is: \n", size);
|
printf("generated %d keys is: \n", size);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ void randKeyTest() {
|
||||||
d->level = level;
|
d->level = level;
|
||||||
|
|
||||||
int32_t* key = (int32_t*)SL_GET_NODE_KEY(pSkipList, d);
|
int32_t* key = (int32_t*)SL_GET_NODE_KEY(pSkipList, d);
|
||||||
key[0] = rand() % 1000000000;
|
key[0] = taosRand() % 1000000000;
|
||||||
|
|
||||||
key[1] = key[0];
|
key[1] = key[0];
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ void duplicatedKeyTest() {
|
||||||
|
|
||||||
TEST(testCase, skiplist_test) {
|
TEST(testCase, skiplist_test) {
|
||||||
assert(sizeof(SSkipListKey) == 8);
|
assert(sizeof(SSkipListKey) == 8);
|
||||||
srand(time(NULL));
|
taosSeedRand(time(NULL));
|
||||||
|
|
||||||
stringKeySkiplistTest();
|
stringKeySkiplistTest();
|
||||||
doubleSkipListTest();
|
doubleSkipListTest();
|
||||||
|
|
Loading…
Reference in New Issue