Merge branch '3.0' into fix/3_liaohj
This commit is contained in:
commit
5768cc94a1
|
@ -18,7 +18,6 @@
|
||||||
// extern dependencies
|
// extern dependencies
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t fid;
|
int32_t fid;
|
||||||
bool hasDataToCommit;
|
|
||||||
STFileSet *fset;
|
STFileSet *fset;
|
||||||
} SFileSetCommitInfo;
|
} SFileSetCommitInfo;
|
||||||
|
|
||||||
|
@ -512,36 +511,25 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbCommitInfoAdd(STsdb *tsdb, const SFileSetCommitInfo *info) {
|
static int32_t tsdbCommitInfoAdd(STsdb *tsdb, int32_t fid) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
SFileSetCommitInfo *tinfo;
|
SFileSetCommitInfo *tinfo;
|
||||||
|
|
||||||
vHashGet(tsdb->commitInfo->ht, info, (void **)&tinfo);
|
if ((tinfo = taosMemoryMalloc(sizeof(*tinfo))) == NULL) {
|
||||||
if (tinfo) {
|
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||||
if (info->hasDataToCommit && !tinfo->hasDataToCommit) {
|
|
||||||
tinfo->hasDataToCommit = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((tinfo = taosMemoryCalloc(1, sizeof(*tinfo))) == NULL) {
|
|
||||||
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
|
||||||
}
|
|
||||||
tinfo->fid = info->fid;
|
|
||||||
tinfo->hasDataToCommit = info->hasDataToCommit;
|
|
||||||
if (info->fset) {
|
|
||||||
code = tsdbTFileSetInitCopy(tsdb, info->fset, &tinfo->fset);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
|
||||||
|
|
||||||
code = vHashPut(tsdb->commitInfo->ht, tinfo);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
|
|
||||||
if ((taosArrayPush(tsdb->commitInfo->arr, &tinfo)) == NULL) {
|
|
||||||
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
|
||||||
}
|
|
||||||
taosArraySort(tsdb->commitInfo->arr, tFileSetCommitInfoPCompare);
|
|
||||||
}
|
}
|
||||||
|
tinfo->fid = fid;
|
||||||
|
tinfo->fset = NULL;
|
||||||
|
|
||||||
|
code = vHashPut(tsdb->commitInfo->ht, tinfo);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
|
if ((taosArrayPush(tsdb->commitInfo->arr, &tinfo)) == NULL) {
|
||||||
|
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||||
|
}
|
||||||
|
taosArraySort(tsdb->commitInfo->arr, tFileSetCommitInfoPCompare);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -560,20 +548,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) {
|
||||||
code = tsdbCommitInfoInit(tsdb);
|
code = tsdbCommitInfoInit(tsdb);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
taosThreadMutexLock(&tsdb->mutex);
|
// scan time-series data
|
||||||
TARRAY2_FOREACH(tsdb->pFS->fSetArr, fset) {
|
|
||||||
SFileSetCommitInfo info = {
|
|
||||||
.fid = fset->fid,
|
|
||||||
.hasDataToCommit = false,
|
|
||||||
.fset = fset,
|
|
||||||
};
|
|
||||||
if ((code = tsdbCommitInfoAdd(tsdb, &info))) {
|
|
||||||
taosThreadMutexUnlock(&tsdb->mutex);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
taosThreadMutexUnlock(&tsdb->mutex);
|
|
||||||
|
|
||||||
iter = tRBTreeIterCreate(tsdb->imem->tbDataTree, 1);
|
iter = tRBTreeIterCreate(tsdb->imem->tbDataTree, 1);
|
||||||
for (SRBTreeNode *node = tRBTreeIterNext(&iter); node; node = tRBTreeIterNext(&iter)) {
|
for (SRBTreeNode *node = tRBTreeIterNext(&iter); node; node = tRBTreeIterNext(&iter)) {
|
||||||
STbData *pTbData = TCONTAINER_OF(node, STbData, rbtn);
|
STbData *pTbData = TCONTAINER_OF(node, STbData, rbtn);
|
||||||
|
@ -598,34 +573,77 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) {
|
||||||
fid = tsdbKeyFid(TSDBROW_TS(row), tsdb->keepCfg.days, tsdb->keepCfg.precision);
|
fid = tsdbKeyFid(TSDBROW_TS(row), tsdb->keepCfg.days, tsdb->keepCfg.precision);
|
||||||
tsdbFidKeyRange(fid, tsdb->keepCfg.days, tsdb->keepCfg.precision, &minKey, &maxKey);
|
tsdbFidKeyRange(fid, tsdb->keepCfg.days, tsdb->keepCfg.precision, &minKey, &maxKey);
|
||||||
|
|
||||||
SFileSetCommitInfo info = {
|
SFileSetCommitInfo *info;
|
||||||
.fid = fid,
|
SFileSetCommitInfo tinfo = {
|
||||||
.hasDataToCommit = true,
|
.fid = fid,
|
||||||
.fset = NULL,
|
|
||||||
};
|
};
|
||||||
code = tsdbCommitInfoAdd(tsdb, &info);
|
vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
if (info == NULL) {
|
||||||
|
code = tsdbCommitInfoAdd(tsdb, fid);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
}
|
||||||
|
|
||||||
from.key.ts = maxKey + 1;
|
from.key.ts = maxKey + 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// scan tomb data
|
taosThreadMutexLock(&tsdb->mutex);
|
||||||
for (SDelData *pDelData = pTbData->pHead; pDelData; pDelData = pDelData->pNext) {
|
|
||||||
for (int32_t i = taosArrayGetSize(tsdb->commitInfo->arr) - 1; i >= 0; i--) {
|
|
||||||
int64_t minKey, maxKey;
|
|
||||||
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i);
|
|
||||||
|
|
||||||
tsdbFidKeyRange(info->fid, tsdb->keepCfg.days, tsdb->keepCfg.precision, &minKey, &maxKey);
|
// scan tomb data
|
||||||
|
if (tsdb->imem->nDel > 0) {
|
||||||
|
TARRAY2_FOREACH(tsdb->pFS->fSetArr, fset) {
|
||||||
|
if (tsdbTFileSetIsEmpty(fset)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDelData->sKey > maxKey || pDelData->eKey < minKey) {
|
SFileSetCommitInfo *info;
|
||||||
continue;
|
SFileSetCommitInfo tinfo = {
|
||||||
} else if (!info->hasDataToCommit) {
|
.fid = fset->fid,
|
||||||
info->hasDataToCommit = true;
|
};
|
||||||
|
|
||||||
|
// check if the file set already on the commit list
|
||||||
|
vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info);
|
||||||
|
if (info != NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t minKey, maxKey;
|
||||||
|
bool hasDataToCommit = false;
|
||||||
|
tsdbFidKeyRange(fset->fid, tsdb->keepCfg.days, tsdb->keepCfg.precision, &minKey, &maxKey);
|
||||||
|
iter = tRBTreeIterCreate(tsdb->imem->tbDataTree, 1);
|
||||||
|
for (SRBTreeNode *node = tRBTreeIterNext(&iter); node; node = tRBTreeIterNext(&iter)) {
|
||||||
|
STbData *pTbData = TCONTAINER_OF(node, STbData, rbtn);
|
||||||
|
for (SDelData *pDelData = pTbData->pHead; pDelData; pDelData = pDelData->pNext) {
|
||||||
|
if (pDelData->sKey > maxKey || pDelData->eKey < minKey) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
hasDataToCommit = true;
|
||||||
|
if ((code = tsdbCommitInfoAdd(tsdb, fset->fid))) {
|
||||||
|
taosThreadMutexUnlock(&tsdb->mutex);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasDataToCommit) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// begin tasks on file set
|
||||||
|
for (int i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) {
|
||||||
|
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i);
|
||||||
|
tsdbBeginTaskOnFileSet(tsdb, info->fid, &fset);
|
||||||
|
if (fset) {
|
||||||
|
tsdbTFileSetInitCopy(tsdb, fset, &info->fset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&tsdb->mutex);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbCommitInfoDestroy(tsdb);
|
tsdbCommitInfoDestroy(tsdb);
|
||||||
|
@ -653,16 +671,6 @@ static int32_t tsdbOpenCommitter(STsdb *tsdb, SCommitInfo *info, SCommitter2 *co
|
||||||
code = tsdbCommitInfoBuild(tsdb);
|
code = tsdbCommitInfoBuild(tsdb);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
STFileSet *fset;
|
|
||||||
taosThreadMutexLock(&tsdb->mutex);
|
|
||||||
for (int i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) {
|
|
||||||
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i);
|
|
||||||
if (info->hasDataToCommit && info->fset) {
|
|
||||||
tsdbBeginTaskOnFileSet(tsdb, info->fid, &fset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
taosThreadMutexUnlock(&tsdb->mutex);
|
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
TSDB_ERROR_LOG(TD_VID(tsdb->pVnode), lino, code);
|
TSDB_ERROR_LOG(TD_VID(tsdb->pVnode), lino, code);
|
||||||
|
@ -735,10 +743,8 @@ int32_t tsdbCommitBegin(STsdb *tsdb, SCommitInfo *info) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) {
|
for (int32_t i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) {
|
||||||
committer.ctx->info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i);
|
committer.ctx->info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i);
|
||||||
if (committer.ctx->info->hasDataToCommit) {
|
code = tsdbCommitFileSet(&committer);
|
||||||
code = tsdbCommitFileSet(&committer);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbCloseCommitter(&committer, code);
|
code = tsdbCloseCommitter(&committer, code);
|
||||||
|
@ -771,7 +777,7 @@ int32_t tsdbCommitCommit(STsdb *tsdb) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) {
|
for (int32_t i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) {
|
||||||
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i);
|
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i);
|
||||||
if (info->hasDataToCommit && info->fset) {
|
if (info->fset) {
|
||||||
tsdbFinishTaskOnFileSet(tsdb, info->fid);
|
tsdbFinishTaskOnFileSet(tsdb, info->fid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -803,7 +809,7 @@ int32_t tsdbCommitAbort(STsdb *pTsdb) {
|
||||||
taosThreadMutexLock(&pTsdb->mutex);
|
taosThreadMutexLock(&pTsdb->mutex);
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pTsdb->commitInfo->arr); i++) {
|
for (int32_t i = 0; i < taosArrayGetSize(pTsdb->commitInfo->arr); i++) {
|
||||||
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(pTsdb->commitInfo->arr, i);
|
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(pTsdb->commitInfo->arr, i);
|
||||||
if (info->hasDataToCommit && info->fset) {
|
if (info->fset) {
|
||||||
tsdbFinishTaskOnFileSet(pTsdb, info->fid);
|
tsdbFinishTaskOnFileSet(pTsdb, info->fid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1181,7 +1181,7 @@ int32_t tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) {
|
||||||
int16_t sttTrigger = tsdb->pVnode->config.sttTrigger;
|
int16_t sttTrigger = tsdb->pVnode->config.sttTrigger;
|
||||||
|
|
||||||
tsdbFSGetFSet(tsdb->pFS, fid, fset);
|
tsdbFSGetFSet(tsdb->pFS, fid, fset);
|
||||||
if (sttTrigger == 1 && fset) {
|
if (sttTrigger == 1 && (*fset)) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if ((*fset)->taskRunning) {
|
if ((*fset)->taskRunning) {
|
||||||
(*fset)->numWaitTask++;
|
(*fset)->numWaitTask++;
|
||||||
|
|
|
@ -47,7 +47,7 @@ int taos_linked_list_push(taos_linked_list_t *self, void *item);
|
||||||
/**
|
/**
|
||||||
* @brief API PRIVATE Pop the first item off of the list
|
* @brief API PRIVATE Pop the first item off of the list
|
||||||
*/
|
*/
|
||||||
void *taos_linked_list_pop(taos_linked_list_t *self);
|
//void *taos_linked_list_pop(taos_linked_list_t *self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief API PRIVATE Returns the item at the head of the list or NULL if not present
|
* @brief API PRIVATE Returns the item at the head of the list or NULL if not present
|
||||||
|
|
|
@ -33,6 +33,8 @@ taos_map_t *taos_collector_default_collect(taos_collector_t *self) { return self
|
||||||
taos_collector_t *taos_collector_new(const char *name) {
|
taos_collector_t *taos_collector_new(const char *name) {
|
||||||
int r = 0;
|
int r = 0;
|
||||||
taos_collector_t *self = (taos_collector_t *)taos_malloc(sizeof(taos_collector_t));
|
taos_collector_t *self = (taos_collector_t *)taos_malloc(sizeof(taos_collector_t));
|
||||||
|
if (self == NULL) return NULL;
|
||||||
|
memset(self, 0, sizeof(taos_collector_t));
|
||||||
self->name = taos_strdup(name);
|
self->name = taos_strdup(name);
|
||||||
self->metrics = taos_map_new();
|
self->metrics = taos_map_new();
|
||||||
if (self->metrics == NULL) {
|
if (self->metrics == NULL) {
|
||||||
|
@ -66,9 +68,11 @@ int taos_collector_destroy(taos_collector_t *self) {
|
||||||
if (r) ret = r;
|
if (r) ret = r;
|
||||||
self->metrics = NULL;
|
self->metrics = NULL;
|
||||||
|
|
||||||
r = taos_string_builder_destroy(self->string_builder);
|
if(self->string_builder != NULL){
|
||||||
if (r) ret = r;
|
r = taos_string_builder_destroy(self->string_builder);
|
||||||
self->string_builder = NULL;
|
if (r) ret = r;
|
||||||
|
self->string_builder = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
taos_free((char *)self->name);
|
taos_free((char *)self->name);
|
||||||
self->name = NULL;
|
self->name = NULL;
|
||||||
|
|
|
@ -59,6 +59,7 @@ taos_collector_registry_t *taos_collector_registry_new(const char *name) {
|
||||||
r = pthread_rwlock_init(self->lock, NULL);
|
r = pthread_rwlock_init(self->lock, NULL);
|
||||||
if (r) {
|
if (r) {
|
||||||
TAOS_LOG("failed to initialize rwlock");
|
TAOS_LOG("failed to initialize rwlock");
|
||||||
|
taos_free(self);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
@ -301,6 +302,9 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self,
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
tjsonDelete(pJson);
|
tjsonDelete(pJson);
|
||||||
|
if(tmp_builder != NULL){
|
||||||
|
taos_string_builder_destroy(tmp_builder);
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,7 @@ int taos_linked_list_push(taos_linked_list_t *self, void *item) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void *taos_linked_list_pop(taos_linked_list_t *self) {
|
void *taos_linked_list_pop(taos_linked_list_t *self) {
|
||||||
TAOS_ASSERT(self != NULL);
|
TAOS_ASSERT(self != NULL);
|
||||||
if (self == NULL) return NULL;
|
if (self == NULL) return NULL;
|
||||||
|
@ -141,6 +142,7 @@ void *taos_linked_list_pop(taos_linked_list_t *self) {
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
int taos_linked_list_remove(taos_linked_list_t *self, void *item) {
|
int taos_linked_list_remove(taos_linked_list_t *self, void *item) {
|
||||||
TAOS_ASSERT(self != NULL);
|
TAOS_ASSERT(self != NULL);
|
||||||
|
|
|
@ -90,7 +90,7 @@ taos_map_t *taos_map_new() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->addrs = taos_malloc(sizeof(taos_linked_list_t) * self->max_size);
|
self->addrs = taos_malloc(sizeof(taos_linked_list_t*) * self->max_size);
|
||||||
self->free_value_fn = destroy_map_node_value_no_op;
|
self->free_value_fn = destroy_map_node_value_no_op;
|
||||||
|
|
||||||
for (int i = 0; i < self->max_size; i++) {
|
for (int i = 0; i < self->max_size; i++) {
|
||||||
|
@ -273,7 +273,7 @@ int taos_map_ensure_space(taos_map_t *self) {
|
||||||
if (r) return r;
|
if (r) return r;
|
||||||
|
|
||||||
// Create a new array of addrs
|
// Create a new array of addrs
|
||||||
taos_linked_list_t **new_addrs = taos_malloc(sizeof(taos_linked_list_t) * new_max);
|
taos_linked_list_t **new_addrs = taos_malloc(sizeof(taos_linked_list_t*) * new_max);
|
||||||
|
|
||||||
// Initialize the new array
|
// Initialize the new array
|
||||||
for (int i = 0; i < new_max; i++) {
|
for (int i = 0; i < new_max; i++) {
|
||||||
|
|
|
@ -33,6 +33,8 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name,
|
||||||
size_t label_key_count, const char **label_keys) {
|
size_t label_key_count, const char **label_keys) {
|
||||||
int r = 0;
|
int r = 0;
|
||||||
taos_metric_t *self = (taos_metric_t *)taos_malloc(sizeof(taos_metric_t));
|
taos_metric_t *self = (taos_metric_t *)taos_malloc(sizeof(taos_metric_t));
|
||||||
|
if (self == NULL) return NULL;
|
||||||
|
memset(self, 0, sizeof(taos_metric_t));
|
||||||
self->type = metric_type;
|
self->type = metric_type;
|
||||||
int len = strlen(name) + 1;
|
int len = strlen(name) + 1;
|
||||||
self->name = taos_malloc(len);
|
self->name = taos_malloc(len);
|
||||||
|
@ -79,6 +81,7 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name,
|
||||||
r = pthread_rwlock_init(self->rwlock, NULL);
|
r = pthread_rwlock_init(self->rwlock, NULL);
|
||||||
if (r) {
|
if (r) {
|
||||||
TAOS_LOG(TAOS_PTHREAD_RWLOCK_INIT_ERROR);
|
TAOS_LOG(TAOS_PTHREAD_RWLOCK_INIT_ERROR);
|
||||||
|
taos_free(self);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
@ -91,9 +94,11 @@ int taos_metric_destroy(taos_metric_t *self) {
|
||||||
int r = 0;
|
int r = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
r = taos_map_destroy(self->samples);
|
if(self->samples != NULL){
|
||||||
self->samples = NULL;
|
r = taos_map_destroy(self->samples);
|
||||||
if (r) ret = r;
|
self->samples = NULL;
|
||||||
|
if (r) ret = r;
|
||||||
|
}
|
||||||
|
|
||||||
r = taos_metric_formatter_destroy(self->formatter);
|
r = taos_metric_formatter_destroy(self->formatter);
|
||||||
self->formatter = NULL;
|
self->formatter = NULL;
|
||||||
|
@ -152,8 +157,7 @@ taos_metric_sample_t *taos_metric_sample_from_labels(taos_metric_t *self, const
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Get l_value
|
// Get l_value
|
||||||
r = taos_metric_formatter_load_l_value(self->formatter, self->name, NULL, self->label_key_count, self->label_keys,
|
r = taos_metric_formatter_load_l_value(self->formatter, self->name, NULL, self->label_key_count, self->label_keys, label_values);
|
||||||
label_values);
|
|
||||||
if (r) {
|
if (r) {
|
||||||
TAOS_METRIC_SAMPLE_FROM_LABELS_HANDLE_UNLOCK();
|
TAOS_METRIC_SAMPLE_FROM_LABELS_HANDLE_UNLOCK();
|
||||||
}
|
}
|
||||||
|
@ -170,10 +174,12 @@ taos_metric_sample_t *taos_metric_sample_from_labels(taos_metric_t *self, const
|
||||||
sample = taos_metric_sample_new(self->type, l_value, 0.0);
|
sample = taos_metric_sample_new(self->type, l_value, 0.0);
|
||||||
r = taos_map_set(self->samples, l_value, sample);
|
r = taos_map_set(self->samples, l_value, sample);
|
||||||
if (r) {
|
if (r) {
|
||||||
|
taos_free((void *)l_value);
|
||||||
TAOS_METRIC_SAMPLE_FROM_LABELS_HANDLE_UNLOCK();
|
TAOS_METRIC_SAMPLE_FROM_LABELS_HANDLE_UNLOCK();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_rwlock_unlock(self->rwlock);
|
r = pthread_rwlock_unlock(self->rwlock);
|
||||||
|
if (r) TAOS_LOG(TAOS_PTHREAD_RWLOCK_UNLOCK_ERROR);
|
||||||
taos_free((void *)l_value);
|
taos_free((void *)l_value);
|
||||||
return sample;
|
return sample;
|
||||||
}
|
}
|
||||||
|
|
|
@ -798,6 +798,7 @@ TEST(queryTest, normalCase) {
|
||||||
|
|
||||||
schedulerFreeJob(&job, 0);
|
schedulerFreeJob(&job, 0);
|
||||||
|
|
||||||
|
taosThreadJoin(thread1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(queryTest, readyFirstCase) {
|
TEST(queryTest, readyFirstCase) {
|
||||||
|
@ -907,6 +908,8 @@ TEST(queryTest, readyFirstCase) {
|
||||||
schedulerDestroy();
|
schedulerDestroy();
|
||||||
|
|
||||||
schedulerFreeJob(&job, 0);
|
schedulerFreeJob(&job, 0);
|
||||||
|
|
||||||
|
taosThreadJoin(thread1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(queryTest, flowCtrlCase) {
|
TEST(queryTest, flowCtrlCase) {
|
||||||
|
@ -1001,6 +1004,8 @@ TEST(queryTest, flowCtrlCase) {
|
||||||
schedulerDestroy();
|
schedulerDestroy();
|
||||||
|
|
||||||
schedulerFreeJob(&job, 0);
|
schedulerFreeJob(&job, 0);
|
||||||
|
|
||||||
|
taosThreadJoin(thread1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(insertTest, normalCase) {
|
TEST(insertTest, normalCase) {
|
||||||
|
@ -1061,6 +1066,8 @@ TEST(insertTest, normalCase) {
|
||||||
schedulerFreeJob(&insertJobRefId, 0);
|
schedulerFreeJob(&insertJobRefId, 0);
|
||||||
|
|
||||||
schedulerDestroy();
|
schedulerDestroy();
|
||||||
|
|
||||||
|
taosThreadJoin(thread1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(multiThread, forceFree) {
|
TEST(multiThread, forceFree) {
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
###################################################################
|
||||||
|
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This file is proprietary and confidential to TAOS Technologies.
|
||||||
|
# No part of this file may be reproduced, stored, transmitted,
|
||||||
|
# disclosed or used in any form or by any means other than as
|
||||||
|
# expressly provided by the written permission from Jianhui Tao
|
||||||
|
#
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
import taos
|
||||||
|
import frame
|
||||||
|
import frame.etool
|
||||||
|
|
||||||
|
from frame.log import *
|
||||||
|
from frame.cases import *
|
||||||
|
from frame.sql import *
|
||||||
|
from frame.caseBase import *
|
||||||
|
from frame import *
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase(TBase):
|
||||||
|
def alterSupportVnodes(self):
|
||||||
|
tdLog.info(f"test function of altering supportVnodes")
|
||||||
|
|
||||||
|
tdSql.execute("alter dnode 1 'supportVnodes' '128'")
|
||||||
|
time.sleep(1)
|
||||||
|
tdSql.query('show dnodes')
|
||||||
|
tdSql.checkData(0, 3, "128")
|
||||||
|
|
||||||
|
tdSql.execute("alter dnode 1 'supportVnodes' '64'")
|
||||||
|
time.sleep(1)
|
||||||
|
tdSql.query('show dnodes')
|
||||||
|
tdSql.checkData(0, 3, "64")
|
||||||
|
|
||||||
|
# run
|
||||||
|
def run(self):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
|
||||||
|
# TS-4721
|
||||||
|
self.alterSupportVnodes()
|
||||||
|
|
||||||
|
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -0,0 +1,63 @@
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import glob
|
||||||
|
import shutil
|
||||||
|
import time
|
||||||
|
|
||||||
|
from frame.log import *
|
||||||
|
from frame.cases import *
|
||||||
|
from frame.sql import *
|
||||||
|
from frame.srvCtl import *
|
||||||
|
from frame.caseBase import *
|
||||||
|
from frame import *
|
||||||
|
from frame.autogen import *
|
||||||
|
# from frame.server.dnodes import *
|
||||||
|
# from frame.server.cluster import *
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase(TBase):
|
||||||
|
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
super(TDTestCase, self).init(conn, logSql, replicaVar=1, checkColName="c1")
|
||||||
|
self.valgrind = 0
|
||||||
|
self.db = "test"
|
||||||
|
self.stb = "meters"
|
||||||
|
self.childtable_count = 10
|
||||||
|
tdSql.init(conn.cursor(), logSql)
|
||||||
|
|
||||||
|
def create_encrypt_db(self):
|
||||||
|
|
||||||
|
tdSql.execute("create encrypt_key '1234567890'")
|
||||||
|
autoGen = AutoGen()
|
||||||
|
autoGen.create_db(self.db, 2, 1, "ENCRYPT_ALGORITHM 'sm4'")
|
||||||
|
tdSql.execute(f"use {self.db}")
|
||||||
|
autoGen.create_stable(self.stb, 2, 3, 8, 8)
|
||||||
|
autoGen.create_child(self.stb, "d", self.childtable_count)
|
||||||
|
autoGen.insert_data(1000)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {self.db}.{self.stb}")
|
||||||
|
tdSql.checkRows(1000 * self.childtable_count)
|
||||||
|
|
||||||
|
self.timestamp_step = 1000
|
||||||
|
self.insert_rows = 1000
|
||||||
|
|
||||||
|
self.checkInsertCorrect()
|
||||||
|
|
||||||
|
def create_encrypt_db_error(self):
|
||||||
|
tdSql.error("create encrypt_key '123'")
|
||||||
|
tdSql.error("create encrypt_key '12345678abcdefghi'")
|
||||||
|
tdSql.error("create database test ENCRYPT_ALGORITHM 'sm4'")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.create_encrypt_db_error()
|
||||||
|
self.create_encrypt_db()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -11,6 +11,7 @@
|
||||||
# army-test
|
# army-test
|
||||||
#
|
#
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f enterprise/multi-level/mlevel_basic.py -N 3 -L 3 -D 2
|
,,y,army,./pytest.sh python3 ./test.py -f enterprise/multi-level/mlevel_basic.py -N 3 -L 3 -D 2
|
||||||
|
,,y,army,./pytest.sh python3 ./test.py -f enterprise/db-encrypt/basic.py
|
||||||
,,n,army,python3 ./test.py -f enterprise/s3/s3Basic.py -N 3
|
,,n,army,python3 ./test.py -f enterprise/s3/s3Basic.py -N 3
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/snapshot.py -N 3 -L 3 -D 2
|
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/snapshot.py -N 3 -L 3 -D 2
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/query/function/test_func_elapsed.py
|
,,y,army,./pytest.sh python3 ./test.py -f community/query/function/test_func_elapsed.py
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/splitVgroupByLearner.py -N 3
|
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/splitVgroupByLearner.py -N 3
|
||||||
,,n,army,python3 ./test.py -f community/cmdline/fullopt.py
|
,,n,army,python3 ./test.py -f community/cmdline/fullopt.py
|
||||||
,,n,army,python3 ./test.py -f community/query/show.py -N 3
|
,,n,army,python3 ./test.py -f community/query/show.py -N 3
|
||||||
|
,,n,army,python3 ./test.py -f enterprise/alter/alterConfig.py -N 3
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/storage/oneStageComp.py -N 3 -L 3 -D 1
|
,,y,army,./pytest.sh python3 ./test.py -f community/storage/oneStageComp.py -N 3 -L 3 -D 1
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/storage/compressBasic.py -N 3
|
,,y,army,./pytest.sh python3 ./test.py -f community/storage/compressBasic.py -N 3
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,30 @@ class TDTestCase:
|
||||||
#tdSql.init(conn.cursor())
|
#tdSql.init(conn.cursor())
|
||||||
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||||
|
|
||||||
|
def interp_on_empty_table(self):
|
||||||
|
dbname = "db"
|
||||||
|
tbname = "t"
|
||||||
|
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
|
|
||||||
|
tdSql.execute(f'''create table if not exists {dbname}.{tbname} (ts timestamp, k int)''')
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========step2:interp query on empty table")
|
||||||
|
|
||||||
|
tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(prev)")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(next)")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(linear)")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(value, 2)")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
dbname = "db"
|
dbname = "db"
|
||||||
tbname = "tb"
|
tbname = "tb"
|
||||||
|
@ -5658,6 +5682,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(0, 0, '2023-08-06 23:59:00')
|
tdSql.checkData(0, 0, '2023-08-06 23:59:00')
|
||||||
tdSql.checkData(0, 1, None)
|
tdSql.checkData(0, 1, None)
|
||||||
|
|
||||||
|
self.interp_on_empty_table()
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
Loading…
Reference in New Issue