rebuild index at tag0

This commit is contained in:
yihaoDeng 2023-08-15 00:40:12 +00:00
parent 3067417ea3
commit 1447d1d55c
3 changed files with 18 additions and 5 deletions

View File

@ -32,6 +32,8 @@ void taosSeedRand(uint32_t seed);
uint32_t taosRand(void); uint32_t taosRand(void);
uint32_t taosRandR(uint32_t* pSeed); uint32_t taosRandR(uint32_t* pSeed);
void taosRandStr(char* str, int32_t size); void taosRandStr(char* str, int32_t size);
void taosRandStr2(char* str, int32_t size);
uint32_t taosSafeRand(void); uint32_t taosSafeRand(void);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -866,8 +866,10 @@ static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCrea
mInfo("trans:%d, used to create stb:%s", pTrans->id, pCreate->name); mInfo("trans:%d, used to create stb:%s", pTrans->id, pCreate->name);
if (mndBuildStbFromReq(pMnode, &stbObj, pCreate, pDb) != 0) goto _OVER; if (mndBuildStbFromReq(pMnode, &stbObj, pCreate, pDb) != 0) goto _OVER;
char randStr[16] = {0};
taosRandStr2(randStr, tListLen(randStr) - 1);
SSchema *pSchema = &(stbObj.pTags[0]); SSchema *pSchema = &(stbObj.pTags[0]);
sprintf(fullIdxName, "%s.%s_default", pDb->name, pSchema->name); sprintf(fullIdxName, "%s.%s_%s", pDb->name, pSchema->name, randStr);
SSIdx idx = {0}; SSIdx idx = {0};
if (mndAcquireGlobalIdx(pMnode, fullIdxName, SDB_IDX, &idx) == 0 && idx.pIdx != NULL) { if (mndAcquireGlobalIdx(pMnode, fullIdxName, SDB_IDX, &idx) == 0 && idx.pIdx != NULL) {

View File

@ -27,11 +27,11 @@ void taosSeedRand(uint32_t seed) { return srand(seed); }
uint32_t taosRand(void) { uint32_t taosRand(void) {
#ifdef WINDOWS #ifdef WINDOWS
unsigned int pSeed; unsigned int pSeed;
rand_s(&pSeed); rand_s(&pSeed);
return pSeed; return pSeed;
#else #else
return rand(); return rand();
#endif #endif
} }
@ -84,3 +84,12 @@ void taosRandStr(char* str, int32_t size) {
str[i] = set[taosRand() % len]; str[i] = set[taosRand() % len];
} }
} }
void taosRandStr2(char* str, int32_t size) {
const char* set = "abcdefghijklmnopqrstuvwxyz0123456789";
int32_t len = 36;
for (int32_t i = 0; i < size; ++i) {
str[i] = set[taosRand() % len];
}
}