Merge branch '3.0' of https://github.com/taosdata/TDengine into feat/TS-4243-3.0
This commit is contained in:
commit
52ed1ec5f7
Binary file not shown.
|
@ -65,6 +65,11 @@ extern "C" {
|
||||||
#define TSDB_PERFS_TABLE_TRANS "perf_trans"
|
#define TSDB_PERFS_TABLE_TRANS "perf_trans"
|
||||||
#define TSDB_PERFS_TABLE_APPS "perf_apps"
|
#define TSDB_PERFS_TABLE_APPS "perf_apps"
|
||||||
|
|
||||||
|
#define TSDB_AUDIT_DB "audit"
|
||||||
|
#define TSDB_AUDIT_STB_OPERATION "operations"
|
||||||
|
#define TSDB_AUDIT_CTB_OPERATION "t_operations_"
|
||||||
|
#define TSDB_AUDIT_CTB_OPERATION_LEN 13
|
||||||
|
|
||||||
typedef struct SSysDbTableSchema {
|
typedef struct SSysDbTableSchema {
|
||||||
const char* name;
|
const char* name;
|
||||||
const int32_t type;
|
const int32_t type;
|
||||||
|
|
|
@ -232,7 +232,7 @@ struct SConfig *taosGetCfg();
|
||||||
void taosSetAllDebugFlag(int32_t flag);
|
void taosSetAllDebugFlag(int32_t flag);
|
||||||
void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal);
|
void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal);
|
||||||
void taosLocalCfgForbiddenToChange(char *name, bool *forbidden);
|
void taosLocalCfgForbiddenToChange(char *name, bool *forbidden);
|
||||||
int8_t taosGranted();
|
int8_t taosGranted(int8_t type);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,9 @@ extern "C" {
|
||||||
|
|
||||||
#define GRANT_HEART_BEAT_MIN 2
|
#define GRANT_HEART_BEAT_MIN 2
|
||||||
#define GRANT_ACTIVE_CODE "activeCode"
|
#define GRANT_ACTIVE_CODE "activeCode"
|
||||||
|
#define GRANT_FLAG_ALL (0x01)
|
||||||
|
#define GRANT_FLAG_AUDIT (0x02)
|
||||||
|
#define GRANT_FLAG_VIEW (0x04)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_GRANT_ALL,
|
TSDB_GRANT_ALL,
|
||||||
|
@ -50,63 +53,39 @@ typedef enum {
|
||||||
TSDB_GRANT_SUBSCRIPTION,
|
TSDB_GRANT_SUBSCRIPTION,
|
||||||
TSDB_GRANT_AUDIT,
|
TSDB_GRANT_AUDIT,
|
||||||
TSDB_GRANT_CSV,
|
TSDB_GRANT_CSV,
|
||||||
|
TSDB_GRANT_VIEW,
|
||||||
TSDB_GRANT_MULTI_TIER,
|
TSDB_GRANT_MULTI_TIER,
|
||||||
TSDB_GRANT_BACKUP_RESTORE,
|
TSDB_GRANT_BACKUP_RESTORE,
|
||||||
} EGrantType;
|
} EGrantType;
|
||||||
|
|
||||||
int32_t grantCheck(EGrantType grant);
|
int32_t grantCheck(EGrantType grant);
|
||||||
|
int32_t grantCheckExpire(EGrantType grant);
|
||||||
char* tGetMachineId();
|
char* tGetMachineId();
|
||||||
#ifndef TD_UNIQ_GRANT
|
#ifdef TD_UNIQ_GRANT
|
||||||
int32_t grantAlterActiveCode(int32_t did, const char* old, const char* newer, char* out, int8_t type);
|
int32_t grantCheckLE(EGrantType grant);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #ifndef GRANTS_CFG
|
// #ifndef GRANTS_CFG
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
#ifdef TD_UNIQ_GRANT
|
|
||||||
#define GRANTS_SCHEMA \
|
#define GRANTS_SCHEMA \
|
||||||
static const SSysDbTableSchema grantsSchema[] = { \
|
static const SSysDbTableSchema grantsSchema[] = { \
|
||||||
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "state", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define GRANTS_SCHEMA \
|
|
||||||
static const SSysDbTableSchema grantsSchema[] = { \
|
|
||||||
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "storage", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "databases", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "users", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "accounts", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "connections", .bytes = 11 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "streams", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "cpu_cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "speed", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "opc_da", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "opc_ua", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "pi", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "kafka", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "influxdb", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "mqtt", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define GRANTS_SCHEMA \
|
#define GRANTS_SCHEMA \
|
||||||
static const SSysDbTableSchema grantsSchema[] = { \
|
static const SSysDbTableSchema grantsSchema[] = { \
|
||||||
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "state", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
|
|
@ -3923,6 +3923,7 @@ int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
|
||||||
|
|
||||||
#define SUBMIT_REQ_AUTO_CREATE_TABLE 0x1
|
#define SUBMIT_REQ_AUTO_CREATE_TABLE 0x1
|
||||||
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
|
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
|
||||||
|
#define SUBMIT_REQ_FROM_FILE 0x4
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t flags;
|
int32_t flags;
|
||||||
|
|
|
@ -211,6 +211,7 @@ typedef struct SStoreTqReader {
|
||||||
bool (*tqNextBlockImpl)(); // todo remove it
|
bool (*tqNextBlockImpl)(); // todo remove it
|
||||||
SSDataBlock* (*tqGetResultBlock)();
|
SSDataBlock* (*tqGetResultBlock)();
|
||||||
int64_t (*tqGetResultBlockTime)();
|
int64_t (*tqGetResultBlockTime)();
|
||||||
|
int32_t (*tqGetStreamExecProgress)();
|
||||||
|
|
||||||
void (*tqReaderSetColIdList)();
|
void (*tqReaderSetColIdList)();
|
||||||
int32_t (*tqReaderSetQueryTableList)();
|
int32_t (*tqReaderSetQueryTableList)();
|
||||||
|
@ -266,16 +267,11 @@ typedef struct SStoreMeta {
|
||||||
// support filter and non-filter cases. [vnodeGetCtbIdList & vnodeGetCtbIdListByFilter]
|
// support filter and non-filter cases. [vnodeGetCtbIdList & vnodeGetCtbIdListByFilter]
|
||||||
int32_t (*getChildTableList)(void* pVnode, int64_t suid, SArray* list);
|
int32_t (*getChildTableList)(void* pVnode, int64_t suid, SArray* list);
|
||||||
int32_t (*storeGetTableList)(void* pVnode, int8_t type, SArray* pList);
|
int32_t (*storeGetTableList)(void* pVnode, int8_t type, SArray* pList);
|
||||||
void* storeGetVersionRange;
|
int32_t (*getTableSchema)(void* pVnode, int64_t uid, STSchema** pSchema, int64_t* suid);
|
||||||
void* storeGetLastTimestamp;
|
|
||||||
|
|
||||||
int32_t (*getTableSchema)(void* pVnode, int64_t uid, STSchema** pSchema, int64_t* suid); // tsdbGetTableSchema
|
|
||||||
int32_t (*getNumOfChildTables)(void* pVnode, int64_t uid, int64_t* numOfTables, int32_t* numOfCols);
|
int32_t (*getNumOfChildTables)(void* pVnode, int64_t uid, int64_t* numOfTables, int32_t* numOfCols);
|
||||||
void (*getBasicInfo)(void* pVnode, const char** dbname, int32_t* vgId, int64_t* numOfTables,
|
void (*getBasicInfo)(void* pVnode, const char** dbname, int32_t* vgId, int64_t* numOfTables,
|
||||||
int64_t* numOfNormalTables);
|
int64_t* numOfNormalTables);
|
||||||
|
|
||||||
int64_t (*getNumOfRowsInMem)(void* pVnode);
|
|
||||||
|
|
||||||
SMCtbCursor* (*openCtbCursor)(void* pVnode, tb_uid_t uid, int lock);
|
SMCtbCursor* (*openCtbCursor)(void* pVnode, tb_uid_t uid, int lock);
|
||||||
int32_t (*resumeCtbCursor)(SMCtbCursor* pCtbCur, int8_t first);
|
int32_t (*resumeCtbCursor)(SMCtbCursor* pCtbCur, int8_t first);
|
||||||
void (*pauseCtbCursor)(SMCtbCursor* pCtbCur);
|
void (*pauseCtbCursor)(SMCtbCursor* pCtbCur);
|
||||||
|
|
|
@ -713,8 +713,10 @@ typedef struct SSubplan {
|
||||||
SNode* pTagCond;
|
SNode* pTagCond;
|
||||||
SNode* pTagIndexCond;
|
SNode* pTagIndexCond;
|
||||||
bool showRewrite;
|
bool showRewrite;
|
||||||
int32_t rowsThreshold;
|
bool isView;
|
||||||
|
bool isAudit;
|
||||||
bool dynamicRowThreshold;
|
bool dynamicRowThreshold;
|
||||||
|
int32_t rowsThreshold;
|
||||||
} SSubplan;
|
} SSubplan;
|
||||||
|
|
||||||
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
|
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
|
||||||
|
|
|
@ -86,8 +86,10 @@ typedef struct SParseContext {
|
||||||
bool enableSysInfo;
|
bool enableSysInfo;
|
||||||
bool async;
|
bool async;
|
||||||
bool hasInvisibleCol;
|
bool hasInvisibleCol;
|
||||||
const char* svrVer;
|
bool isView;
|
||||||
|
bool isAudit;
|
||||||
bool nodeOffline;
|
bool nodeOffline;
|
||||||
|
const char* svrVer;
|
||||||
SArray* pTableMetaPos; // sql table pos => catalog data pos
|
SArray* pTableMetaPos; // sql table pos => catalog data pos
|
||||||
SArray* pTableVgroupPos; // sql table pos => catalog data pos
|
SArray* pTableVgroupPos; // sql table pos => catalog data pos
|
||||||
int64_t allocatorId;
|
int64_t allocatorId;
|
||||||
|
|
|
@ -32,6 +32,8 @@ typedef struct SPlanContext {
|
||||||
bool streamQuery;
|
bool streamQuery;
|
||||||
bool rSmaQuery;
|
bool rSmaQuery;
|
||||||
bool showRewrite;
|
bool showRewrite;
|
||||||
|
bool isView;
|
||||||
|
bool isAudit;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
int64_t deleteMark;
|
int64_t deleteMark;
|
||||||
|
|
|
@ -66,7 +66,11 @@ typedef enum {
|
||||||
#define QUERY_RSP_POLICY_QUICK 1
|
#define QUERY_RSP_POLICY_QUICK 1
|
||||||
|
|
||||||
#define QUERY_MSG_MASK_SHOW_REWRITE() (1 << 0)
|
#define QUERY_MSG_MASK_SHOW_REWRITE() (1 << 0)
|
||||||
|
#define QUERY_MSG_MASK_AUDIT() (1 << 1)
|
||||||
|
#define QUERY_MSG_MASK_VIEW() (1 << 2)
|
||||||
#define TEST_SHOW_REWRITE_MASK(m) (((m) & QUERY_MSG_MASK_SHOW_REWRITE()) != 0)
|
#define TEST_SHOW_REWRITE_MASK(m) (((m) & QUERY_MSG_MASK_SHOW_REWRITE()) != 0)
|
||||||
|
#define TEST_AUDIT_MASK(m) (((m) & QUERY_MSG_MASK_AUDIT()) != 0)
|
||||||
|
#define TEST_VIEW_MASK(m) (((m) & QUERY_MSG_MASK_VIEW()) != 0)
|
||||||
|
|
||||||
typedef struct STableComInfo {
|
typedef struct STableComInfo {
|
||||||
uint8_t numOfTags; // the number of tags in schema
|
uint8_t numOfTags; // the number of tags in schema
|
||||||
|
@ -338,6 +342,11 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
||||||
|
|
||||||
#define IS_SYS_DBNAME(_dbname) (IS_INFORMATION_SCHEMA_DB(_dbname) || IS_PERFORMANCE_SCHEMA_DB(_dbname))
|
#define IS_SYS_DBNAME(_dbname) (IS_INFORMATION_SCHEMA_DB(_dbname) || IS_PERFORMANCE_SCHEMA_DB(_dbname))
|
||||||
|
|
||||||
|
#define IS_AUDIT_DBNAME(_dbname) ((*(_dbname) == 'a') && (0 == strcmp(_dbname, TSDB_AUDIT_DB)))
|
||||||
|
#define IS_AUDIT_STB_NAME(_stbname) ((*(_stbname) == 'o') && (0 == strcmp(_stbname, TSDB_AUDIT_STB_OPERATION)))
|
||||||
|
#define IS_AUDIT_CTB_NAME(_ctbname) \
|
||||||
|
((*(_ctbname) == 't') && (0 == strncmp(_ctbname, TSDB_AUDIT_CTB_OPERATION, TSDB_AUDIT_CTB_OPERATION_LEN)))
|
||||||
|
|
||||||
#define qFatal(...) \
|
#define qFatal(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_FATAL) { \
|
if (qDebugFlag & DEBUG_FATAL) { \
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _STREAM_STATE_H_
|
||||||
|
#define _STREAM_STATE_H_
|
||||||
|
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
|
|
||||||
#include "rocksdb/c.h"
|
#include "rocksdb/c.h"
|
||||||
|
@ -20,9 +23,6 @@
|
||||||
#include "tsimplehash.h"
|
#include "tsimplehash.h"
|
||||||
#include "tstreamFileState.h"
|
#include "tstreamFileState.h"
|
||||||
|
|
||||||
#ifndef _STREAM_STATE_H_
|
|
||||||
#define _STREAM_STATE_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _STREAM_H_
|
||||||
|
#define _STREAM_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "streamState.h"
|
#include "streamState.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
|
@ -26,9 +29,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _STREAM_H_
|
|
||||||
#define _STREAM_H_
|
|
||||||
|
|
||||||
#define ONE_MiB_F (1048576.0)
|
#define ONE_MiB_F (1048576.0)
|
||||||
#define ONE_KiB_F (1024.0)
|
#define ONE_KiB_F (1024.0)
|
||||||
#define SIZE_IN_MiB(_v) ((_v) / ONE_MiB_F)
|
#define SIZE_IN_MiB(_v) ((_v) / ONE_MiB_F)
|
||||||
|
@ -313,7 +313,7 @@ typedef struct SCheckpointInfo {
|
||||||
int64_t failedId; // record the latest failed checkpoint id
|
int64_t failedId; // record the latest failed checkpoint id
|
||||||
int64_t checkpointingId;
|
int64_t checkpointingId;
|
||||||
int32_t downstreamAlignNum;
|
int32_t downstreamAlignNum;
|
||||||
int32_t checkpointNotReadyTasks;
|
int32_t numOfNotReady;
|
||||||
bool dispatchCheckpointTrigger;
|
bool dispatchCheckpointTrigger;
|
||||||
int64_t msgVer;
|
int64_t msgVer;
|
||||||
int32_t transId;
|
int32_t transId;
|
||||||
|
|
|
@ -575,8 +575,6 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_GRANT_OPT_EXPIRE_TOO_LARGE TAOS_DEF_ERROR_CODE(0, 0x0821)
|
#define TSDB_CODE_GRANT_OPT_EXPIRE_TOO_LARGE TAOS_DEF_ERROR_CODE(0, 0x0821)
|
||||||
#define TSDB_CODE_GRANT_DUPLICATED_ACTIVE TAOS_DEF_ERROR_CODE(0, 0x0822)
|
#define TSDB_CODE_GRANT_DUPLICATED_ACTIVE TAOS_DEF_ERROR_CODE(0, 0x0822)
|
||||||
#define TSDB_CODE_GRANT_VIEW_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0823)
|
#define TSDB_CODE_GRANT_VIEW_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0823)
|
||||||
#define TSDB_CODE_GRANT_CSV_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0824)
|
|
||||||
#define TSDB_CODE_GRANT_AUDIT_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0825)
|
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
||||||
|
|
|
@ -287,6 +287,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_DNODE_VALUE_LEN 256
|
#define TSDB_DNODE_VALUE_LEN 256
|
||||||
|
|
||||||
#define TSDB_CLUSTER_VALUE_LEN 1000
|
#define TSDB_CLUSTER_VALUE_LEN 1000
|
||||||
|
#define TSDB_GRANT_LOG_COL_LEN 15600
|
||||||
|
|
||||||
#define TSDB_ACTIVE_KEY_LEN 109
|
#define TSDB_ACTIVE_KEY_LEN 109
|
||||||
#define TSDB_CONN_ACTIVE_KEY_LEN 255
|
#define TSDB_CONN_ACTIVE_KEY_LEN 255
|
||||||
|
|
|
@ -843,7 +843,7 @@ int32_t hbGetExpiredViewInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, S
|
||||||
view->version = htonl(view->version);
|
view->version = htonl(view->version);
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDebug("hb got %d expired view, valueLen:%lu", viewNum, sizeof(SViewVersion) * viewNum);
|
tscDebug("hb got %u expired view, valueLen:%lu", viewNum, sizeof(SViewVersion) * viewNum);
|
||||||
|
|
||||||
if (NULL == req->info) {
|
if (NULL == req->info) {
|
||||||
req->info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
req->info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
||||||
|
|
|
@ -1154,6 +1154,8 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat
|
||||||
.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp),
|
.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp),
|
||||||
.pAstRoot = pQuery->pRoot,
|
.pAstRoot = pQuery->pRoot,
|
||||||
.showRewrite = pQuery->showRewrite,
|
.showRewrite = pQuery->showRewrite,
|
||||||
|
.isView = pWrapper->pParseCtx->isView,
|
||||||
|
.isAudit = pWrapper->pParseCtx->isAudit,
|
||||||
.pMsg = pRequest->msgBuf,
|
.pMsg = pRequest->msgBuf,
|
||||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||||
.pUser = pRequest->pTscObj->user,
|
.pUser = pRequest->pTscObj->user,
|
||||||
|
|
|
@ -349,21 +349,21 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema useGrantsFullSchema[] = {
|
static const SSysDbTableSchema useGrantsFullSchema[] = {
|
||||||
{.name = "grant_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "grant_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "display_name", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "display_name", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "expire", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "expire", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "limits", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "limits", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema useGrantsLogsSchema[] = {
|
static const SSysDbTableSchema useGrantsLogsSchema[] = {
|
||||||
{.name = "state", .bytes = 1536 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "state", .bytes = 1536 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "active", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "active", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "machine", .bytes = 9088 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "machine", .bytes = TSDB_GRANT_LOG_COL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema useMachinesSchema[] = {
|
static const SSysDbTableSchema useMachinesSchema[] = {
|
||||||
{.name = "id", .bytes = TSDB_CLUSTER_ID_LEN + 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
{.name = "id", .bytes = TSDB_CLUSTER_ID_LEN + 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "machine", .bytes = 6016 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
{.name = "machine", .bytes = 7552 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysTableMeta infosMeta[] = {
|
static const SSysTableMeta infosMeta[] = {
|
||||||
|
|
|
@ -1801,4 +1801,17 @@ void taosSetAllDebugFlag(int32_t flag) {
|
||||||
if (terrno == TSDB_CODE_CFG_NOT_FOUND) terrno = TSDB_CODE_SUCCESS; // ignore not exist
|
if (terrno == TSDB_CODE_CFG_NOT_FOUND) terrno = TSDB_CODE_SUCCESS; // ignore not exist
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t taosGranted() { return atomic_load_8(&tsGrant); }
|
int8_t taosGranted(int8_t type) {
|
||||||
|
switch (type) {
|
||||||
|
case TSDB_GRANT_ALL:
|
||||||
|
return atomic_load_8(&tsGrant) & GRANT_FLAG_ALL;
|
||||||
|
case TSDB_GRANT_AUDIT:
|
||||||
|
return atomic_load_8(&tsGrant) & GRANT_FLAG_AUDIT;
|
||||||
|
case TSDB_GRANT_VIEW:
|
||||||
|
return atomic_load_8(&tsGrant) & GRANT_FLAG_VIEW;
|
||||||
|
default:
|
||||||
|
ASSERTS(0, "undefined grant type:%" PRIi8, type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -19,5 +19,13 @@
|
||||||
#ifndef _GRANT
|
#ifndef _GRANT
|
||||||
|
|
||||||
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||||
|
int32_t grantCheckExpire(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||||
|
|
||||||
|
#ifdef TD_UNIQ_GRANT
|
||||||
|
int32_t grantCheckLE(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef TD_UNIQ_GRANT
|
||||||
|
int32_t grantCheckExpire(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
|
@ -556,7 +556,7 @@ typedef struct {
|
||||||
} SMqConsumerObj;
|
} SMqConsumerObj;
|
||||||
|
|
||||||
SMqConsumerObj* tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]);
|
SMqConsumerObj* tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]);
|
||||||
void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer, bool delete);
|
void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer, bool isDeleted);
|
||||||
int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer);
|
int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer);
|
||||||
void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer, int8_t sver);
|
void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer, int8_t sver);
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,8 @@
|
||||||
int32_t mndGrantActionDelete(SSdb * pSdb, SGrantLogObj * pGrant);
|
int32_t mndGrantActionDelete(SSdb * pSdb, SGrantLogObj * pGrant);
|
||||||
int32_t mndGrantActionUpdate(SSdb * pSdb, SGrantLogObj * pOldGrant, SGrantLogObj * pNewGrant);
|
int32_t mndGrantActionUpdate(SSdb * pSdb, SGrantLogObj * pOldGrant, SGrantLogObj * pNewGrant);
|
||||||
|
|
||||||
#ifdef TD_UNIQ_GRANT
|
|
||||||
int32_t grantAlterActiveCode(SMnode * pMnode, SGrantLogObj * pObj, const char *oldActive, const char *newActive,
|
int32_t grantAlterActiveCode(SMnode * pMnode, SGrantLogObj * pObj, const char *oldActive, const char *newActive,
|
||||||
char **mergeActive);
|
char **mergeActive);
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t mndProcessConfigGrantReq(SMnode * pMnode, SRpcMsg * pReq, SMCfgClusterReq * pCfg);
|
int32_t mndProcessConfigGrantReq(SMnode * pMnode, SRpcMsg * pReq, SMCfgClusterReq * pCfg);
|
||||||
int32_t mndProcessUpdGrantLog(SMnode * pMnode, SRpcMsg * pReq, SArray * pMachines, SGrantState * pState);
|
int32_t mndProcessUpdGrantLog(SMnode * pMnode, SRpcMsg * pReq, SArray * pMachines, SGrantState * pState);
|
||||||
|
|
|
@ -124,6 +124,7 @@ SStreamTaskIter *createStreamTaskIter(SStreamObj *pStream);
|
||||||
void destroyStreamTaskIter(SStreamTaskIter *pIter);
|
void destroyStreamTaskIter(SStreamTaskIter *pIter);
|
||||||
bool streamTaskIterNextTask(SStreamTaskIter *pIter);
|
bool streamTaskIterNextTask(SStreamTaskIter *pIter);
|
||||||
SStreamTask *streamTaskIterGetCurrent(SStreamTaskIter *pIter);
|
SStreamTask *streamTaskIterGetCurrent(SStreamTaskIter *pIter);
|
||||||
|
void mndInitExecInfo();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,9 +82,11 @@ void mndTransSetSerial(STrans *pTrans);
|
||||||
void mndTransSetParallel(STrans *pTrans);
|
void mndTransSetParallel(STrans *pTrans);
|
||||||
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
||||||
int32_t mndTransCheckConflict(SMnode *pMnode, STrans *pTrans);
|
int32_t mndTransCheckConflict(SMnode *pMnode, STrans *pTrans);
|
||||||
|
#ifndef BUILD_NO_CALL
|
||||||
static int32_t mndTrancCheckConflict(SMnode *pMnode, STrans *pTrans) {
|
static int32_t mndTrancCheckConflict(SMnode *pMnode, STrans *pTrans) {
|
||||||
return mndTransCheckConflict(pMnode, pTrans);
|
return mndTransCheckConflict(pMnode, pTrans);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
|
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
|
||||||
int32_t mndTransProcessRsp(SRpcMsg *pRsp);
|
int32_t mndTransProcessRsp(SRpcMsg *pRsp);
|
||||||
void mndTransPullup(SMnode *pMnode);
|
void mndTransPullup(SMnode *pMnode);
|
||||||
|
|
|
@ -409,7 +409,7 @@ int32_t mndProcessConfigClusterReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // audit
|
{ // audit
|
||||||
auditRecord(pReq, pMnode->clusterId, "alterCluster", "", "", cfgReq.sql, cfgReq.sqlLen);
|
auditRecord(pReq, pMnode->clusterId, "alterCluster", "", "", cfgReq.sql, TMIN(cfgReq.sqlLen, GRANT_ACTIVE_HEAD_LEN << 1));
|
||||||
}
|
}
|
||||||
_exit:
|
_exit:
|
||||||
tFreeSMCfgClusterReq(&cfgReq);
|
tFreeSMCfgClusterReq(&cfgReq);
|
||||||
|
|
|
@ -107,7 +107,7 @@ static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode *
|
||||||
goto FAILED;
|
goto FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((terrno = grantCheck(TSDB_GRANT_SUBSCRIPTION)) < 0) {
|
if ((terrno = grantCheckExpire(TSDB_GRANT_SUBSCRIPTION)) < 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto FAILED;
|
goto FAILED;
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,8 @@ static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbR
|
||||||
}
|
}
|
||||||
STopicPrivilege *data = taosArrayReserve(rsp->topicPrivileges, 1);
|
STopicPrivilege *data = taosArrayReserve(rsp->topicPrivileges, 1);
|
||||||
strcpy(data->topic, topic);
|
strcpy(data->topic, topic);
|
||||||
if (mndCheckTopicPrivilege(pMnode, user, MND_OPER_SUBSCRIBE, pTopic) != 0 || grantCheck(TSDB_GRANT_SUBSCRIPTION) < 0) {
|
if (mndCheckTopicPrivilege(pMnode, user, MND_OPER_SUBSCRIBE, pTopic) != 0 ||
|
||||||
|
grantCheckExpire(TSDB_GRANT_SUBSCRIPTION) < 0) {
|
||||||
data->noPrivilege = 1;
|
data->noPrivilege = 1;
|
||||||
} else {
|
} else {
|
||||||
data->noPrivilege = 0;
|
data->noPrivilege = 0;
|
||||||
|
|
|
@ -141,7 +141,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
|
||||||
memcpy(dnodeObj.machineId, machineId, TSDB_MACHINE_ID_LEN);
|
memcpy(dnodeObj.machineId, machineId, TSDB_MACHINE_ID_LEN);
|
||||||
taosMemoryFreeClear(machineId);
|
taosMemoryFreeClear(machineId);
|
||||||
} else {
|
} else {
|
||||||
#ifdef TD_UNIQ_GRANT
|
#ifdef TD_ENTERPRISE
|
||||||
terrno = TSDB_CODE_DNODE_NO_MACHINE_CODE;
|
terrno = TSDB_CODE_DNODE_NO_MACHINE_CODE;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -79,11 +79,6 @@ char *tGetMachineId() { return NULL; };
|
||||||
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
||||||
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
||||||
int32_t mndProcessConfigGrantReq(SMnode *pMnode, SRpcMsg *pReq, SMCfgClusterReq *pCfg) { return 0; }
|
int32_t mndProcessConfigGrantReq(SMnode *pMnode, SRpcMsg *pReq, SMCfgClusterReq *pCfg) { return 0; }
|
||||||
#else
|
|
||||||
#ifndef TD_UNIQ_GRANT
|
|
||||||
char *tGetMachineId() { return NULL; };
|
|
||||||
int32_t mndProcessConfigGrantReq(SMnode *pMnode, SRpcMsg *pReq, SMCfgClusterReq *pCfg) { return 0; }
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void mndGenerateMachineCode() { grantParseParameter(); }
|
void mndGenerateMachineCode() { grantParseParameter(); }
|
|
@ -62,8 +62,6 @@ static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pP
|
||||||
static void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
static void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
||||||
static int32_t removeExpirednodeEntryAndTask(SArray *pNodeSnapshot);
|
static int32_t removeExpirednodeEntryAndTask(SArray *pNodeSnapshot);
|
||||||
static int32_t doKillCheckpointTrans(SMnode *pMnode, const char *pDbName, size_t len);
|
static int32_t doKillCheckpointTrans(SMnode *pMnode, const char *pDbName, size_t len);
|
||||||
static void freeCheckpointCandEntry(void *);
|
|
||||||
static void freeTaskList(void *param);
|
|
||||||
static SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
static SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
||||||
|
|
||||||
SSdbRaw *mndStreamSeqActionEncode(SStreamObj *pStream);
|
SSdbRaw *mndStreamSeqActionEncode(SStreamObj *pStream);
|
||||||
|
@ -121,17 +119,7 @@ int32_t mndInitStream(SMnode *pMnode) {
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndRetrieveStreamTask);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndRetrieveStreamTask);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndCancelGetNextStreamTask);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndCancelGetNextStreamTask);
|
||||||
|
|
||||||
taosThreadMutexInit(&execInfo.lock, NULL);
|
mndInitExecInfo();
|
||||||
_hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR);
|
|
||||||
|
|
||||||
execInfo.pTaskList = taosArrayInit(4, sizeof(STaskId));
|
|
||||||
execInfo.pTaskMap = taosHashInit(64, fn, true, HASH_NO_LOCK);
|
|
||||||
execInfo.transMgmt.pDBTrans = taosHashInit(32, fn, true, HASH_NO_LOCK);
|
|
||||||
execInfo.transMgmt.pWaitingList = taosHashInit(32, fn, true, HASH_NO_LOCK);
|
|
||||||
execInfo.pTransferStateStreams = taosHashInit(32, fn, true, HASH_NO_LOCK);
|
|
||||||
|
|
||||||
taosHashSetFreeFp(execInfo.transMgmt.pWaitingList, freeCheckpointCandEntry);
|
|
||||||
taosHashSetFreeFp(execInfo.pTransferStateStreams, freeTaskList);
|
|
||||||
|
|
||||||
if (sdbSetTable(pMnode->pSdb, table) != 0) {
|
if (sdbSetTable(pMnode->pSdb, table) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1628,7 +1616,7 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
|
|
||||||
if(grantCheck(TSDB_GRANT_STREAMS) < 0){
|
if(grantCheckExpire(TSDB_GRANT_STREAMS) < 0){
|
||||||
terrno = TSDB_CODE_GRANT_EXPIRED;
|
terrno = TSDB_CODE_GRANT_EXPIRED;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2117,16 +2105,6 @@ void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode) {
|
||||||
ASSERT(taosHashGetSize(pExecNode->pTaskMap) == taosArrayGetSize(pExecNode->pTaskList));
|
ASSERT(taosHashGetSize(pExecNode->pTaskMap) == taosArrayGetSize(pExecNode->pTaskList));
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeCheckpointCandEntry(void *param) {
|
|
||||||
SCheckpointCandEntry *pEntry = param;
|
|
||||||
taosMemoryFreeClear(pEntry->pName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void freeTaskList(void* param) {
|
|
||||||
SArray** pList = (SArray **)param;
|
|
||||||
taosArrayDestroy(*pList);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void doAddTaskId(SArray* pList, int32_t taskId, int64_t uid, int32_t numOfTotal) {
|
static void doAddTaskId(SArray* pList, int32_t taskId, int64_t uid, int32_t numOfTotal) {
|
||||||
int32_t num = taosArrayGetSize(pList);
|
int32_t num = taosArrayGetSize(pList);
|
||||||
for(int32_t i = 0; i < num; ++i) {
|
for(int32_t i = 0; i < num; ++i) {
|
||||||
|
|
|
@ -225,7 +225,7 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
SArray *pFailedTasks = taosArrayInit(4, sizeof(SFailedCheckpointInfo));
|
SArray *pFailedTasks = taosArrayInit(4, sizeof(SFailedCheckpointInfo));
|
||||||
SArray *pOrphanTasks = taosArrayInit(3, sizeof(SOrphanTask));
|
SArray *pOrphanTasks = taosArrayInit(3, sizeof(SOrphanTask));
|
||||||
|
|
||||||
if(grantCheck(TSDB_GRANT_STREAMS) < 0){
|
if(grantCheckExpire(TSDB_GRANT_STREAMS) < 0){
|
||||||
if(suspendAllStreams(pMnode, &pReq->info) < 0){
|
if(suspendAllStreams(pMnode, &pReq->info) < 0){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -317,8 +317,12 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
// kill the checkpoint trans and then set all tasks status to be normal
|
// kill the checkpoint trans and then set all tasks status to be normal
|
||||||
if (taosArrayGetSize(pFailedTasks) > 0) {
|
if (taosArrayGetSize(pFailedTasks) > 0) {
|
||||||
bool allReady = true;
|
bool allReady = true;
|
||||||
|
if (pMnode != NULL) {
|
||||||
SArray *p = mndTakeVgroupSnapshot(pMnode, &allReady);
|
SArray *p = mndTakeVgroupSnapshot(pMnode, &allReady);
|
||||||
taosArrayDestroy(p);
|
taosArrayDestroy(p);
|
||||||
|
} else {
|
||||||
|
allReady = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (allReady || snodeChanged) {
|
if (allReady || snodeChanged) {
|
||||||
// if the execInfo.activeCheckpoint == 0, the checkpoint is restoring from wal
|
// if the execInfo.activeCheckpoint == 0, the checkpoint is restoring from wal
|
||||||
|
|
|
@ -543,3 +543,27 @@ int32_t mndStreamSetResetTaskAction(SMnode *pMnode, STrans *pTrans, SStreamObj *
|
||||||
taosWUnLockLatch(&pStream->lock);
|
taosWUnLockLatch(&pStream->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void freeCheckpointCandEntry(void *param) {
|
||||||
|
SCheckpointCandEntry *pEntry = param;
|
||||||
|
taosMemoryFreeClear(pEntry->pName);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void freeTaskList(void* param) {
|
||||||
|
SArray** pList = (SArray **)param;
|
||||||
|
taosArrayDestroy(*pList);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mndInitExecInfo() {
|
||||||
|
taosThreadMutexInit(&execInfo.lock, NULL);
|
||||||
|
_hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR);
|
||||||
|
|
||||||
|
execInfo.pTaskList = taosArrayInit(4, sizeof(STaskId));
|
||||||
|
execInfo.pTaskMap = taosHashInit(64, fn, true, HASH_NO_LOCK);
|
||||||
|
execInfo.transMgmt.pDBTrans = taosHashInit(32, fn, true, HASH_NO_LOCK);
|
||||||
|
execInfo.transMgmt.pWaitingList = taosHashInit(32, fn, true, HASH_NO_LOCK);
|
||||||
|
execInfo.pTransferStateStreams = taosHashInit(32, fn, true, HASH_NO_LOCK);
|
||||||
|
|
||||||
|
taosHashSetFreeFp(execInfo.transMgmt.pWaitingList, freeCheckpointCandEntry);
|
||||||
|
taosHashSetFreeFp(execInfo.pTransferStateStreams, freeTaskList);
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ add_subdirectory(acct)
|
||||||
#add_subdirectory(db)
|
#add_subdirectory(db)
|
||||||
#add_subdirectory(dnode)
|
#add_subdirectory(dnode)
|
||||||
add_subdirectory(func)
|
add_subdirectory(func)
|
||||||
#add_subdirectory(mnode)
|
add_subdirectory(stream)
|
||||||
add_subdirectory(profile)
|
add_subdirectory(profile)
|
||||||
add_subdirectory(qnode)
|
add_subdirectory(qnode)
|
||||||
add_subdirectory(sdb)
|
add_subdirectory(sdb)
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
SET(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
aux_source_directory(. MNODE_STREAM_TEST_SRC)
|
||||||
|
add_executable(streamTest ${MNODE_STREAM_TEST_SRC})
|
||||||
|
target_link_libraries(
|
||||||
|
streamTest
|
||||||
|
PRIVATE dnode gtest
|
||||||
|
)
|
||||||
|
|
||||||
|
add_test(
|
||||||
|
NAME streamTest
|
||||||
|
COMMAND streamTest
|
||||||
|
)
|
|
@ -0,0 +1,155 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
|
||||||
|
#include <libs/stream/tstream.h>
|
||||||
|
#include <libs/transport/trpc.h>
|
||||||
|
#include "../../inc/mndStream.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
SRpcMsg buildHbReq() {
|
||||||
|
SStreamHbMsg msg = {0};
|
||||||
|
msg.vgId = 1;
|
||||||
|
msg.numOfTasks = 5;
|
||||||
|
msg.pTaskStatus = taosArrayInit(4, sizeof(STaskStatusEntry));
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < 4; ++i) {
|
||||||
|
STaskStatusEntry entry = {0};
|
||||||
|
entry.nodeId = i + 1;
|
||||||
|
entry.stage = 1;
|
||||||
|
entry.id.taskId = i + 1;
|
||||||
|
entry.id.streamId = 999;
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
|
entry.stage = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayPush(msg.pTaskStatus, &entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// (p->checkpointId != 0) && p->checkpointFailed
|
||||||
|
// add failed checkpoint info
|
||||||
|
{
|
||||||
|
STaskStatusEntry entry = {0};
|
||||||
|
entry.nodeId = 5;
|
||||||
|
entry.stage = 1;
|
||||||
|
|
||||||
|
entry.id.taskId = 5;
|
||||||
|
entry.id.streamId = 999;
|
||||||
|
|
||||||
|
entry.checkpointId = 1;
|
||||||
|
entry.checkpointFailed = true;
|
||||||
|
|
||||||
|
taosArrayPush(msg.pTaskStatus, &entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tlen = 0;
|
||||||
|
int32_t code = 0;
|
||||||
|
SEncoder encoder;
|
||||||
|
void* buf = NULL;
|
||||||
|
SRpcMsg msg1 = {0};
|
||||||
|
msg1.info.noResp = 1;
|
||||||
|
|
||||||
|
tEncodeSize(tEncodeStreamHbMsg, &msg, tlen, code);
|
||||||
|
if (code < 0) {
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = rpcMallocCont(tlen);
|
||||||
|
if (buf == NULL) {
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
|
tEncoderInit(&encoder, (uint8_t*)buf, tlen);
|
||||||
|
if ((code = tEncodeStreamHbMsg(&encoder, &msg)) < 0) {
|
||||||
|
rpcFreeCont(buf);
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
|
initRpcMsg(&msg1, TDMT_MND_STREAM_HEARTBEAT, buf, tlen);
|
||||||
|
|
||||||
|
taosArrayDestroy(msg.pTaskStatus);
|
||||||
|
return msg1;
|
||||||
|
|
||||||
|
_end:
|
||||||
|
return msg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTask(SStreamTask* pTask, int32_t nodeId, int64_t streamId, int32_t taskId) {
|
||||||
|
SStreamExecInfo* pExecNode = &execInfo;
|
||||||
|
|
||||||
|
pTask->id.streamId = streamId;
|
||||||
|
pTask->id.taskId = taskId;
|
||||||
|
pTask->info.nodeId = nodeId;
|
||||||
|
|
||||||
|
STaskId id;
|
||||||
|
id.streamId = pTask->id.streamId;
|
||||||
|
id.taskId = pTask->id.taskId;
|
||||||
|
|
||||||
|
STaskStatusEntry entry;
|
||||||
|
streamTaskStatusInit(&entry, pTask);
|
||||||
|
|
||||||
|
entry.stage = 1;
|
||||||
|
entry.status = TASK_STATUS__READY;
|
||||||
|
|
||||||
|
taosHashPut(pExecNode->pTaskMap, &id, sizeof(id), &entry, sizeof(entry));
|
||||||
|
taosArrayPush(pExecNode->pTaskList, &id);
|
||||||
|
}
|
||||||
|
void initStreamExecInfo() {
|
||||||
|
SStreamExecInfo* pExecNode = &execInfo;
|
||||||
|
|
||||||
|
SStreamTask task = {0};
|
||||||
|
setTask(&task, 1, 999, 1);
|
||||||
|
setTask(&task, 1, 999, 2);
|
||||||
|
setTask(&task, 1, 999, 3);
|
||||||
|
setTask(&task, 1, 999, 4);
|
||||||
|
setTask(&task, 2, 999, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void initNodeInfo() {
|
||||||
|
execInfo.pNodeList = taosArrayInit(4, sizeof(SNodeEntry));
|
||||||
|
SNodeEntry entry = {0};
|
||||||
|
entry.nodeId = 2;
|
||||||
|
entry.stageUpdated = true;
|
||||||
|
taosArrayPush(execInfo.pNodeList, &entry);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(mndHbTest, handle_error_in_hb) {
|
||||||
|
mndInitExecInfo();
|
||||||
|
initStreamExecInfo();
|
||||||
|
initNodeInfo();
|
||||||
|
|
||||||
|
SRpcMsg msg = buildHbReq();
|
||||||
|
int32_t code = mndProcessStreamHb(&msg);
|
||||||
|
|
||||||
|
rpcFreeCont(msg.pCont);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic pop
|
|
@ -90,6 +90,8 @@ int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num);
|
||||||
int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num);
|
int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num);
|
||||||
int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num);
|
int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num);
|
||||||
|
|
||||||
|
int32_t vnodeGetTableSchema(void *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
||||||
|
|
||||||
void vnodeResetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
void vnodeResetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
||||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
||||||
int32_t vnodeGetLoadLite(SVnode *pVnode, SVnodeLoadLite *pLoad);
|
int32_t vnodeGetLoadLite(SVnode *pVnode, SVnodeLoadLite *pLoad);
|
||||||
|
@ -180,7 +182,6 @@ int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList,
|
||||||
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, const int32_t *dstSlotIds,
|
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, const int32_t *dstSlotIds,
|
||||||
SArray *pTableUids);
|
SArray *pTableUids);
|
||||||
void *tsdbCacherowsReaderClose(void *pReader);
|
void *tsdbCacherowsReaderClose(void *pReader);
|
||||||
int32_t tsdbGetTableSchema(void *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
|
||||||
|
|
||||||
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
||||||
size_t tsdbCacheGetCapacity(SVnode *pVnode);
|
size_t tsdbCacheGetCapacity(SVnode *pVnode);
|
||||||
|
@ -233,6 +234,7 @@ int32_t tqReaderSetSubmitMsg(STqReader *pReader, void *msgStr, int32_t msgLen, i
|
||||||
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
|
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
|
||||||
int32_t tqRetrieveDataBlock(STqReader *pReader, SSDataBlock **pRes, const char *idstr);
|
int32_t tqRetrieveDataBlock(STqReader *pReader, SSDataBlock **pRes, const char *idstr);
|
||||||
int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas, SSubmitTbData **pSubmitTbDataRet);
|
int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas, SSubmitTbData **pSubmitTbDataRet);
|
||||||
|
int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, bool* fhFinished);
|
||||||
|
|
||||||
// sma
|
// sma
|
||||||
int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days);
|
int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days);
|
||||||
|
|
|
@ -97,7 +97,6 @@ typedef struct {
|
||||||
struct STQ {
|
struct STQ {
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
char* path;
|
char* path;
|
||||||
int64_t walLogLastVer;
|
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
SHashObj* pPushMgr; // subKey -> STqHandle
|
SHashObj* pPushMgr; // subKey -> STqHandle
|
||||||
SHashObj* pHandle; // subKey -> STqHandle
|
SHashObj* pHandle; // subKey -> STqHandle
|
||||||
|
@ -153,13 +152,13 @@ char* tqOffsetBuildFName(const char* path, int32_t fVer);
|
||||||
int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname);
|
int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname);
|
||||||
|
|
||||||
// tq util
|
// tq util
|
||||||
int32_t extractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type);
|
int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type);
|
||||||
int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg);
|
int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg);
|
||||||
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp* pRsp, int32_t epoch, int64_t consumerId,
|
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp* pRsp, int32_t epoch, int64_t consumerId,
|
||||||
int32_t type, int64_t sver, int64_t ever);
|
int32_t type, int64_t sver, int64_t ever);
|
||||||
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset);
|
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset);
|
||||||
void tqUpdateNodeStage(STQ* pTq, bool isLeader);
|
void tqUpdateNodeStage(STQ* pTq, bool isLeader);
|
||||||
int32_t setDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
||||||
SSubmitTbData* pTableData, const char* id);
|
SSubmitTbData* pTableData, const char* id);
|
||||||
int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, const char* id);
|
int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, const char* id);
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,7 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx);
|
||||||
// tsdbRead.c ==============================================================================================
|
// tsdbRead.c ==============================================================================================
|
||||||
int32_t tsdbTakeReadSnap2(STsdbReader *pReader, _query_reseek_func_t reseek, STsdbReadSnap **ppSnap);
|
int32_t tsdbTakeReadSnap2(STsdbReader *pReader, _query_reseek_func_t reseek, STsdbReadSnap **ppSnap);
|
||||||
void tsdbUntakeReadSnap2(STsdbReader *pReader, STsdbReadSnap *pSnap, bool proactive);
|
void tsdbUntakeReadSnap2(STsdbReader *pReader, STsdbReadSnap *pSnap, bool proactive);
|
||||||
|
int32_t tsdbGetTableSchema(SMeta* pMeta, int64_t uid, STSchema** pSchema, int64_t* suid);
|
||||||
|
|
||||||
// tsdbMerge.c ==============================================================================================
|
// tsdbMerge.c ==============================================================================================
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -942,8 +943,6 @@ static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
|
|
||||||
TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter);
|
TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter);
|
||||||
|
|
||||||
int32_t tRowInfoCmprFn(const void *p1, const void *p2);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t suid;
|
int64_t suid;
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
|
|
|
@ -1554,7 +1554,7 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
|
||||||
}
|
}
|
||||||
_resume_delete:
|
_resume_delete:
|
||||||
version = RSMA_EXEC_MSG_VER(msg);
|
version = RSMA_EXEC_MSG_VER(msg);
|
||||||
if ((terrno = extractDelDataBlock(RSMA_EXEC_MSG_BODY(msg), RSMA_EXEC_MSG_LEN(msg), version,
|
if ((terrno = tqExtractDelDataBlock(RSMA_EXEC_MSG_BODY(msg), RSMA_EXEC_MSG_LEN(msg), version,
|
||||||
&packData.pDataBlock, 1))) {
|
&packData.pDataBlock, 1))) {
|
||||||
taosFreeQitem(msg);
|
taosFreeQitem(msg);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
|
@ -203,7 +203,7 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *
|
||||||
|
|
||||||
int32_t *index = taosHashGet(pTableIndexMap, &groupId, sizeof(groupId));
|
int32_t *index = taosHashGet(pTableIndexMap, &groupId, sizeof(groupId));
|
||||||
if (index == NULL) { // no data yet, append it
|
if (index == NULL) { // no data yet, append it
|
||||||
code = setDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, "");
|
code = tqSetDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, "");
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *
|
||||||
int32_t size = (int32_t)taosArrayGetSize(pReq->aSubmitTbData) - 1;
|
int32_t size = (int32_t)taosArrayGetSize(pReq->aSubmitTbData) - 1;
|
||||||
taosHashPut(pTableIndexMap, &groupId, sizeof(groupId), &size, sizeof(size));
|
taosHashPut(pTableIndexMap, &groupId, sizeof(groupId), &size, sizeof(size));
|
||||||
} else {
|
} else {
|
||||||
code = setDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, "");
|
code = tqSetDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, "");
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ STQ* tqOpen(const char* path, SVnode* pVnode) {
|
||||||
|
|
||||||
pTq->path = taosStrdup(path);
|
pTq->path = taosStrdup(path);
|
||||||
pTq->pVnode = pVnode;
|
pTq->pVnode = pVnode;
|
||||||
pTq->walLogLastVer = pVnode->pWal->vers.lastVer;
|
|
||||||
|
|
||||||
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||||
taosHashSetFreeFp(pTq->pHandle, tqDestroyTqHandle);
|
taosHashSetFreeFp(pTq->pHandle, tqDestroyTqHandle);
|
||||||
|
@ -1055,7 +1054,7 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
int32_t code = tqStreamTaskProcessRunReq(pTq->pStreamMeta, pMsg, vnodeIsRoleLeader(pTq->pVnode));
|
int32_t code = tqStreamTaskProcessRunReq(pTq->pStreamMeta, pMsg, vnodeIsRoleLeader(pTq->pVnode));
|
||||||
|
|
||||||
// let's continue scan data in the wal files
|
// let's continue scan data in the wal files
|
||||||
if(code == 0 && pReq->reqType >= 0){
|
if (code == 0 && (pReq->reqType >= 0 || pReq->reqType == STREAM_EXEC_T_RESUME_TASK)) {
|
||||||
tqScanWalAsync(pTq, false);
|
tqScanWalAsync(pTq, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -344,7 +344,7 @@ int32_t extractMsgFromWal(SWalReader* pReader, void** pItem, int64_t maxVer, con
|
||||||
void* pBody = POINTER_SHIFT(pCont->body, sizeof(SMsgHead));
|
void* pBody = POINTER_SHIFT(pCont->body, sizeof(SMsgHead));
|
||||||
int32_t len = pCont->bodyLen - sizeof(SMsgHead);
|
int32_t len = pCont->bodyLen - sizeof(SMsgHead);
|
||||||
|
|
||||||
code = extractDelDataBlock(pBody, len, ver, (void**)pItem, 0);
|
code = tqExtractDelDataBlock(pBody, len, ver, (void**)pItem, 0);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
if (*pItem == NULL) {
|
if (*pItem == NULL) {
|
||||||
tqDebug("s-task:%s empty delete msg, discard it, len:%d, ver:%" PRId64, id, len, ver);
|
tqDebug("s-task:%s empty delete msg, discard it, len:%d, ver:%" PRId64, id, len, ver);
|
||||||
|
|
|
@ -746,7 +746,7 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t setDstTableDataPayload(uint64_t suid, const STSchema *pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema *pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
||||||
SSubmitTbData* pTableData, const char* id) {
|
SSubmitTbData* pTableData, const char* id) {
|
||||||
int32_t numOfRows = pDataBlock->info.rows;
|
int32_t numOfRows = pDataBlock->info.rows;
|
||||||
|
|
||||||
|
@ -821,7 +821,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = setDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, id);
|
code = tqSetDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, id);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -868,7 +868,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = setDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, id);
|
code = tqSetDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, id);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -878,7 +878,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) {
|
||||||
int32_t size = (int32_t)taosArrayGetSize(submitReq.aSubmitTbData) - 1;
|
int32_t size = (int32_t)taosArrayGetSize(submitReq.aSubmitTbData) - 1;
|
||||||
taosHashPut(pTableIndexMap, &groupId, sizeof(groupId), &size, sizeof(size));
|
taosHashPut(pTableIndexMap, &groupId, sizeof(groupId), &size, sizeof(size));
|
||||||
} else {
|
} else {
|
||||||
code = setDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, id);
|
code = tqSetDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, id);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,7 +388,7 @@ int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp*
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t extractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type) {
|
int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type) {
|
||||||
SDecoder* pCoder = &(SDecoder){0};
|
SDecoder* pCoder = &(SDecoder){0};
|
||||||
SDeleteRes* pRes = &(SDeleteRes){0};
|
SDeleteRes* pRes = &(SDeleteRes){0};
|
||||||
|
|
||||||
|
@ -449,3 +449,73 @@ int32_t extractDelDataBlock(const void* pData, int32_t len, int64_t ver, void**
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, bool* fhFinished) {
|
||||||
|
SStreamMeta* pMeta = pVnode->pTq->pStreamMeta;
|
||||||
|
int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList);
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
if (pDelay != NULL) {
|
||||||
|
*pDelay = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*fhFinished = false;
|
||||||
|
|
||||||
|
if (numOfTasks <= 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract the required source task for a given stream, identified by streamId
|
||||||
|
for (int32_t i = 0; i < numOfTasks; ++i) {
|
||||||
|
STaskId* pId = taosArrayGet(pMeta->pTaskList, i);
|
||||||
|
if (pId->streamId != streamId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, pId, sizeof(*pId));
|
||||||
|
if (ppTask == NULL) {
|
||||||
|
tqError("vgId:%d failed to acquire task:0x%" PRIx64 " in retrieving progress", pMeta->vgId, pId->taskId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*ppTask)->info.taskLevel != TASK_LEVEL__SOURCE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// here we get the required stream source task
|
||||||
|
SStreamTask* pTask = *ppTask;
|
||||||
|
*fhFinished = !HAS_RELATED_FILLHISTORY_TASK(pTask);
|
||||||
|
|
||||||
|
int64_t ver = walReaderGetCurrentVer(pTask->exec.pWalReader);
|
||||||
|
|
||||||
|
SVersionRange verRange = {0};
|
||||||
|
walReaderValidVersionRange(pTask->exec.pWalReader, &verRange.minVer, &verRange.maxVer);
|
||||||
|
|
||||||
|
SWalReader* pReader = walOpenReader(pTask->exec.pWalReader->pWal, NULL, 0);
|
||||||
|
if (pReader == NULL) {
|
||||||
|
tqError("failed to open wal reader to extract exec progress, vgId:%d", pMeta->vgId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t cur = 0;
|
||||||
|
int64_t latest = 0;
|
||||||
|
|
||||||
|
code = walFetchHead(pReader, ver);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
cur = pReader->pHead->head.ingestTs;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = walFetchHead(pReader, verRange.maxVer);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
latest = pReader->pHead->head.ingestTs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pDelay != NULL) { // delay in ms
|
||||||
|
*pDelay = (latest - cur) / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
walCloseReader(pReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
|
@ -719,7 +719,7 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC
|
||||||
|
|
||||||
static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCacheRowsReader *pr, int16_t *aCols,
|
static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCacheRowsReader *pr, int16_t *aCols,
|
||||||
int nCols, int16_t *slotIds);
|
int nCols, int16_t *slotIds);
|
||||||
#if 1
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t tsdbCacheGetSlow(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCacheRowsReader *pr, int8_t ltype) {
|
int32_t tsdbCacheGetSlow(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCacheRowsReader *pr, int8_t ltype) {
|
||||||
rocksdb_writebatch_t *wb = NULL;
|
rocksdb_writebatch_t *wb = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -821,7 +821,6 @@ int32_t tsdbCacheGetSlow(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCacheR
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static SLastCol *tsdbCacheLoadCol(STsdb *pTsdb, SCacheRowsReader *pr, int16_t slotid, tb_uid_t uid, int16_t cid,
|
static SLastCol *tsdbCacheLoadCol(STsdb *pTsdb, SCacheRowsReader *pr, int16_t slotid, tb_uid_t uid, int16_t cid,
|
||||||
int8_t ltype) {
|
int8_t ltype) {
|
||||||
|
@ -880,6 +879,7 @@ static SLastCol *tsdbCacheLoadCol(STsdb *pTsdb, SCacheRowsReader *pr, int16_t sl
|
||||||
|
|
||||||
return pLastCol;
|
return pLastCol;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SArray *remainCols,
|
static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SArray *remainCols,
|
||||||
SCacheRowsReader *pr, int8_t ltype) {
|
SCacheRowsReader *pr, int8_t ltype) {
|
||||||
|
@ -1359,6 +1359,7 @@ static void getTableCacheKey(tb_uid_t uid, int cacheType, char *key, int *len) {
|
||||||
*len = sizeof(uint64_t);
|
*len = sizeof(uint64_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
static void deleteTableCacheLast(const void *key, size_t keyLen, void *value, void *ud) {
|
static void deleteTableCacheLast(const void *key, size_t keyLen, void *value, void *ud) {
|
||||||
(void)ud;
|
(void)ud;
|
||||||
SArray *pLastArray = (SArray *)value;
|
SArray *pLastArray = (SArray *)value;
|
||||||
|
@ -1670,6 +1671,7 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, TSDBROW *row, STsdb
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static tb_uid_t getTableSuidByUid(tb_uid_t uid, STsdb *pTsdb) {
|
static tb_uid_t getTableSuidByUid(tb_uid_t uid, STsdb *pTsdb) {
|
||||||
tb_uid_t suid = 0;
|
tb_uid_t suid = 0;
|
||||||
|
@ -1715,6 +1717,7 @@ static int32_t getTableDelDataFromTbData(STbData *pTbData, SArray *aDelData) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
static int32_t getTableDelData(STbData *pMem, STbData *pIMem, SDelFReader *pDelReader, SDelIdx *pDelIdx,
|
static int32_t getTableDelData(STbData *pMem, STbData *pIMem, SDelFReader *pDelReader, SDelIdx *pDelIdx,
|
||||||
SArray *aDelData) {
|
SArray *aDelData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -1759,6 +1762,7 @@ _err:
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void freeTableInfoFunc(void *param) {
|
static void freeTableInfoFunc(void *param) {
|
||||||
void **p = (void **)param;
|
void **p = (void **)param;
|
||||||
|
@ -2716,6 +2720,7 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
static int32_t initLastColArray(STSchema *pTSchema, SArray **ppColArray) {
|
static int32_t initLastColArray(STSchema *pTSchema, SArray **ppColArray) {
|
||||||
SArray *pColArray = taosArrayInit(pTSchema->numOfCols, sizeof(SLastCol));
|
SArray *pColArray = taosArrayInit(pTSchema->numOfCols, sizeof(SLastCol));
|
||||||
if (NULL == pColArray) {
|
if (NULL == pColArray) {
|
||||||
|
@ -2729,6 +2734,7 @@ static int32_t initLastColArray(STSchema *pTSchema, SArray **ppColArray) {
|
||||||
*ppColArray = pColArray;
|
*ppColArray = pColArray;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int32_t initLastColArrayPartial(STSchema *pTSchema, SArray **ppColArray, int16_t *slotIds, int nCols) {
|
static int32_t initLastColArrayPartial(STSchema *pTSchema, SArray **ppColArray, int16_t *slotIds, int nCols) {
|
||||||
SArray *pColArray = taosArrayInit(nCols, sizeof(SLastCol));
|
SArray *pColArray = taosArrayInit(nCols, sizeof(SLastCol));
|
||||||
|
@ -3089,7 +3095,9 @@ void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) {
|
||||||
taosLRUCacheSetCapacity(pVnode->pTsdb->lruCache, capacity);
|
taosLRUCacheSetCapacity(pVnode->pTsdb->lruCache, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
size_t tsdbCacheGetCapacity(SVnode *pVnode) { return taosLRUCacheGetCapacity(pVnode->pTsdb->lruCache); }
|
size_t tsdbCacheGetCapacity(SVnode *pVnode) { return taosLRUCacheGetCapacity(pVnode->pTsdb->lruCache); }
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t tsdbCacheGetUsage(SVnode *pVnode) {
|
size_t tsdbCacheGetUsage(SVnode *pVnode) {
|
||||||
size_t usage = 0;
|
size_t usage = 0;
|
||||||
|
@ -3185,6 +3193,7 @@ int32_t tsdbCacheGetBlockIdx(SLRUCache *pCache, SDataFReader *pFileReader, LRUHa
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h) {
|
int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -3193,6 +3202,7 @@ int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h) {
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// block cache
|
// block cache
|
||||||
static void getBCacheKey(int32_t fid, int64_t commitID, int64_t blkno, char *key, int *len) {
|
static void getBCacheKey(int32_t fid, int64_t commitID, int64_t blkno, char *key, int *len) {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "vnodeInt.h"
|
#include "vnodeInt.h"
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
// STsdbDataIter2
|
// STsdbDataIter2
|
||||||
/* open */
|
/* open */
|
||||||
int32_t tsdbOpenDataFileDataIter(SDataFReader* pReader, STsdbDataIter2** ppIter) {
|
int32_t tsdbOpenDataFileDataIter(SDataFReader* pReader, STsdbDataIter2** ppIter) {
|
||||||
|
@ -451,6 +452,7 @@ int32_t tsdbDataIterNext2(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* get */
|
/* get */
|
||||||
|
|
||||||
|
|
|
@ -2635,6 +2635,58 @@ static bool moveToNextTableForPreFileSetMem(SReaderStatus* pStatus) {
|
||||||
return (pStatus->pProcMemTableIter != NULL);
|
return (pStatus->pProcMemTableIter != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void buildCleanBlockFromSttFiles(STsdbReader* pReader, STableBlockScanInfo* pScanInfo) {
|
||||||
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
|
SSttBlockReader* pSttBlockReader = pStatus->fileIter.pSttBlockReader;
|
||||||
|
SSDataBlock* pResBlock = pReader->resBlockInfo.pResBlock;
|
||||||
|
|
||||||
|
bool asc = ASCENDING_TRAVERSE(pReader->info.order);
|
||||||
|
|
||||||
|
SDataBlockInfo* pInfo = &pResBlock->info;
|
||||||
|
blockDataEnsureCapacity(pResBlock, pScanInfo->numOfRowsInStt);
|
||||||
|
|
||||||
|
pInfo->rows = pScanInfo->numOfRowsInStt;
|
||||||
|
pInfo->id.uid = pScanInfo->uid;
|
||||||
|
pInfo->dataLoad = 1;
|
||||||
|
pInfo->window = pScanInfo->sttWindow;
|
||||||
|
|
||||||
|
setComposedBlockFlag(pReader, true);
|
||||||
|
|
||||||
|
pScanInfo->sttKeyInfo.nextProcKey = asc ? pScanInfo->sttWindow.ekey + 1 : pScanInfo->sttWindow.skey - 1;
|
||||||
|
pScanInfo->sttKeyInfo.status = STT_FILE_NO_DATA;
|
||||||
|
pScanInfo->lastProcKey = asc ? pScanInfo->sttWindow.ekey : pScanInfo->sttWindow.skey;
|
||||||
|
pScanInfo->sttBlockReturned = true;
|
||||||
|
|
||||||
|
pSttBlockReader->mergeTree.pIter = NULL;
|
||||||
|
|
||||||
|
tsdbDebug("%p uid:%" PRId64 " return clean stt block as one, brange:%" PRId64 "-%" PRId64 " rows:%" PRId64 " %s",
|
||||||
|
pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey,
|
||||||
|
pResBlock->info.rows, pReader->idStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void buildCleanBlockFromDataFiles(STsdbReader* pReader, STableBlockScanInfo* pScanInfo,
|
||||||
|
SFileDataBlockInfo* pBlockInfo, int32_t blockIndex) {
|
||||||
|
// whole block is required, return it directly
|
||||||
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
|
SDataBlockInfo* pInfo = &pReader->resBlockInfo.pResBlock->info;
|
||||||
|
bool asc = ASCENDING_TRAVERSE(pReader->info.order);
|
||||||
|
|
||||||
|
pInfo->rows = pBlockInfo->numRow;
|
||||||
|
pInfo->id.uid = pScanInfo->uid;
|
||||||
|
pInfo->dataLoad = 0;
|
||||||
|
pInfo->version = pReader->info.verRange.maxVer;
|
||||||
|
pInfo->window = (STimeWindow){.skey = pBlockInfo->firstKey, .ekey = pBlockInfo->lastKey};
|
||||||
|
setComposedBlockFlag(pReader, false);
|
||||||
|
setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlockInfo->lastKey, pReader->info.order);
|
||||||
|
|
||||||
|
// update the last key for the corresponding table
|
||||||
|
pScanInfo->lastProcKey = asc ? pInfo->window.ekey : pInfo->window.skey;
|
||||||
|
tsdbDebug("%p uid:%" PRIu64 " clean file block retrieved from file, global index:%d, "
|
||||||
|
"table index:%d, rows:%d, brange:%" PRId64 "-%" PRId64 ", %s",
|
||||||
|
pReader, pScanInfo->uid, blockIndex, pBlockInfo->tbBlockIdx, pBlockInfo->numRow, pBlockInfo->firstKey,
|
||||||
|
pBlockInfo->lastKey, pReader->idStr);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t doLoadSttBlockSequentially(STsdbReader* pReader) {
|
static int32_t doLoadSttBlockSequentially(STsdbReader* pReader) {
|
||||||
SReaderStatus* pStatus = &pReader->status;
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
SSttBlockReader* pSttBlockReader = pStatus->fileIter.pSttBlockReader;
|
SSttBlockReader* pSttBlockReader = pStatus->fileIter.pSttBlockReader;
|
||||||
|
@ -2687,28 +2739,7 @@ static int32_t doLoadSttBlockSequentially(STsdbReader* pReader) {
|
||||||
|
|
||||||
// if only require the total rows, no need to load data from stt file if it is clean stt blocks
|
// if only require the total rows, no need to load data from stt file if it is clean stt blocks
|
||||||
if (pReader->info.execMode == READER_EXEC_ROWS && pScanInfo->cleanSttBlocks) {
|
if (pReader->info.execMode == READER_EXEC_ROWS && pScanInfo->cleanSttBlocks) {
|
||||||
bool asc = ASCENDING_TRAVERSE(pReader->info.order);
|
buildCleanBlockFromSttFiles(pReader, pScanInfo);
|
||||||
|
|
||||||
SDataBlockInfo* pInfo = &pResBlock->info;
|
|
||||||
blockDataEnsureCapacity(pResBlock, pScanInfo->numOfRowsInStt);
|
|
||||||
|
|
||||||
pInfo->rows = pScanInfo->numOfRowsInStt;
|
|
||||||
pInfo->id.uid = pScanInfo->uid;
|
|
||||||
pInfo->dataLoad = 1;
|
|
||||||
pInfo->window = pScanInfo->sttWindow;
|
|
||||||
|
|
||||||
setComposedBlockFlag(pReader, true);
|
|
||||||
|
|
||||||
pScanInfo->sttKeyInfo.nextProcKey = asc ? pScanInfo->sttWindow.ekey + 1 : pScanInfo->sttWindow.skey - 1;
|
|
||||||
pScanInfo->sttKeyInfo.status = STT_FILE_NO_DATA;
|
|
||||||
pScanInfo->lastProcKey = asc ? pScanInfo->sttWindow.ekey : pScanInfo->sttWindow.skey;
|
|
||||||
pScanInfo->sttBlockReturned = true;
|
|
||||||
|
|
||||||
pSttBlockReader->mergeTree.pIter = NULL;
|
|
||||||
|
|
||||||
tsdbDebug("%p uid:%" PRId64 " return clean stt block as one, brange:%" PRId64 "-%" PRId64 " rows:%" PRId64 " %s",
|
|
||||||
pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey,
|
|
||||||
pResBlock->info.rows, pReader->idStr);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2748,10 +2779,11 @@ static int32_t doLoadSttBlockSequentially(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool notOverlapWithSttFiles(SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pScanInfo, bool asc) {
|
// current active data block not overlap with the stt-files/stt-blocks
|
||||||
|
static bool notOverlapWithFiles(SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pScanInfo, bool asc) {
|
||||||
ASSERT(pScanInfo->sttKeyInfo.status != STT_FILE_READER_UNINIT);
|
ASSERT(pScanInfo->sttKeyInfo.status != STT_FILE_READER_UNINIT);
|
||||||
|
|
||||||
if (pScanInfo->sttKeyInfo.status == STT_FILE_NO_DATA) {
|
if ((!hasDataInSttBlock(pScanInfo)) || (pScanInfo->cleanSttBlocks == true)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
int64_t keyInStt = pScanInfo->sttKeyInfo.nextProcKey;
|
int64_t keyInStt = pScanInfo->sttKeyInfo.nextProcKey;
|
||||||
|
@ -2801,24 +2833,32 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
||||||
int64_t endKey = getBoarderKeyInFiles(pBlockInfo, pScanInfo, pReader->info.order);
|
int64_t endKey = getBoarderKeyInFiles(pBlockInfo, pScanInfo, pReader->info.order);
|
||||||
code = buildDataBlockFromBuf(pReader, pScanInfo, endKey);
|
code = buildDataBlockFromBuf(pReader, pScanInfo, endKey);
|
||||||
} else {
|
} else {
|
||||||
if (notOverlapWithSttFiles(pBlockInfo, pScanInfo, asc)) {
|
if (notOverlapWithFiles(pBlockInfo, pScanInfo, asc)) {
|
||||||
// whole block is required, return it directly
|
int64_t keyInStt = pScanInfo->sttKeyInfo.nextProcKey;
|
||||||
SDataBlockInfo* pInfo = &pReader->resBlockInfo.pResBlock->info;
|
|
||||||
pInfo->rows = pBlockInfo->numRow;
|
|
||||||
pInfo->id.uid = pScanInfo->uid;
|
|
||||||
pInfo->dataLoad = 0;
|
|
||||||
pInfo->version = pReader->info.verRange.maxVer;
|
|
||||||
pInfo->window = (STimeWindow){.skey = pBlockInfo->firstKey, .ekey = pBlockInfo->lastKey};
|
|
||||||
setComposedBlockFlag(pReader, false);
|
|
||||||
setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlockInfo->lastKey, pReader->info.order);
|
|
||||||
|
|
||||||
// update the last key for the corresponding table
|
if ((!hasDataInSttBlock(pScanInfo)) || (asc && pBlockInfo->lastKey < keyInStt) ||
|
||||||
pScanInfo->lastProcKey = asc ? pInfo->window.ekey : pInfo->window.skey;
|
(!asc && pBlockInfo->firstKey > keyInStt)) {
|
||||||
tsdbDebug("%p uid:%" PRIu64
|
if (pScanInfo->cleanSttBlocks && hasDataInSttBlock(pScanInfo)) {
|
||||||
" clean file block retrieved from file, global index:%d, "
|
if (asc) { // file block is located before the stt block
|
||||||
"table index:%d, rows:%d, brange:%" PRId64 "-%" PRId64 ", %s",
|
ASSERT(pScanInfo->sttWindow.skey > pBlockInfo->lastKey);
|
||||||
pReader, pScanInfo->uid, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlockInfo->numRow,
|
} else { // stt block is before the file block
|
||||||
pBlockInfo->firstKey, pBlockInfo->lastKey, pReader->idStr);
|
ASSERT(pScanInfo->sttWindow.ekey < pBlockInfo->firstKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildCleanBlockFromDataFiles(pReader, pScanInfo, pBlockInfo, pBlockIter->index);
|
||||||
|
} else { // clean stt block
|
||||||
|
if (asc) {
|
||||||
|
ASSERT(pScanInfo->sttWindow.ekey < pBlockInfo->firstKey);
|
||||||
|
} else {
|
||||||
|
ASSERT(pScanInfo->sttWindow.skey > pBlockInfo->lastKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the stt file block
|
||||||
|
ASSERT(pReader->info.execMode == READER_EXEC_ROWS && pSttBlockReader->mergeTree.pIter == NULL);
|
||||||
|
buildCleanBlockFromSttFiles(pReader, pScanInfo);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SBlockData* pBData = &pReader->status.fileBlockData;
|
SBlockData* pBData = &pReader->status.fileBlockData;
|
||||||
tBlockDataReset(pBData);
|
tBlockDataReset(pBData);
|
||||||
|
@ -2829,7 +2869,6 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
|
||||||
// let's load data from stt files, make sure clear the cleanStt block flag before load the data from stt files
|
// let's load data from stt files, make sure clear the cleanStt block flag before load the data from stt files
|
||||||
pScanInfo->cleanSttBlocks = false;
|
|
||||||
initSttBlockReader(pSttBlockReader, pScanInfo, pReader);
|
initSttBlockReader(pSttBlockReader, pScanInfo, pReader);
|
||||||
|
|
||||||
// no data in stt block, no need to proceed.
|
// no data in stt block, no need to proceed.
|
||||||
|
@ -5001,9 +5040,9 @@ int64_t tsdbGetNumOfRowsInMemTable2(STsdbReader* pReader) {
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbGetTableSchema(void* pVnode, int64_t uid, STSchema** pSchema, int64_t* suid) {
|
int32_t tsdbGetTableSchema(SMeta* pMeta, int64_t uid, STSchema** pSchema, int64_t* suid) {
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
metaReaderDoInit(&mr, ((SVnode*)pVnode)->pMeta, 0);
|
metaReaderDoInit(&mr, pMeta, 0);
|
||||||
int32_t code = metaReaderGetTableEntryByUidCache(&mr, uid);
|
int32_t code = metaReaderGetTableEntryByUidCache(&mr, uid);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = TSDB_CODE_TDB_INVALID_TABLE_ID;
|
terrno = TSDB_CODE_TDB_INVALID_TABLE_ID;
|
||||||
|
@ -5033,7 +5072,7 @@ int32_t tsdbGetTableSchema(void* pVnode, int64_t uid, STSchema** pSchema, int64_
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
|
|
||||||
// get the newest table schema version
|
// get the newest table schema version
|
||||||
code = metaGetTbTSchemaEx(((SVnode*)pVnode)->pMeta, *suid, uid, -1, pSchema);
|
code = metaGetTbTSchemaEx(pMeta, *suid, uid, -1, pSchema);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ void tMapDataClear(SMapData *pMapData) {
|
||||||
pMapData->aOffset = NULL;
|
pMapData->aOffset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t tMapDataPutItem(SMapData *pMapData, void *pItem, int32_t (*tPutItemFn)(uint8_t *, void *)) {
|
int32_t tMapDataPutItem(SMapData *pMapData, void *pItem, int32_t (*tPutItemFn)(uint8_t *, void *)) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t offset = pMapData->nData;
|
int32_t offset = pMapData->nData;
|
||||||
|
@ -95,12 +96,14 @@ int32_t tMapDataSearch(SMapData *pMapData, void *pSearchItem, int32_t (*tGetItem
|
||||||
_exit:
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tMapDataGetItemByIdx(SMapData *pMapData, int32_t idx, void *pItem, int32_t (*tGetItemFn)(uint8_t *, void *)) {
|
void tMapDataGetItemByIdx(SMapData *pMapData, int32_t idx, void *pItem, int32_t (*tGetItemFn)(uint8_t *, void *)) {
|
||||||
ASSERT(idx >= 0 && idx < pMapData->nItem);
|
ASSERT(idx >= 0 && idx < pMapData->nItem);
|
||||||
tGetItemFn(pMapData->pData + pMapData->aOffset[idx], pItem);
|
tGetItemFn(pMapData->pData + pMapData->aOffset[idx], pItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t tMapDataToArray(SMapData *pMapData, int32_t itemSize, int32_t (*tGetItemFn)(uint8_t *, void *),
|
int32_t tMapDataToArray(SMapData *pMapData, int32_t itemSize, int32_t (*tGetItemFn)(uint8_t *, void *),
|
||||||
SArray **ppArray) {
|
SArray **ppArray) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -140,6 +143,7 @@ int32_t tPutMapData(uint8_t *p, SMapData *pMapData) {
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t tGetMapData(uint8_t *p, SMapData *pMapData) {
|
int32_t tGetMapData(uint8_t *p, SMapData *pMapData) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
@ -167,6 +171,7 @@ int32_t tGetMapData(uint8_t *p, SMapData *pMapData) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
// TABLEID =======================================================================
|
// TABLEID =======================================================================
|
||||||
int32_t tTABLEIDCmprFn(const void *p1, const void *p2) {
|
int32_t tTABLEIDCmprFn(const void *p1, const void *p2) {
|
||||||
TABLEID *pId1 = (TABLEID *)p1;
|
TABLEID *pId1 = (TABLEID *)p1;
|
||||||
|
@ -199,6 +204,7 @@ int32_t tPutBlockIdx(uint8_t *p, void *ph) {
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t tGetBlockIdx(uint8_t *p, void *ph) {
|
int32_t tGetBlockIdx(uint8_t *p, void *ph) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
@ -212,6 +218,7 @@ int32_t tGetBlockIdx(uint8_t *p, void *ph) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t tCmprBlockIdx(void const *lhs, void const *rhs) {
|
int32_t tCmprBlockIdx(void const *lhs, void const *rhs) {
|
||||||
SBlockIdx *lBlockIdx = (SBlockIdx *)lhs;
|
SBlockIdx *lBlockIdx = (SBlockIdx *)lhs;
|
||||||
SBlockIdx *rBlockIdx = (SBlockIdx *)rhs;
|
SBlockIdx *rBlockIdx = (SBlockIdx *)rhs;
|
||||||
|
@ -280,6 +287,7 @@ int32_t tPutDataBlk(uint8_t *p, void *ph) {
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t tGetDataBlk(uint8_t *p, void *ph) {
|
int32_t tGetDataBlk(uint8_t *p, void *ph) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
@ -310,6 +318,7 @@ int32_t tGetDataBlk(uint8_t *p, void *ph) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t tDataBlkCmprFn(const void *p1, const void *p2) {
|
int32_t tDataBlkCmprFn(const void *p1, const void *p2) {
|
||||||
SDataBlk *pBlock1 = (SDataBlk *)p1;
|
SDataBlk *pBlock1 = (SDataBlk *)p1;
|
||||||
SDataBlk *pBlock2 = (SDataBlk *)p2;
|
SDataBlk *pBlock2 = (SDataBlk *)p2;
|
||||||
|
@ -349,6 +358,7 @@ int32_t tPutSttBlk(uint8_t *p, void *ph) {
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t tGetSttBlk(uint8_t *p, void *ph) {
|
int32_t tGetSttBlk(uint8_t *p, void *ph) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
@ -438,6 +448,7 @@ int32_t tGetBlockCol(uint8_t *p, void *ph) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t tBlockColCmprFn(const void *p1, const void *p2) {
|
int32_t tBlockColCmprFn(const void *p1, const void *p2) {
|
||||||
if (((SBlockCol *)p1)->cid < ((SBlockCol *)p2)->cid) {
|
if (((SBlockCol *)p1)->cid < ((SBlockCol *)p2)->cid) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -479,6 +490,7 @@ int32_t tPutDelIdx(uint8_t *p, void *ph) {
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t tGetDelIdx(uint8_t *p, void *ph) {
|
int32_t tGetDelIdx(uint8_t *p, void *ph) {
|
||||||
SDelIdx *pDelIdx = (SDelIdx *)ph;
|
SDelIdx *pDelIdx = (SDelIdx *)ph;
|
||||||
|
@ -492,6 +504,7 @@ int32_t tGetDelIdx(uint8_t *p, void *ph) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
// SDelData ======================================================
|
// SDelData ======================================================
|
||||||
int32_t tPutDelData(uint8_t *p, void *ph) {
|
int32_t tPutDelData(uint8_t *p, void *ph) {
|
||||||
SDelData *pDelData = (SDelData *)ph;
|
SDelData *pDelData = (SDelData *)ph;
|
||||||
|
@ -503,6 +516,7 @@ int32_t tPutDelData(uint8_t *p, void *ph) {
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t tGetDelData(uint8_t *p, void *ph) {
|
int32_t tGetDelData(uint8_t *p, void *ph) {
|
||||||
SDelData *pDelData = (SDelData *)ph;
|
SDelData *pDelData = (SDelData *)ph;
|
||||||
|
@ -1324,6 +1338,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t tBlockDataTryUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, int64_t uid) {
|
int32_t tBlockDataTryUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, int64_t uid) {
|
||||||
if (pBlockData->nRow == 0) {
|
if (pBlockData->nRow == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1341,6 +1356,7 @@ int32_t tBlockDataUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
|
||||||
return tBlockDataAppendRow(pBlockData, pRow, pTSchema, uid);
|
return tBlockDataAppendRow(pBlockData, pRow, pTSchema, uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SColData *tBlockDataGetColData(SBlockData *pBlockData, int16_t cid) {
|
SColData *tBlockDataGetColData(SBlockData *pBlockData, int16_t cid) {
|
||||||
ASSERT(cid != PRIMARYKEY_TIMESTAMP_COL_ID);
|
ASSERT(cid != PRIMARYKEY_TIMESTAMP_COL_ID);
|
||||||
|
|
|
@ -91,7 +91,7 @@ void initMetadataAPI(SStoreMeta* pMeta) {
|
||||||
pMeta->getTableTypeByName = metaGetTableTypeByName;
|
pMeta->getTableTypeByName = metaGetTableTypeByName;
|
||||||
pMeta->getTableNameByUid = metaGetTableNameByUid;
|
pMeta->getTableNameByUid = metaGetTableNameByUid;
|
||||||
|
|
||||||
pMeta->getTableSchema = tsdbGetTableSchema; // todo refactor
|
pMeta->getTableSchema = vnodeGetTableSchema;
|
||||||
pMeta->storeGetTableList = vnodeGetTableList;
|
pMeta->storeGetTableList = vnodeGetTableList;
|
||||||
|
|
||||||
pMeta->getCachedTableList = metaGetCachedTableUidList;
|
pMeta->getCachedTableList = metaGetCachedTableUidList;
|
||||||
|
@ -135,6 +135,8 @@ void initTqAPI(SStoreTqReader* pTq) {
|
||||||
|
|
||||||
pTq->tqReaderNextBlockFilterOut = tqNextDataBlockFilterOut;
|
pTq->tqReaderNextBlockFilterOut = tqNextDataBlockFilterOut;
|
||||||
pTq->tqGetResultBlockTime = tqGetResultBlockTime;
|
pTq->tqGetResultBlockTime = tqGetResultBlockTime;
|
||||||
|
|
||||||
|
pTq->tqGetStreamExecProgress = tqGetStreamExecInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initStateStoreAPI(SStateStore* pStore) {
|
void initStateStoreAPI(SStateStore* pStore) {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
#include "tsdb.h"
|
||||||
|
|
||||||
#define VNODE_GET_LOAD_RESET_VALS(pVar, oVal, vType, tags) \
|
#define VNODE_GET_LOAD_RESET_VALS(pVar, oVal, vType, tags) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -703,3 +704,7 @@ void *vnodeGetIvtIdx(void *pVnode) {
|
||||||
}
|
}
|
||||||
return metaGetIvtIdx(((SVnode *)pVnode)->pMeta);
|
return metaGetIvtIdx(((SVnode *)pVnode)->pMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t vnodeGetTableSchema(void *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid) {
|
||||||
|
return tsdbGetTableSchema(((SVnode*)pVnode)->pMeta, uid, pSchema, suid);
|
||||||
|
}
|
||||||
|
|
|
@ -238,6 +238,11 @@ static int32_t vnodePreProcessSubmitTbData(SVnode *pVnode, SDecoder *pCoder, int
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (submitTbData.flags & SUBMIT_REQ_FROM_FILE) {
|
||||||
|
code = grantCheck(TSDB_GRANT_CSV);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
}
|
||||||
|
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
if (submitTbData.flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
if (submitTbData.flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
||||||
code = vnodePreprocessCreateTableReq(pVnode, pCoder, btimeMs, &uid);
|
code = vnodePreprocessCreateTableReq(pVnode, pCoder, btimeMs, &uid);
|
||||||
|
|
|
@ -300,7 +300,3 @@ int32_t ctgUpdateRentViewVersion(SCatalog *pCtg, char *dbFName, char *viewName,
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,6 @@ static int32_t setSingleOutputTupleBufv1(SResultRowInfo* pResultRowInfo, STimeWi
|
||||||
|
|
||||||
(*pResult)->win = *win;
|
(*pResult)->win = *win;
|
||||||
|
|
||||||
clearResultRowInitFlag(pExprSup->pCtx, pExprSup->numOfExprs);
|
|
||||||
setResultRowInitCtx(*pResult, pExprSup->pCtx, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset);
|
setResultRowInitCtx(*pResult, pExprSup->pCtx, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -262,6 +261,7 @@ int32_t eventWindowAggImpl(SOperatorInfo* pOperator, SEventWindowOperatorInfo* p
|
||||||
} else if (pInfo->groupId != gid) {
|
} else if (pInfo->groupId != gid) {
|
||||||
// this is a new group, reset the info
|
// this is a new group, reset the info
|
||||||
pInfo->inWindow = false;
|
pInfo->inWindow = false;
|
||||||
|
pInfo->groupId = gid;
|
||||||
}
|
}
|
||||||
|
|
||||||
SFilterColumnParam param1 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock};
|
SFilterColumnParam param1 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock};
|
||||||
|
@ -319,6 +319,9 @@ int32_t eventWindowAggImpl(SOperatorInfo* pOperator, SEventWindowOperatorInfo* p
|
||||||
doKeepNewWindowStartInfo(pRowSup, tsList, rowIndex, gid);
|
doKeepNewWindowStartInfo(pRowSup, tsList, rowIndex, gid);
|
||||||
pInfo->inWindow = true;
|
pInfo->inWindow = true;
|
||||||
startIndex = rowIndex;
|
startIndex = rowIndex;
|
||||||
|
if (pInfo->pRow != NULL) {
|
||||||
|
clearResultRowInitFlag(pSup->pCtx, pSup->numOfExprs);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,6 +349,7 @@ static void doStreamEventAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||||
|
curWin.winInfo.pStatePos->beUpdated = true;
|
||||||
SSessionKey key = {0};
|
SSessionKey key = {0};
|
||||||
getSessionHashKey(&curWin.winInfo.sessionWin, &key);
|
getSessionHashKey(&curWin.winInfo.sessionWin, &key);
|
||||||
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &curWin.winInfo, sizeof(SResultWindowInfo));
|
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &curWin.winInfo, sizeof(SResultWindowInfo));
|
||||||
|
@ -725,7 +726,6 @@ SOperatorInfo* createStreamEventAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->isHistoryOp) {
|
if (pInfo->isHistoryOp) {
|
||||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
|
||||||
pInfo->pAllUpdated = tSimpleHashInit(64, hashFn);
|
pInfo->pAllUpdated = tSimpleHashInit(64, hashFn);
|
||||||
} else {
|
} else {
|
||||||
pInfo->pAllUpdated = NULL;
|
pInfo->pAllUpdated = NULL;
|
||||||
|
|
|
@ -2083,6 +2083,7 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||||
|
winInfo.pStatePos->beUpdated = true;
|
||||||
SSessionKey key = {0};
|
SSessionKey key = {0};
|
||||||
getSessionHashKey(&winInfo.sessionWin, &key);
|
getSessionHashKey(&winInfo.sessionWin, &key);
|
||||||
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &winInfo, sizeof(SResultWindowInfo));
|
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &winInfo, sizeof(SResultWindowInfo));
|
||||||
|
@ -2286,6 +2287,10 @@ int32_t getAllSessionWindow(SSHashObj* pHashMap, SSHashObj* pStUpdated) {
|
||||||
int32_t iter = 0;
|
int32_t iter = 0;
|
||||||
while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) {
|
while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) {
|
||||||
SResultWindowInfo* pWinInfo = pIte;
|
SResultWindowInfo* pWinInfo = pIte;
|
||||||
|
if (!pWinInfo->pStatePos->beUpdated) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pWinInfo->pStatePos->beUpdated = false;
|
||||||
saveResult(*pWinInfo, pStUpdated);
|
saveResult(*pWinInfo, pStUpdated);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -3425,6 +3430,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||||
|
curWin.winInfo.pStatePos->beUpdated = true;
|
||||||
SSessionKey key = {0};
|
SSessionKey key = {0};
|
||||||
getSessionHashKey(&curWin.winInfo.sessionWin, &key);
|
getSessionHashKey(&curWin.winInfo.sessionWin, &key);
|
||||||
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &curWin.winInfo, sizeof(SResultWindowInfo));
|
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &curWin.winInfo, sizeof(SResultWindowInfo));
|
||||||
|
|
|
@ -42,6 +42,7 @@ void regexDestroy(FstRegex *regex) {
|
||||||
taosMemoryFree(regex);
|
taosMemoryFree(regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
uint32_t regexAutomStart(FstRegex *regex) {
|
uint32_t regexAutomStart(FstRegex *regex) {
|
||||||
///// no nothing
|
///// no nothing
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -65,3 +66,4 @@ bool regexAutomAccept(FstRegex *regex, uint32_t state, uint8_t byte, uint32_t *r
|
||||||
}
|
}
|
||||||
return dfaAccept(regex->dfa, state, byte, result);
|
return dfaAccept(regex->dfa, state, byte, result);
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -684,12 +684,14 @@ int idxTFileSearch(void* tfile, SIndexTermQuery* query, SIdxTRslt* result) {
|
||||||
|
|
||||||
return tfileReaderSearch(reader, query, result);
|
return tfileReaderSearch(reader, query, result);
|
||||||
}
|
}
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int idxTFilePut(void* tfile, SIndexTerm* term, uint64_t uid) {
|
int idxTFilePut(void* tfile, SIndexTerm* term, uint64_t uid) {
|
||||||
// TFileWriterOpt wOpt = {.suid = term->suid, .colType = term->colType, .colName = term->colName, .nColName =
|
// TFileWriterOpt wOpt = {.suid = term->suid, .colType = term->colType, .colName = term->colName, .nColName =
|
||||||
// term->nColName, .version = 1};
|
// term->nColName, .version = 1};
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
static bool tfileIteratorNext(Iterate* iiter) {
|
static bool tfileIteratorNext(Iterate* iiter) {
|
||||||
IterateValue* iv = &iiter->val;
|
IterateValue* iv = &iiter->val;
|
||||||
iterateValueDestroy(iv, false);
|
iterateValueDestroy(iv, false);
|
||||||
|
|
|
@ -3294,6 +3294,8 @@ static const char* jkSubplanTagIndexCond = "TagIndexCond";
|
||||||
static const char* jkSubplanShowRewrite = "ShowRewrite";
|
static const char* jkSubplanShowRewrite = "ShowRewrite";
|
||||||
static const char* jkSubplanRowsThreshold = "RowThreshold";
|
static const char* jkSubplanRowsThreshold = "RowThreshold";
|
||||||
static const char* jkSubplanDynamicRowsThreshold = "DyRowThreshold";
|
static const char* jkSubplanDynamicRowsThreshold = "DyRowThreshold";
|
||||||
|
static const char* jkSubplanIsView = "IsView";
|
||||||
|
static const char* jkSubplanIsAudit = "IsAudit";
|
||||||
|
|
||||||
static int32_t subplanToJson(const void* pObj, SJson* pJson) {
|
static int32_t subplanToJson(const void* pObj, SJson* pJson) {
|
||||||
const SSubplan* pNode = (const SSubplan*)pObj;
|
const SSubplan* pNode = (const SSubplan*)pObj;
|
||||||
|
@ -3332,6 +3334,12 @@ static int32_t subplanToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddBoolToObject(pJson, jkSubplanShowRewrite, pNode->showRewrite);
|
code = tjsonAddBoolToObject(pJson, jkSubplanShowRewrite, pNode->showRewrite);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddBoolToObject(pJson, jkSubplanIsView, pNode->isView);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddBoolToObject(pJson, jkSubplanIsAudit, pNode->isAudit);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkSubplanRowsThreshold, pNode->rowsThreshold);
|
code = tjsonAddIntegerToObject(pJson, jkSubplanRowsThreshold, pNode->rowsThreshold);
|
||||||
}
|
}
|
||||||
|
@ -3379,6 +3387,12 @@ static int32_t jsonToSubplan(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBoolValue(pJson, jkSubplanShowRewrite, &pNode->showRewrite);
|
code = tjsonGetBoolValue(pJson, jkSubplanShowRewrite, &pNode->showRewrite);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBoolValue(pJson, jkSubplanIsView, &pNode->isView);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBoolValue(pJson, jkSubplanIsAudit, &pNode->isAudit);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetIntValue(pJson, jkSubplanRowsThreshold, &pNode->rowsThreshold);
|
code = tjsonGetIntValue(pJson, jkSubplanRowsThreshold, &pNode->rowsThreshold);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3930,6 +3930,12 @@ static int32_t subplanInlineToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tlvEncodeValueBool(pEncoder, pNode->dynamicRowThreshold);
|
code = tlvEncodeValueBool(pEncoder, pNode->dynamicRowThreshold);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tlvEncodeValueBool(pEncoder, pNode->isView);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tlvEncodeValueBool(pEncoder, pNode->isAudit);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3985,7 +3991,12 @@ static int32_t msgToSubplanInline(STlvDecoder* pDecoder, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tlvDecodeValueBool(pDecoder, &pNode->dynamicRowThreshold);
|
code = tlvDecodeValueBool(pDecoder, &pNode->dynamicRowThreshold);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tlvDecodeValueBool(pDecoder, &pNode->isView);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tlvDecodeValueBool(pDecoder, &pNode->isAudit);
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2144,13 +2144,15 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt
|
||||||
pStmt->pTableCxtHashObj =
|
pStmt->pTableCxtHashObj =
|
||||||
taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
int32_t code = parseCsvFile(pCxt, pStmt, rowsDataCxt, &numOfRows);
|
int32_t code = parseCsvFile(pCxt, pStmt, rowsDataCxt, &numOfRows);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pStmt->totalRowsNum += numOfRows;
|
pStmt->totalRowsNum += numOfRows;
|
||||||
pStmt->totalTbNum += 1;
|
pStmt->totalTbNum += 1;
|
||||||
TSDB_QUERY_SET_TYPE(pStmt->insertType, TSDB_QUERY_TYPE_FILE_INSERT);
|
TSDB_QUERY_SET_TYPE(pStmt->insertType, TSDB_QUERY_TYPE_FILE_INSERT);
|
||||||
|
if (rowsDataCxt.pTableDataCxt && rowsDataCxt.pTableDataCxt->pData) {
|
||||||
|
rowsDataCxt.pTableDataCxt->pData->flags |= SUBMIT_REQ_FROM_FILE;
|
||||||
|
}
|
||||||
if (!pStmt->fileProcessing) {
|
if (!pStmt->fileProcessing) {
|
||||||
taosCloseFile(&pStmt->fp);
|
taosCloseFile(&pStmt->fp);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3165,6 +3165,19 @@ static int32_t checkJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoinTabl
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateAudit(STranslateContext* pCxt, SRealTableNode* pRealTable, SName* pName) {
|
||||||
|
if (pRealTable->pMeta->tableType == TSDB_SUPER_TABLE) {
|
||||||
|
if (IS_AUDIT_DBNAME(pName->dbname) && IS_AUDIT_STB_NAME(pName->tname)) {
|
||||||
|
pCxt->pParseCxt->isAudit = true;
|
||||||
|
}
|
||||||
|
} else if (pRealTable->pMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
|
if (IS_AUDIT_DBNAME(pName->dbname) && IS_AUDIT_CTB_NAME(pName->tname)) {
|
||||||
|
pCxt->pParseCxt->isAudit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t translateTable(STranslateContext* pCxt, SNode** pTable) {
|
int32_t translateTable(STranslateContext* pCxt, SNode** pTable) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
switch (nodeType(*pTable)) {
|
switch (nodeType(*pTable)) {
|
||||||
|
@ -3184,6 +3197,7 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable) {
|
||||||
if (TSDB_VIEW_TABLE == pRealTable->pMeta->tableType) {
|
if (TSDB_VIEW_TABLE == pRealTable->pMeta->tableType) {
|
||||||
return translateView(pCxt, pTable, &name);
|
return translateView(pCxt, pTable, &name);
|
||||||
}
|
}
|
||||||
|
translateAudit(pCxt, pRealTable, &name);
|
||||||
#endif
|
#endif
|
||||||
code = setTableVgroupList(pCxt, &name, pRealTable);
|
code = setTableVgroupList(pCxt, &name, pRealTable);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -4432,7 +4446,7 @@ static int32_t findVgroupsFromEqualTbname(STranslateContext* pCxt, SEqCondTbName
|
||||||
SName snameTb;
|
SName snameTb;
|
||||||
char* tbName = taosArrayGetP(pInfo->aTbnames, j);
|
char* tbName = taosArrayGetP(pInfo->aTbnames, j);
|
||||||
toName(pCxt->pParseCxt->acctId, dbName, tbName, &snameTb);
|
toName(pCxt->pParseCxt->acctId, dbName, tbName, &snameTb);
|
||||||
SVgroupInfo vgInfo;
|
SVgroupInfo vgInfo = {0};
|
||||||
bool bExists;
|
bool bExists;
|
||||||
int32_t code = catalogGetCachedTableHashVgroup(pCxt->pParseCxt->pCatalog, &snameTb, &vgInfo, &bExists);
|
int32_t code = catalogGetCachedTableHashVgroup(pCxt->pParseCxt->pCatalog, &snameTb, &vgInfo, &bExists);
|
||||||
if (code == TSDB_CODE_SUCCESS && bExists) {
|
if (code == TSDB_CODE_SUCCESS && bExists) {
|
||||||
|
@ -8135,27 +8149,27 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
|
||||||
|
|
||||||
tstrncpy(col->tableAlias, pTable, tListLen(col->tableAlias));
|
tstrncpy(col->tableAlias, pTable, tListLen(col->tableAlias));
|
||||||
tstrncpy(col->colName, pMeta->schema[0].name, tListLen(col->colName));
|
tstrncpy(col->colName, pMeta->schema[0].name, tListLen(col->colName));
|
||||||
SNodeList* pParamterList = nodesMakeList();
|
SNodeList* pParameterList = nodesMakeList();
|
||||||
if (NULL == pParamterList) {
|
if (NULL == pParameterList) {
|
||||||
nodesDestroyNode((SNode*)col);
|
nodesDestroyNode((SNode*)col);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = nodesListStrictAppend(pParamterList, (SNode*)col);
|
int32_t code = nodesListStrictAppend(pParameterList, (SNode*)col);
|
||||||
if (code) {
|
if (code) {
|
||||||
nodesDestroyList(pParamterList);
|
nodesDestroyList(pParameterList);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* pFunc = (SNode*)createFunction("last", pParamterList);
|
SNode* pFunc = (SNode*)createFunction("last", pParameterList);
|
||||||
if (NULL == pFunc) {
|
if (NULL == pFunc) {
|
||||||
nodesDestroyList(pParamterList);
|
nodesDestroyList(pParameterList);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeList* pProjectionList = nodesMakeList();
|
SNodeList* pProjectionList = nodesMakeList();
|
||||||
if (NULL == pProjectionList) {
|
if (NULL == pProjectionList) {
|
||||||
nodesDestroyList(pParamterList);
|
nodesDestroyNode(pFunc);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8167,7 +8181,7 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
|
||||||
|
|
||||||
SFunctionNode* pFunc1 = createFunction("_vgid", NULL);
|
SFunctionNode* pFunc1 = createFunction("_vgid", NULL);
|
||||||
if (NULL == pFunc1) {
|
if (NULL == pFunc1) {
|
||||||
nodesDestroyList(pParamterList);
|
nodesDestroyList(pProjectionList);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8180,7 +8194,7 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
|
||||||
|
|
||||||
SFunctionNode* pFunc2 = createFunction("_vgver", NULL);
|
SFunctionNode* pFunc2 = createFunction("_vgver", NULL);
|
||||||
if (NULL == pFunc2) {
|
if (NULL == pFunc2) {
|
||||||
nodesDestroyList(pParamterList);
|
nodesDestroyList(pProjectionList);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8197,27 +8211,56 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo add the group by statement
|
|
||||||
SSelectStmt** pSelect1 = (SSelectStmt**)pQuery;
|
SSelectStmt** pSelect1 = (SSelectStmt**)pQuery;
|
||||||
(*pSelect1)->pGroupByList = nodesMakeList();
|
(*pSelect1)->pGroupByList = nodesMakeList();
|
||||||
|
if (NULL == (*pSelect1)->pGroupByList) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
SGroupingSetNode* pNode1 = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET);
|
SGroupingSetNode* pNode1 = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET);
|
||||||
|
if (NULL == pNode1) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
pNode1->groupingSetType = GP_TYPE_NORMAL;
|
pNode1->groupingSetType = GP_TYPE_NORMAL;
|
||||||
pNode1->pParameterList = nodesMakeList();
|
pNode1->pParameterList = nodesMakeList();
|
||||||
nodesListAppend(pNode1->pParameterList, (SNode*)pFunc1);
|
if (NULL == pNode1->pParameterList) {
|
||||||
|
nodesDestroyNode((SNode*)pNode1);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
nodesListAppend((*pSelect1)->pGroupByList, (SNode*)pNode1);
|
code = nodesListStrictAppend(pNode1->pParameterList, nodesCloneNode((SNode*)pFunc1));
|
||||||
|
if (code) {
|
||||||
|
nodesDestroyNode((SNode*)pNode1);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = nodesListAppend((*pSelect1)->pGroupByList, (SNode*)pNode1);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
SGroupingSetNode* pNode2 = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET);
|
SGroupingSetNode* pNode2 = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET);
|
||||||
|
if (NULL == pNode2) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
pNode2->groupingSetType = GP_TYPE_NORMAL;
|
pNode2->groupingSetType = GP_TYPE_NORMAL;
|
||||||
pNode2->pParameterList = nodesMakeList();
|
pNode2->pParameterList = nodesMakeList();
|
||||||
nodesListAppend(pNode2->pParameterList, (SNode*)pFunc2);
|
if (NULL == pNode2->pParameterList) {
|
||||||
|
nodesDestroyNode((SNode*)pNode2);
|
||||||
nodesListAppend((*pSelect1)->pGroupByList, (SNode*)pNode2);
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = nodesListStrictAppend(pNode2->pParameterList, nodesCloneNode((SNode*)pFunc2));
|
||||||
|
if (code) {
|
||||||
|
nodesDestroyNode((SNode*)pNode2);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nodesListAppend((*pSelect1)->pGroupByList, (SNode*)pNode2);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) {
|
static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) {
|
||||||
pCxt->createStream = true;
|
pCxt->createStream = true;
|
||||||
STableMeta* pMeta = NULL;
|
STableMeta* pMeta = NULL;
|
||||||
|
|
|
@ -755,6 +755,7 @@ void MockCatalogService::destoryCatalogReq(SCatalogReq* pReq) {
|
||||||
taosArrayDestroy(pReq->pUser);
|
taosArrayDestroy(pReq->pUser);
|
||||||
taosArrayDestroy(pReq->pTableIndex);
|
taosArrayDestroy(pReq->pTableIndex);
|
||||||
taosArrayDestroy(pReq->pTableCfg);
|
taosArrayDestroy(pReq->pTableCfg);
|
||||||
|
taosArrayDestroyEx(pReq->pView, destoryTablesReq);
|
||||||
delete pReq;
|
delete pReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,6 +782,7 @@ void MockCatalogService::destoryMetaData(SMetaData* pData) {
|
||||||
taosArrayDestroyEx(pData->pQnodeList, destoryMetaRes);
|
taosArrayDestroyEx(pData->pQnodeList, destoryMetaRes);
|
||||||
taosArrayDestroyEx(pData->pTableCfg, destoryMetaRes);
|
taosArrayDestroyEx(pData->pTableCfg, destoryMetaRes);
|
||||||
taosArrayDestroyEx(pData->pDnodeList, destoryMetaArrayRes);
|
taosArrayDestroyEx(pData->pDnodeList, destoryMetaArrayRes);
|
||||||
|
taosArrayDestroyEx(pData->pView, destoryMetaRes);
|
||||||
taosMemoryFree(pData->pSvrVer);
|
taosMemoryFree(pData->pSvrVer);
|
||||||
delete pData;
|
delete pData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ TEST_F(ParserInitialATest, alterDnode) {
|
||||||
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
||||||
ASSERT_EQ(std::string(req.config), std::string(expect.config));
|
ASSERT_EQ(std::string(req.config), std::string(expect.config));
|
||||||
ASSERT_EQ(std::string(req.value), std::string(expect.value));
|
ASSERT_EQ(std::string(req.value), std::string(expect.value));
|
||||||
|
tFreeSMCfgDnodeReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setCfgDnodeReq(1, "resetLog");
|
setCfgDnodeReq(1, "resetLog");
|
||||||
|
@ -183,6 +184,7 @@ TEST_F(ParserInitialATest, alterDatabase) {
|
||||||
ASSERT_EQ(req.minRows, expect.minRows);
|
ASSERT_EQ(req.minRows, expect.minRows);
|
||||||
ASSERT_EQ(req.walRetentionPeriod, expect.walRetentionPeriod);
|
ASSERT_EQ(req.walRetentionPeriod, expect.walRetentionPeriod);
|
||||||
ASSERT_EQ(req.walRetentionSize, expect.walRetentionSize);
|
ASSERT_EQ(req.walRetentionSize, expect.walRetentionSize);
|
||||||
|
tFreeSAlterDbReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
const int32_t MINUTE_PER_DAY = MILLISECOND_PER_DAY / MILLISECOND_PER_MINUTE;
|
const int32_t MINUTE_PER_DAY = MILLISECOND_PER_DAY / MILLISECOND_PER_MINUTE;
|
||||||
|
@ -827,6 +829,7 @@ TEST_F(ParserInitialATest, alterUser) {
|
||||||
ASSERT_EQ(std::string(req.user), std::string(expect.user));
|
ASSERT_EQ(std::string(req.user), std::string(expect.user));
|
||||||
ASSERT_EQ(std::string(req.pass), std::string(expect.pass));
|
ASSERT_EQ(std::string(req.pass), std::string(expect.pass));
|
||||||
ASSERT_EQ(std::string(req.objname), std::string(expect.objname));
|
ASSERT_EQ(std::string(req.objname), std::string(expect.objname));
|
||||||
|
tFreeSAlterUserReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setAlterUserReq("wxy", TSDB_ALTER_USER_PASSWD, "123456");
|
setAlterUserReq("wxy", TSDB_ALTER_USER_PASSWD, "123456");
|
||||||
|
@ -853,6 +856,7 @@ TEST_F(ParserInitialATest, balanceVgroup) {
|
||||||
ASSERT_EQ(pQuery->pCmdMsg->msgType, TDMT_MND_BALANCE_VGROUP);
|
ASSERT_EQ(pQuery->pCmdMsg->msgType, TDMT_MND_BALANCE_VGROUP);
|
||||||
SBalanceVgroupReq req = {0};
|
SBalanceVgroupReq req = {0};
|
||||||
ASSERT_EQ(tDeserializeSBalanceVgroupReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
|
ASSERT_EQ(tDeserializeSBalanceVgroupReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
|
||||||
|
tFreeSBalanceVgroupReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
run("BALANCE VGROUP");
|
run("BALANCE VGROUP");
|
||||||
|
@ -870,6 +874,7 @@ TEST_F(ParserInitialATest, balanceVgroupLeader) {
|
||||||
SBalanceVgroupLeaderReq req = {0};
|
SBalanceVgroupLeaderReq req = {0};
|
||||||
ASSERT_EQ(tDeserializeSBalanceVgroupLeaderReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req),
|
ASSERT_EQ(tDeserializeSBalanceVgroupLeaderReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req),
|
||||||
TSDB_CODE_SUCCESS);
|
TSDB_CODE_SUCCESS);
|
||||||
|
tFreeSBalanceVgroupLeaderReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
run("BALANCE VGROUP LEADER");
|
run("BALANCE VGROUP LEADER");
|
||||||
|
|
|
@ -52,6 +52,7 @@ TEST_F(ParserExplainToSyncdbTest, grant) {
|
||||||
ASSERT_EQ(req.alterType, expect.alterType);
|
ASSERT_EQ(req.alterType, expect.alterType);
|
||||||
ASSERT_EQ(string(req.user), string(expect.user));
|
ASSERT_EQ(string(req.user), string(expect.user));
|
||||||
ASSERT_EQ(string(req.objname), string(expect.objname));
|
ASSERT_EQ(string(req.objname), string(expect.objname));
|
||||||
|
tFreeSAlterUserReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setAlterUserReq(TSDB_ALTER_USER_ADD_PRIVILEGES, PRIVILEGE_TYPE_ALL, "wxy", "0.*");
|
setAlterUserReq(TSDB_ALTER_USER_ADD_PRIVILEGES, PRIVILEGE_TYPE_ALL, "wxy", "0.*");
|
||||||
|
@ -183,6 +184,7 @@ TEST_F(ParserExplainToSyncdbTest, redistributeVgroup) {
|
||||||
ASSERT_EQ(req.dnodeId1, expect.dnodeId1);
|
ASSERT_EQ(req.dnodeId1, expect.dnodeId1);
|
||||||
ASSERT_EQ(req.dnodeId2, expect.dnodeId2);
|
ASSERT_EQ(req.dnodeId2, expect.dnodeId2);
|
||||||
ASSERT_EQ(req.dnodeId3, expect.dnodeId3);
|
ASSERT_EQ(req.dnodeId3, expect.dnodeId3);
|
||||||
|
tFreeSRedistributeVgroupReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setRedistributeVgroupReqFunc(3, 1);
|
setRedistributeVgroupReqFunc(3, 1);
|
||||||
|
@ -228,6 +230,7 @@ TEST_F(ParserExplainToSyncdbTest, restoreDnode) {
|
||||||
ASSERT_EQ(tDeserializeSRestoreDnodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
|
ASSERT_EQ(tDeserializeSRestoreDnodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
|
||||||
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
||||||
ASSERT_EQ(req.restoreType, expect.restoreType);
|
ASSERT_EQ(req.restoreType, expect.restoreType);
|
||||||
|
tFreeSRestoreDnodeReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setRestoreDnodeReq(1, RESTORE_TYPE__ALL);
|
setRestoreDnodeReq(1, RESTORE_TYPE__ALL);
|
||||||
|
@ -272,6 +275,7 @@ TEST_F(ParserExplainToSyncdbTest, revoke) {
|
||||||
ASSERT_EQ(req.alterType, expect.alterType);
|
ASSERT_EQ(req.alterType, expect.alterType);
|
||||||
ASSERT_EQ(string(req.user), string(expect.user));
|
ASSERT_EQ(string(req.user), string(expect.user));
|
||||||
ASSERT_EQ(string(req.objname), string(expect.objname));
|
ASSERT_EQ(string(req.objname), string(expect.objname));
|
||||||
|
tFreeSAlterUserReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setAlterUserReq(TSDB_ALTER_USER_DEL_PRIVILEGES, PRIVILEGE_TYPE_ALL, "wxy", "0.*");
|
setAlterUserReq(TSDB_ALTER_USER_DEL_PRIVILEGES, PRIVILEGE_TYPE_ALL, "wxy", "0.*");
|
||||||
|
|
|
@ -43,6 +43,7 @@ TEST_F(ParserInitialCTest, compact) {
|
||||||
ASSERT_EQ(std::string(req.db), std::string(expect.db));
|
ASSERT_EQ(std::string(req.db), std::string(expect.db));
|
||||||
ASSERT_EQ(req.timeRange.skey, expect.timeRange.skey);
|
ASSERT_EQ(req.timeRange.skey, expect.timeRange.skey);
|
||||||
ASSERT_EQ(req.timeRange.ekey, expect.timeRange.ekey);
|
ASSERT_EQ(req.timeRange.ekey, expect.timeRange.ekey);
|
||||||
|
tFreeSCompactDbReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setCompactDbReq("test");
|
setCompactDbReq("test");
|
||||||
|
@ -374,6 +375,7 @@ TEST_F(ParserInitialCTest, createDnode) {
|
||||||
|
|
||||||
ASSERT_EQ(std::string(req.fqdn), std::string(expect.fqdn));
|
ASSERT_EQ(std::string(req.fqdn), std::string(expect.fqdn));
|
||||||
ASSERT_EQ(req.port, expect.port);
|
ASSERT_EQ(req.port, expect.port);
|
||||||
|
tFreeSCreateDnodeReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setCreateDnodeReq("abc1", 7030);
|
setCreateDnodeReq("abc1", 7030);
|
||||||
|
@ -599,6 +601,7 @@ TEST_F(ParserInitialCTest, createMnode) {
|
||||||
tDeserializeSCreateDropMQSNodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
tDeserializeSCreateDropMQSNodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||||
|
|
||||||
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
||||||
|
tFreeSMCreateQnodeReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setCreateMnodeReq(1);
|
setCreateMnodeReq(1);
|
||||||
|
@ -622,6 +625,7 @@ TEST_F(ParserInitialCTest, createQnode) {
|
||||||
tDeserializeSCreateDropMQSNodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
tDeserializeSCreateDropMQSNodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||||
|
|
||||||
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
||||||
|
tFreeSMCreateQnodeReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setCreateQnodeReq(1);
|
setCreateQnodeReq(1);
|
||||||
|
@ -1326,6 +1330,7 @@ TEST_F(ParserInitialCTest, createUser) {
|
||||||
ASSERT_EQ(req.enable, expect.enable);
|
ASSERT_EQ(req.enable, expect.enable);
|
||||||
ASSERT_EQ(std::string(req.user), std::string(expect.user));
|
ASSERT_EQ(std::string(req.user), std::string(expect.user));
|
||||||
ASSERT_EQ(std::string(req.pass), std::string(expect.pass));
|
ASSERT_EQ(std::string(req.pass), std::string(expect.pass));
|
||||||
|
tFreeSCreateUserReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setCreateUserReq("wxy", "123456");
|
setCreateUserReq("wxy", "123456");
|
||||||
|
|
|
@ -117,6 +117,7 @@ TEST_F(ParserInitialDTest, dropDnode) {
|
||||||
ASSERT_EQ(req.port, expect.port);
|
ASSERT_EQ(req.port, expect.port);
|
||||||
ASSERT_EQ(req.force, expect.force);
|
ASSERT_EQ(req.force, expect.force);
|
||||||
ASSERT_EQ(req.unsafe, expect.unsafe);
|
ASSERT_EQ(req.unsafe, expect.unsafe);
|
||||||
|
tFreeSDropDnodeReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setDropDnodeReqById(1);
|
setDropDnodeReqById(1);
|
||||||
|
@ -208,6 +209,7 @@ TEST_F(ParserInitialDTest, dropQnode) {
|
||||||
tDeserializeSCreateDropMQSNodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
tDeserializeSCreateDropMQSNodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||||
|
|
||||||
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
ASSERT_EQ(req.dnodeId, expect.dnodeId);
|
||||||
|
tFreeSDDropQnodeReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setDropQnodeReq(1);
|
setDropQnodeReq(1);
|
||||||
|
@ -245,6 +247,7 @@ TEST_F(ParserInitialDTest, dropStream) {
|
||||||
|
|
||||||
ASSERT_EQ(std::string(req.name), std::string(expect.name));
|
ASSERT_EQ(std::string(req.name), std::string(expect.name));
|
||||||
ASSERT_EQ(req.igNotExists, expect.igNotExists);
|
ASSERT_EQ(req.igNotExists, expect.igNotExists);
|
||||||
|
tFreeMDropStreamReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setDropStreamReq("s1");
|
setDropStreamReq("s1");
|
||||||
|
@ -285,6 +288,7 @@ TEST_F(ParserInitialDTest, dropUser) {
|
||||||
ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSDropUserReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSDropUserReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||||
|
|
||||||
ASSERT_EQ(std::string(req.user), std::string(expect.user));
|
ASSERT_EQ(std::string(req.user), std::string(expect.user));
|
||||||
|
tFreeSDropUserReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
setDropUserReq("wxy");
|
setDropUserReq("wxy");
|
||||||
|
|
|
@ -2977,6 +2977,7 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic
|
||||||
}
|
}
|
||||||
nodesClearList(cxt.pLastCols);
|
nodesClearList(cxt.pLastCols);
|
||||||
}
|
}
|
||||||
|
nodesClearList(cxt.pOtherCols);
|
||||||
|
|
||||||
pAgg->hasLastRow = false;
|
pAgg->hasLastRow = false;
|
||||||
pAgg->hasLast = false;
|
pAgg->hasLast = false;
|
||||||
|
|
|
@ -2164,6 +2164,8 @@ static SSubplan* makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubpl
|
||||||
pSubplan->level = pLogicSubplan->level;
|
pSubplan->level = pLogicSubplan->level;
|
||||||
pSubplan->rowsThreshold = 4096;
|
pSubplan->rowsThreshold = 4096;
|
||||||
pSubplan->dynamicRowThreshold = false;
|
pSubplan->dynamicRowThreshold = false;
|
||||||
|
pSubplan->isView = pCxt->pPlanCxt->isView;
|
||||||
|
pSubplan->isAudit = pCxt->pPlanCxt->isAudit;
|
||||||
if (NULL != pCxt->pPlanCxt->pUser) {
|
if (NULL != pCxt->pPlanCxt->pUser) {
|
||||||
snprintf(pSubplan->user, sizeof(pSubplan->user), "%s", pCxt->pPlanCxt->pUser);
|
snprintf(pSubplan->user, sizeof(pSubplan->user), "%s", pCxt->pPlanCxt->pUser);
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,11 +360,25 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg, bool chkGran
|
||||||
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chkGrant && (!TEST_SHOW_REWRITE_MASK(msg.msgMask)) && !taosGranted()) {
|
if (chkGrant) {
|
||||||
|
if ((!TEST_SHOW_REWRITE_MASK(msg.msgMask))) {
|
||||||
|
if (!taosGranted(TSDB_GRANT_ALL)) {
|
||||||
QW_ELOG("query failed cause of grant expired, msgMask:%d", msg.msgMask);
|
QW_ELOG("query failed cause of grant expired, msgMask:%d", msg.msgMask);
|
||||||
tFreeSSubQueryMsg(&msg);
|
tFreeSSubQueryMsg(&msg);
|
||||||
QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED);
|
QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED);
|
||||||
}
|
}
|
||||||
|
if ((TEST_VIEW_MASK(msg.msgMask)) && !taosGranted(TSDB_GRANT_VIEW)) {
|
||||||
|
QW_ELOG("query failed cause of view grant expired, msgMask:%d", msg.msgMask);
|
||||||
|
tFreeSSubQueryMsg(&msg);
|
||||||
|
QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED);
|
||||||
|
}
|
||||||
|
if ((TEST_AUDIT_MASK(msg.msgMask)) && !taosGranted(TSDB_GRANT_AUDIT)) {
|
||||||
|
QW_ELOG("query failed cause of audit grant expired, msgMask:%d", msg.msgMask);
|
||||||
|
tFreeSSubQueryMsg(&msg);
|
||||||
|
QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t sId = msg.sId;
|
uint64_t sId = msg.sId;
|
||||||
uint64_t qId = msg.queryId;
|
uint64_t qId = msg.queryId;
|
||||||
|
|
|
@ -737,6 +737,13 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) {
|
||||||
QW_ERR_JRET(code);
|
QW_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
SReadHandle* pReadHandle = qwMsg->node;
|
||||||
|
int64_t delay = 0;
|
||||||
|
bool fhFinish = false;
|
||||||
|
pReadHandle->api.tqReaderFn.tqGetStreamExecProgress(pReadHandle->vnode, 0, &delay, &fhFinish);
|
||||||
|
#endif
|
||||||
|
|
||||||
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, sql, OPTR_EXEC_MODEL_BATCH);
|
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, sql, OPTR_EXEC_MODEL_BATCH);
|
||||||
sql = NULL;
|
sql = NULL;
|
||||||
if (code) {
|
if (code) {
|
||||||
|
|
|
@ -1109,6 +1109,8 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
qMsg.refId = pJob->refId;
|
qMsg.refId = pJob->refId;
|
||||||
qMsg.execId = pTask->execId;
|
qMsg.execId = pTask->execId;
|
||||||
qMsg.msgMask = (pTask->plan->showRewrite) ? QUERY_MSG_MASK_SHOW_REWRITE() : 0;
|
qMsg.msgMask = (pTask->plan->showRewrite) ? QUERY_MSG_MASK_SHOW_REWRITE() : 0;
|
||||||
|
qMsg.msgMask |= (pTask->plan->isView) ? QUERY_MSG_MASK_VIEW() : 0;
|
||||||
|
qMsg.msgMask |= (pTask->plan->isAudit) ? QUERY_MSG_MASK_AUDIT() : 0;
|
||||||
qMsg.taskType = TASK_TYPE_TEMP;
|
qMsg.taskType = TASK_TYPE_TEMP;
|
||||||
qMsg.explain = SCH_IS_EXPLAIN_JOB(pJob);
|
qMsg.explain = SCH_IS_EXPLAIN_JOB(pJob);
|
||||||
qMsg.needFetch = SCH_TASK_NEED_FETCH(pTask);
|
qMsg.needFetch = SCH_TASK_NEED_FETCH(pTask);
|
||||||
|
|
|
@ -158,7 +158,7 @@ int32_t streamProcessCheckpointSourceReq(SStreamTask* pTask, SStreamCheckpointSo
|
||||||
|
|
||||||
pTask->chkInfo.transId = pReq->transId;
|
pTask->chkInfo.transId = pReq->transId;
|
||||||
pTask->chkInfo.checkpointingId = pReq->checkpointId;
|
pTask->chkInfo.checkpointingId = pReq->checkpointId;
|
||||||
pTask->chkInfo.checkpointNotReadyTasks = streamTaskGetNumOfDownstream(pTask);
|
pTask->chkInfo.numOfNotReady = streamTaskGetNumOfDownstream(pTask);
|
||||||
pTask->chkInfo.startTs = taosGetTimestampMs();
|
pTask->chkInfo.startTs = taosGetTimestampMs();
|
||||||
pTask->execInfo.checkpoint += 1;
|
pTask->execInfo.checkpoint += 1;
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ int32_t streamProcessCheckpointBlock(SStreamTask* pTask, SStreamDataBlock* pBloc
|
||||||
stDebug("s-task:%s set childIdx:%d, and add checkpoint-trigger block into outputQ", id, pTask->info.selfChildId);
|
stDebug("s-task:%s set childIdx:%d, and add checkpoint-trigger block into outputQ", id, pTask->info.selfChildId);
|
||||||
continueDispatchCheckpointBlock(pBlock, pTask);
|
continueDispatchCheckpointBlock(pBlock, pTask);
|
||||||
} else { // only one task exists, no need to dispatch downstream info
|
} else { // only one task exists, no need to dispatch downstream info
|
||||||
atomic_add_fetch_32(&pTask->chkInfo.checkpointNotReadyTasks, 1);
|
atomic_add_fetch_32(&pTask->chkInfo.numOfNotReady, 1);
|
||||||
streamProcessCheckpointReadyMsg(pTask);
|
streamProcessCheckpointReadyMsg(pTask);
|
||||||
streamFreeQitem((SStreamQueueItem*)pBlock);
|
streamFreeQitem((SStreamQueueItem*)pBlock);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ int32_t streamProcessCheckpointBlock(SStreamTask* pTask, SStreamDataBlock* pBloc
|
||||||
|
|
||||||
// set the needed checked downstream tasks, only when all downstream tasks do checkpoint complete, this task
|
// set the needed checked downstream tasks, only when all downstream tasks do checkpoint complete, this task
|
||||||
// can start local checkpoint procedure
|
// can start local checkpoint procedure
|
||||||
pTask->chkInfo.checkpointNotReadyTasks = streamTaskGetNumOfDownstream(pTask);
|
pTask->chkInfo.numOfNotReady = streamTaskGetNumOfDownstream(pTask);
|
||||||
|
|
||||||
// Put the checkpoint block into inputQ, to make sure all blocks with less version have been handled by this task
|
// Put the checkpoint block into inputQ, to make sure all blocks with less version have been handled by this task
|
||||||
// already. And then, dispatch check point msg to all downstream tasks
|
// already. And then, dispatch check point msg to all downstream tasks
|
||||||
|
@ -268,7 +268,7 @@ int32_t streamProcessCheckpointReadyMsg(SStreamTask* pTask) {
|
||||||
ASSERT(pTask->info.taskLevel == TASK_LEVEL__SOURCE || pTask->info.taskLevel == TASK_LEVEL__AGG);
|
ASSERT(pTask->info.taskLevel == TASK_LEVEL__SOURCE || pTask->info.taskLevel == TASK_LEVEL__AGG);
|
||||||
|
|
||||||
// only when all downstream tasks are send checkpoint rsp, we can start the checkpoint procedure for the agg task
|
// only when all downstream tasks are send checkpoint rsp, we can start the checkpoint procedure for the agg task
|
||||||
int32_t notReady = atomic_sub_fetch_32(&pTask->chkInfo.checkpointNotReadyTasks, 1);
|
int32_t notReady = atomic_sub_fetch_32(&pTask->chkInfo.numOfNotReady, 1);
|
||||||
ASSERT(notReady >= 0);
|
ASSERT(notReady >= 0);
|
||||||
|
|
||||||
if (notReady == 0) {
|
if (notReady == 0) {
|
||||||
|
@ -287,7 +287,7 @@ void streamTaskClearCheckInfo(SStreamTask* pTask, bool clearChkpReadyMsg) {
|
||||||
pTask->chkInfo.checkpointingId = 0; // clear the checkpoint id
|
pTask->chkInfo.checkpointingId = 0; // clear the checkpoint id
|
||||||
pTask->chkInfo.failedId = 0;
|
pTask->chkInfo.failedId = 0;
|
||||||
pTask->chkInfo.startTs = 0; // clear the recorded start time
|
pTask->chkInfo.startTs = 0; // clear the recorded start time
|
||||||
pTask->chkInfo.checkpointNotReadyTasks = 0;
|
pTask->chkInfo.numOfNotReady = 0;
|
||||||
pTask->chkInfo.transId = 0;
|
pTask->chkInfo.transId = 0;
|
||||||
pTask->chkInfo.dispatchCheckpointTrigger = false;
|
pTask->chkInfo.dispatchCheckpointTrigger = false;
|
||||||
|
|
||||||
|
|
|
@ -155,14 +155,14 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu
|
||||||
*blockSize = 0;
|
*blockSize = 0;
|
||||||
|
|
||||||
// no available token in bucket for sink task, let's wait for a little bit
|
// no available token in bucket for sink task, let's wait for a little bit
|
||||||
if (taskLevel == TASK_LEVEL__SINK && (!streamTaskExtractAvailableToken(pTask->outputInfo.pTokenBucket, pTask->id.idStr))) {
|
if (taskLevel == TASK_LEVEL__SINK && (!streamTaskExtractAvailableToken(pTask->outputInfo.pTokenBucket, id))) {
|
||||||
stDebug("s-task:%s no available token in bucket for sink data, wait for 10ms", id);
|
stDebug("s-task:%s no available token in bucket for sink data, wait for 10ms", id);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (streamTaskShouldPause(pTask) || streamTaskShouldStop(pTask)) {
|
if (streamTaskShouldPause(pTask) || streamTaskShouldStop(pTask)) {
|
||||||
stDebug("s-task:%s task should pause, extract input blocks:%d", pTask->id.idStr, *numOfBlocks);
|
stDebug("s-task:%s task should pause, extract input blocks:%d", id, *numOfBlocks);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,3 +33,8 @@ add_test(
|
||||||
NAME streamUpdateTest
|
NAME streamUpdateTest
|
||||||
COMMAND streamUpdateTest
|
COMMAND streamUpdateTest
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# add_test(
|
||||||
|
# NAME checkpointTest
|
||||||
|
# COMMAND checkpointTest
|
||||||
|
# )
|
|
@ -39,7 +39,9 @@ int main(int argc, char **argv) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strcpy(tsSnodeAddress, "127.0.0.1");
|
strcpy(tsSnodeAddress, "127.0.0.1");
|
||||||
return RUN_ALL_TESTS();
|
int ret = RUN_ALL_TESTS();
|
||||||
|
s3CleanUp();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, checkpointUpload_Test) {
|
TEST(testCase, checkpointUpload_Test) {
|
||||||
|
|
|
@ -413,6 +413,7 @@ int32_t syncEndSnapshot(int64_t rid) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t syncStepDown(int64_t rid, SyncTerm newTerm) {
|
int32_t syncStepDown(int64_t rid, SyncTerm newTerm) {
|
||||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
|
@ -424,6 +425,7 @@ int32_t syncStepDown(int64_t rid, SyncTerm newTerm) {
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool syncNodeIsReadyForRead(SSyncNode* pSyncNode) {
|
bool syncNodeIsReadyForRead(SSyncNode* pSyncNode) {
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
|
@ -458,6 +460,7 @@ bool syncIsReadyForRead(int64_t rid) {
|
||||||
return ready;
|
return ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
bool syncSnapshotSending(int64_t rid) {
|
bool syncSnapshotSending(int64_t rid) {
|
||||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
|
@ -479,6 +482,7 @@ bool syncSnapshotRecving(int64_t rid) {
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t syncNodeLeaderTransfer(SSyncNode* pSyncNode) {
|
int32_t syncNodeLeaderTransfer(SSyncNode* pSyncNode) {
|
||||||
if (pSyncNode->peersNum == 0) {
|
if (pSyncNode->peersNum == 0) {
|
||||||
|
@ -1060,7 +1064,9 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) {
|
||||||
pSyncNode->heartbeatTimerMS = pSyncNode->hbBaseLine;
|
pSyncNode->heartbeatTimerMS = pSyncNode->hbBaseLine;
|
||||||
atomic_store_64(&pSyncNode->heartbeatTimerLogicClock, 0);
|
atomic_store_64(&pSyncNode->heartbeatTimerLogicClock, 0);
|
||||||
atomic_store_64(&pSyncNode->heartbeatTimerLogicClockUser, 0);
|
atomic_store_64(&pSyncNode->heartbeatTimerLogicClockUser, 0);
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
pSyncNode->FpHeartbeatTimerCB = syncNodeEqHeartbeatTimer;
|
pSyncNode->FpHeartbeatTimerCB = syncNodeEqHeartbeatTimer;
|
||||||
|
#endif
|
||||||
pSyncNode->heartbeatTimerCounter = 0;
|
pSyncNode->heartbeatTimerCounter = 0;
|
||||||
|
|
||||||
// init peer heartbeat timer
|
// init peer heartbeat timer
|
||||||
|
@ -1151,6 +1157,7 @@ _error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode) {
|
void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode) {
|
||||||
if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||||
SSnapshot snapshot = {0};
|
SSnapshot snapshot = {0};
|
||||||
|
@ -1160,6 +1167,7 @@ void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t syncNodeRestore(SSyncNode* pSyncNode) {
|
int32_t syncNodeRestore(SSyncNode* pSyncNode) {
|
||||||
ASSERTS(pSyncNode->pLogStore != NULL, "log store not created");
|
ASSERTS(pSyncNode->pLogStore != NULL, "log store not created");
|
||||||
|
@ -1214,6 +1222,7 @@ int32_t syncNodeStart(SSyncNode* pSyncNode) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t syncNodeStartStandBy(SSyncNode* pSyncNode) {
|
int32_t syncNodeStartStandBy(SSyncNode* pSyncNode) {
|
||||||
// state change
|
// state change
|
||||||
pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER;
|
pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER;
|
||||||
|
@ -1235,6 +1244,7 @@ int32_t syncNodeStartStandBy(SSyncNode* pSyncNode) {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void syncNodePreClose(SSyncNode* pSyncNode) {
|
void syncNodePreClose(SSyncNode* pSyncNode) {
|
||||||
ASSERT(pSyncNode != NULL);
|
ASSERT(pSyncNode != NULL);
|
||||||
|
@ -1401,6 +1411,7 @@ void syncNodeResetElectTimer(SSyncNode* pSyncNode) {
|
||||||
electMS);
|
electMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
static int32_t syncNodeDoStartHeartbeatTimer(SSyncNode* pSyncNode) {
|
static int32_t syncNodeDoStartHeartbeatTimer(SSyncNode* pSyncNode) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
if (syncIsInit()) {
|
if (syncIsInit()) {
|
||||||
|
@ -1414,6 +1425,7 @@ static int32_t syncNodeDoStartHeartbeatTimer(SSyncNode* pSyncNode) {
|
||||||
sNTrace(pSyncNode, "start heartbeat timer, ms:%d", pSyncNode->heartbeatTimerMS);
|
sNTrace(pSyncNode, "start heartbeat timer, ms:%d", pSyncNode->heartbeatTimerMS);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t syncNodeStartHeartbeatTimer(SSyncNode* pSyncNode) {
|
int32_t syncNodeStartHeartbeatTimer(SSyncNode* pSyncNode) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
@ -1452,11 +1464,13 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) {
|
int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) {
|
||||||
syncNodeStopHeartbeatTimer(pSyncNode);
|
syncNodeStopHeartbeatTimer(pSyncNode);
|
||||||
syncNodeStartHeartbeatTimer(pSyncNode);
|
syncNodeStartHeartbeatTimer(pSyncNode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pNode, SRpcMsg* pMsg) {
|
int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pNode, SRpcMsg* pMsg) {
|
||||||
SEpSet* epSet = NULL;
|
SEpSet* epSet = NULL;
|
||||||
|
@ -1700,6 +1714,7 @@ _END:
|
||||||
}
|
}
|
||||||
|
|
||||||
// raft state change --------------
|
// raft state change --------------
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) {
|
void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) {
|
||||||
if (term > raftStoreGetTerm(pSyncNode)) {
|
if (term > raftStoreGetTerm(pSyncNode)) {
|
||||||
raftStoreSetTerm(pSyncNode, term);
|
raftStoreSetTerm(pSyncNode, term);
|
||||||
|
@ -1709,6 +1724,7 @@ void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) {
|
||||||
raftStoreClearVote(pSyncNode);
|
raftStoreClearVote(pSyncNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void syncNodeUpdateTermWithoutStepDown(SSyncNode* pSyncNode, SyncTerm term) {
|
void syncNodeUpdateTermWithoutStepDown(SSyncNode* pSyncNode, SyncTerm term) {
|
||||||
if (term > raftStoreGetTerm(pSyncNode)) {
|
if (term > raftStoreGetTerm(pSyncNode)) {
|
||||||
|
@ -1934,6 +1950,7 @@ void syncNodeFollower2Candidate(SSyncNode* pSyncNode) {
|
||||||
sNTrace(pSyncNode, "follower to candidate");
|
sNTrace(pSyncNode, "follower to candidate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
void syncNodeLeader2Follower(SSyncNode* pSyncNode) {
|
void syncNodeLeader2Follower(SSyncNode* pSyncNode) {
|
||||||
ASSERT(pSyncNode->state == TAOS_SYNC_STATE_LEADER);
|
ASSERT(pSyncNode->state == TAOS_SYNC_STATE_LEADER);
|
||||||
syncNodeBecomeFollower(pSyncNode, "leader to follower");
|
syncNodeBecomeFollower(pSyncNode, "leader to follower");
|
||||||
|
@ -1953,6 +1970,7 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode) {
|
||||||
|
|
||||||
sNTrace(pSyncNode, "candidate to follower");
|
sNTrace(pSyncNode, "candidate to follower");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// just called by syncNodeVoteForSelf
|
// just called by syncNodeVoteForSelf
|
||||||
// need assert
|
// need assert
|
||||||
|
@ -2042,6 +2060,7 @@ int32_t syncNodeGetLastIndexTerm(SSyncNode* pSyncNode, SyncIndex* pLastIndex, Sy
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
// return append-entries first try index
|
// return append-entries first try index
|
||||||
SyncIndex syncNodeSyncStartIndex(SSyncNode* pSyncNode) {
|
SyncIndex syncNodeSyncStartIndex(SSyncNode* pSyncNode) {
|
||||||
SyncIndex syncStartIndex = syncNodeGetLastIndex(pSyncNode) + 1;
|
SyncIndex syncStartIndex = syncNodeGetLastIndex(pSyncNode) + 1;
|
||||||
|
@ -2129,6 +2148,7 @@ int32_t syncNodeGetPreIndexTerm(SSyncNode* pSyncNode, SyncIndex index, SyncIndex
|
||||||
*pPreTerm = syncNodeGetPreTerm(pSyncNode, index);
|
*pPreTerm = syncNodeGetPreTerm(pSyncNode, index);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void syncNodeEqPingTimer(void* param, void* tmrId) {
|
static void syncNodeEqPingTimer(void* param, void* tmrId) {
|
||||||
if (!syncIsInit()) return;
|
if (!syncIsInit()) return;
|
||||||
|
@ -2200,6 +2220,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
|
||||||
syncNodeRelease(pNode);
|
syncNodeRelease(pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
||||||
if (!syncIsInit()) return;
|
if (!syncIsInit()) return;
|
||||||
|
|
||||||
|
@ -2233,6 +2254,7 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) {
|
static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) {
|
||||||
int64_t hbDataRid = (int64_t)param;
|
int64_t hbDataRid = (int64_t)param;
|
||||||
|
@ -2320,6 +2342,7 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) {
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
static void deleteCacheEntry(const void* key, size_t keyLen, void* value, void* ud) {
|
static void deleteCacheEntry(const void* key, size_t keyLen, void* value, void* ud) {
|
||||||
(void)ud;
|
(void)ud;
|
||||||
taosMemoryFree(value);
|
taosMemoryFree(value);
|
||||||
|
@ -2339,6 +2362,7 @@ int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHand
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void syncBuildConfigFromReq(SAlterVnodeReplicaReq* pReq, SSyncCfg* cfg) { // TODO SAlterVnodeReplicaReq name is proper?
|
void syncBuildConfigFromReq(SAlterVnodeReplicaReq* pReq, SSyncCfg* cfg) { // TODO SAlterVnodeReplicaReq name is proper?
|
||||||
cfg->replicaNum = 0;
|
cfg->replicaNum = 0;
|
||||||
|
@ -2976,6 +3000,7 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
static int32_t syncNodeAppendNoopOld(SSyncNode* ths) {
|
static int32_t syncNodeAppendNoopOld(SSyncNode* ths) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
|
||||||
|
@ -3004,6 +3029,7 @@ static int32_t syncNodeAppendNoopOld(SSyncNode* ths) {
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
||||||
SyncHeartbeat* pMsg = pRpcMsg->pCont;
|
SyncHeartbeat* pMsg = pRpcMsg->pCont;
|
||||||
|
@ -3121,6 +3147,7 @@ int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
||||||
return syncLogReplProcessHeartbeatReply(pMgr, ths, pMsg);
|
return syncLogReplProcessHeartbeatReply(pMgr, ths, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t syncNodeOnHeartbeatReplyOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
int32_t syncNodeOnHeartbeatReplyOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
||||||
SyncHeartbeatReply* pMsg = pRpcMsg->pCont;
|
SyncHeartbeatReply* pMsg = pRpcMsg->pCont;
|
||||||
|
|
||||||
|
@ -3136,6 +3163,7 @@ int32_t syncNodeOnHeartbeatReplyOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
||||||
syncIndexMgrSetRecvTime(ths->pMatchIndex, &pMsg->srcId, tsMs);
|
syncIndexMgrSetRecvTime(ths->pMatchIndex, &pMsg->srcId, tsMs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
||||||
SyncLocalCmd* pMsg = pRpcMsg->pCont;
|
SyncLocalCmd* pMsg = pRpcMsg->pCont;
|
||||||
|
@ -3315,6 +3343,7 @@ SPeerState* syncNodeGetPeerState(SSyncNode* ths, const SRaftId* pDestId) {
|
||||||
return pState;
|
return pState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
bool syncNodeNeedSendAppendEntries(SSyncNode* ths, const SRaftId* pDestId, const SyncAppendEntries* pMsg) {
|
bool syncNodeNeedSendAppendEntries(SSyncNode* ths, const SRaftId* pDestId, const SyncAppendEntries* pMsg) {
|
||||||
SPeerState* pState = syncNodeGetPeerState(ths, pDestId);
|
SPeerState* pState = syncNodeGetPeerState(ths, pDestId);
|
||||||
if (pState == NULL) {
|
if (pState == NULL) {
|
||||||
|
@ -3356,3 +3385,4 @@ bool syncNodeCanChange(SSyncNode* pSyncNode) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -2515,7 +2515,7 @@ int transReleaseCliHandle(void* handle) {
|
||||||
|
|
||||||
SCliThrd* pThrd = transGetWorkThrdFromHandle(NULL, (int64_t)handle);
|
SCliThrd* pThrd = transGetWorkThrdFromHandle(NULL, (int64_t)handle);
|
||||||
if (pThrd == NULL) {
|
if (pThrd == NULL) {
|
||||||
return -1;
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STransMsg tmsg = {.info.handle = handle, .info.ahandle = (void*)0x9527};
|
STransMsg tmsg = {.info.handle = handle, .info.ahandle = (void*)0x9527};
|
||||||
|
@ -2535,7 +2535,7 @@ int transReleaseCliHandle(void* handle) {
|
||||||
|
|
||||||
if (0 != transAsyncSend(pThrd->asyncPool, &cmsg->q)) {
|
if (0 != transAsyncSend(pThrd->asyncPool, &cmsg->q)) {
|
||||||
destroyCmsg(cmsg);
|
destroyCmsg(cmsg);
|
||||||
return -1;
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2544,7 +2544,7 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran
|
||||||
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
|
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
if (pTransInst == NULL) {
|
if (pTransInst == NULL) {
|
||||||
transFreeMsg(pReq->pCont);
|
transFreeMsg(pReq->pCont);
|
||||||
return -1;
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle);
|
SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle);
|
||||||
|
@ -2577,7 +2577,7 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran
|
||||||
if (0 != transAsyncSend(pThrd->asyncPool, &(cliMsg->q))) {
|
if (0 != transAsyncSend(pThrd->asyncPool, &(cliMsg->q))) {
|
||||||
destroyCmsg(cliMsg);
|
destroyCmsg(cliMsg);
|
||||||
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
return -1;
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
}
|
}
|
||||||
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2589,7 +2589,7 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs
|
||||||
if (pTransInst == NULL) {
|
if (pTransInst == NULL) {
|
||||||
transFreeMsg(pReq->pCont);
|
transFreeMsg(pReq->pCont);
|
||||||
taosMemoryFree(pTransRsp);
|
taosMemoryFree(pTransRsp);
|
||||||
return -1;
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle);
|
SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle);
|
||||||
|
@ -2627,6 +2627,7 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs
|
||||||
int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q);
|
int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
destroyCmsg(cliMsg);
|
destroyCmsg(cliMsg);
|
||||||
|
ret = TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
goto _RETURN;
|
goto _RETURN;
|
||||||
}
|
}
|
||||||
tsem_wait(sem);
|
tsem_wait(sem);
|
||||||
|
@ -2661,7 +2662,7 @@ int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STr
|
||||||
if (pTransInst == NULL) {
|
if (pTransInst == NULL) {
|
||||||
transFreeMsg(pReq->pCont);
|
transFreeMsg(pReq->pCont);
|
||||||
taosMemoryFree(pTransMsg);
|
taosMemoryFree(pTransMsg);
|
||||||
return -1;
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle);
|
SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle);
|
||||||
|
@ -2698,6 +2699,7 @@ int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STr
|
||||||
int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q);
|
int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
destroyCmsg(cliMsg);
|
destroyCmsg(cliMsg);
|
||||||
|
ret = TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
goto _RETURN;
|
goto _RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2726,7 +2728,7 @@ _RETURN:
|
||||||
int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) {
|
int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) {
|
||||||
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
|
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
if (pTransInst == NULL) {
|
if (pTransInst == NULL) {
|
||||||
return -1;
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCvtAddr cvtAddr = {0};
|
SCvtAddr cvtAddr = {0};
|
||||||
|
@ -2750,7 +2752,6 @@ int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) {
|
||||||
if (transAsyncSend(thrd->asyncPool, &(cliMsg->q)) != 0) {
|
if (transAsyncSend(thrd->asyncPool, &(cliMsg->q)) != 0) {
|
||||||
destroyCmsg(cliMsg);
|
destroyCmsg(cliMsg);
|
||||||
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
|
|
|
@ -70,8 +70,7 @@ int32_t walNextValidMsg(SWalReader *pReader) {
|
||||||
int64_t committedVer = walGetCommittedVer(pReader->pWal);
|
int64_t committedVer = walGetCommittedVer(pReader->pWal);
|
||||||
int64_t appliedVer = walGetAppliedVer(pReader->pWal);
|
int64_t appliedVer = walGetAppliedVer(pReader->pWal);
|
||||||
|
|
||||||
wDebug("vgId:%d, wal start to fetch, index:%" PRId64 ", last index:%" PRId64 " commit index:%" PRId64
|
wDebug("vgId:%d, wal start to fetch, index:%" PRId64 ", last:%" PRId64 " commit:%" PRId64 ", applied:%" PRId64,
|
||||||
", applied index:%" PRId64,
|
|
||||||
pReader->pWal->cfg.vgId, fetchVer, lastVer, committedVer, appliedVer);
|
pReader->pWal->cfg.vgId, fetchVer, lastVer, committedVer, appliedVer);
|
||||||
if (fetchVer > appliedVer) {
|
if (fetchVer > appliedVer) {
|
||||||
terrno = TSDB_CODE_WAL_LOG_NOT_EXIST;
|
terrno = TSDB_CODE_WAL_LOG_NOT_EXIST;
|
||||||
|
@ -86,10 +85,8 @@ int32_t walNextValidMsg(SWalReader *pReader) {
|
||||||
int32_t type = pReader->pHead->head.msgType;
|
int32_t type = pReader->pHead->head.msgType;
|
||||||
if (type == TDMT_VND_SUBMIT || ((type == TDMT_VND_DELETE) && (pReader->cond.deleteMsg == 1)) ||
|
if (type == TDMT_VND_SUBMIT || ((type == TDMT_VND_DELETE) && (pReader->cond.deleteMsg == 1)) ||
|
||||||
(IS_META_MSG(type) && pReader->cond.scanMeta)) {
|
(IS_META_MSG(type) && pReader->cond.scanMeta)) {
|
||||||
if (walFetchBody(pReader) < 0) {
|
int32_t code = walFetchBody(pReader);
|
||||||
return -1;
|
return (code == TSDB_CODE_SUCCESS)? 0:-1;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
if (walSkipFetchBody(pReader) < 0) {
|
if (walSkipFetchBody(pReader) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -498,7 +498,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
||||||
pWal->writeHead.head.version = index;
|
pWal->writeHead.head.version = index;
|
||||||
pWal->writeHead.head.bodyLen = bodyLen;
|
pWal->writeHead.head.bodyLen = bodyLen;
|
||||||
pWal->writeHead.head.msgType = msgType;
|
pWal->writeHead.head.msgType = msgType;
|
||||||
pWal->writeHead.head.ingestTs = 0;
|
pWal->writeHead.head.ingestTs = taosGetTimestampUs();
|
||||||
|
|
||||||
// sync info for sync module
|
// sync info for sync module
|
||||||
pWal->writeHead.head.syncMeta = syncMeta;
|
pWal->writeHead.head.syncMeta = syncMeta;
|
||||||
|
|
|
@ -18,10 +18,12 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "talgo.h"
|
#include "talgo.h"
|
||||||
|
|
||||||
|
#if defined(WINDOWS_STASH) || defined(_ALPINE)
|
||||||
int32_t qsortHelper(const void* p1, const void* p2, const void* param) {
|
int32_t qsortHelper(const void* p1, const void* p2, const void* param) {
|
||||||
__compar_fn_t comparFn = param;
|
__compar_fn_t comparFn = param;
|
||||||
return comparFn(p1, p2);
|
return comparFn(p1, p2);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// todo refactor: 1) move away; 2) use merge sort instead; 3) qsort is not a stable sort actually.
|
// todo refactor: 1) move away; 2) use merge sort instead; 3) qsort is not a stable sort actually.
|
||||||
void taosSort(void* base, int64_t sz, int64_t width, __compar_fn_t compar) {
|
void taosSort(void* base, int64_t sz, int64_t width, __compar_fn_t compar) {
|
||||||
|
|
|
@ -56,6 +56,8 @@ int32_t taosGetAppName(char* name, int32_t* len) {
|
||||||
char* end = strrchr(filepath, TD_DIRSEP[0]);
|
char* end = strrchr(filepath, TD_DIRSEP[0]);
|
||||||
if (end == NULL) {
|
if (end == NULL) {
|
||||||
end = filepath;
|
end = filepath;
|
||||||
|
} else {
|
||||||
|
end += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tstrncpy(name, end, TSDB_APP_NAME_LEN);
|
tstrncpy(name, end, TSDB_APP_NAME_LEN);
|
||||||
|
|
|
@ -88,6 +88,7 @@ struct termios oldtio;
|
||||||
|
|
||||||
typedef struct FILE TdCmd;
|
typedef struct FILE TdCmd;
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
void* taosLoadDll(const char* filename) {
|
void* taosLoadDll(const char* filename) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
@ -140,6 +141,7 @@ void taosCloseDll(void* handle) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int taosSetConsoleEcho(bool on) {
|
int taosSetConsoleEcho(bool on) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "tbase64.h"
|
#include "tbase64.h"
|
||||||
#include <math.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
static char basis_64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
static char basis_64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
|
|
|
@ -977,6 +977,7 @@ int32_t tsDecompressDoubleLossyImp(const char *input, int32_t compressedSize, co
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* STREAM COMPRESSION
|
* STREAM COMPRESSION
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
@ -2120,7 +2121,7 @@ int32_t tCompressEnd(SCompressor *pCmprsor, const uint8_t **ppOut, int32_t *nOut
|
||||||
int32_t tCompress(SCompressor *pCmprsor, const void *pData, int64_t nData) {
|
int32_t tCompress(SCompressor *pCmprsor, const void *pData, int64_t nData) {
|
||||||
return DATA_TYPE_INFO[pCmprsor->type].cmprFn(pCmprsor, pData, nData);
|
return DATA_TYPE_INFO[pCmprsor->type].cmprFn(pCmprsor, pData, nData);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* REGULAR COMPRESSION
|
* REGULAR COMPRESSION
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
|
@ -450,10 +450,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_ACTIVE, "Invalid active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_KEY, "Invalid key to parse active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_KEY, "Invalid key to parse active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_DEC_IVLD_KEY, "Invalid key to decode active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_DEC_IVLD_KEY, "Invalid key to decode active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_DEC_IVLD_KLEN, "Invalid klen to decode active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_DEC_IVLD_KLEN, "Invalid klen to decode active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_IVLD_KEY, "Invalid key to gen active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_IVLD_KEY, "Invalid key to generate active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_ACTIVE_LEN, "Exceeded active len to gen active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_ACTIVE_LEN, "Exceeded active len to generate active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN, "Invalid klen to encode active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN, "Invalid klen to encode active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_DIST, "Invalid dist to parse active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_DIST, "Invalid distribution time to parse active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_UNLICENSED_CLUSTER, "Illegal operation, the license is being used by an unlicensed cluster")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_UNLICENSED_CLUSTER, "Illegal operation, the license is being used by an unlicensed cluster")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_LACK_OF_BASIC, "Lack of basic functions in active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_LACK_OF_BASIC, "Lack of basic functions in active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_OBJ_NOT_EXIST, "Grant object not exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_OBJ_NOT_EXIST, "Grant object not exist")
|
||||||
|
@ -462,8 +462,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_MACHINES_MISMATCH, "Cluster machines mism
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_OPT_EXPIRE_TOO_LARGE, "Expire time of optional grant item is too large")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_OPT_EXPIRE_TOO_LARGE, "Expire time of optional grant item is too large")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DUPLICATED_ACTIVE, "The active code can't be activated repeatedly")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DUPLICATED_ACTIVE, "The active code can't be activated repeatedly")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_VIEW_LIMITED, "Number of view has reached the licensed upper limit")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_VIEW_LIMITED, "Number of view has reached the licensed upper limit")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CSV_LIMITED, "Csv has reached the licensed upper limit")
|
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_AUDIT_LIMITED, "Audit has reached the licensed upper limit")
|
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_TIMEOUT, "Sync timeout")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_TIMEOUT, "Sync timeout")
|
||||||
|
|
|
@ -115,6 +115,7 @@ void *taosInitScheduler(int32_t queueSize, int32_t numOfThreads, const char *lab
|
||||||
return (void *)pSched;
|
return (void *)pSched;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
void *taosInitSchedulerWithInfo(int32_t queueSize, int32_t numOfThreads, const char *label, void *tmrCtrl) {
|
void *taosInitSchedulerWithInfo(int32_t queueSize, int32_t numOfThreads, const char *label, void *tmrCtrl) {
|
||||||
SSchedQueue *pSched = taosInitScheduler(queueSize, numOfThreads, label, NULL);
|
SSchedQueue *pSched = taosInitScheduler(queueSize, numOfThreads, label, NULL);
|
||||||
|
|
||||||
|
@ -125,6 +126,7 @@ void *taosInitSchedulerWithInfo(int32_t queueSize, int32_t numOfThreads, const c
|
||||||
|
|
||||||
return pSched;
|
return pSched;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void *taosProcessSchedQueue(void *scheduler) {
|
void *taosProcessSchedQueue(void *scheduler) {
|
||||||
SSchedMsg msg;
|
SSchedMsg msg;
|
||||||
|
@ -241,6 +243,7 @@ void taosCleanUpScheduler(void *param) {
|
||||||
// taosMemoryFree(pSched);
|
// taosMemoryFree(pSched);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
// for debug purpose, dump the scheduler status every 1min.
|
// for debug purpose, dump the scheduler status every 1min.
|
||||||
void taosDumpSchedulerStatus(void *qhandle, void *tmrId) {
|
void taosDumpSchedulerStatus(void *qhandle, void *tmrId) {
|
||||||
SSchedQueue *pSched = (SSchedQueue *)qhandle;
|
SSchedQueue *pSched = (SSchedQueue *)qhandle;
|
||||||
|
@ -255,3 +258,4 @@ void taosDumpSchedulerStatus(void *qhandle, void *tmrId) {
|
||||||
|
|
||||||
taosTmrReset(taosDumpSchedulerStatus, DUMP_SCHEDULER_TIME_WINDOW, pSched, pSched->pTmrCtrl, &pSched->pTimer);
|
taosTmrReset(taosDumpSchedulerStatus, DUMP_SCHEDULER_TIME_WINDOW, pSched, pSched->pTmrCtrl, &pSched->pTimer);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -64,6 +64,7 @@ int64_t taosStrHumanToInt64(const char* str) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
void taosInt64ToHumanStr(int64_t val, char* outStr) {
|
void taosInt64ToHumanStr(int64_t val, char* outStr) {
|
||||||
if (((val >= UNIT_ONE_EXBIBYTE) || (-val >= UNIT_ONE_EXBIBYTE)) && ((val % UNIT_ONE_EXBIBYTE) == 0)) {
|
if (((val >= UNIT_ONE_EXBIBYTE) || (-val >= UNIT_ONE_EXBIBYTE)) && ((val % UNIT_ONE_EXBIBYTE) == 0)) {
|
||||||
sprintf(outStr, "%qdE", (long long)val / UNIT_ONE_EXBIBYTE);
|
sprintf(outStr, "%qdE", (long long)val / UNIT_ONE_EXBIBYTE);
|
||||||
|
@ -80,6 +81,7 @@ void taosInt64ToHumanStr(int64_t val, char* outStr) {
|
||||||
} else
|
} else
|
||||||
sprintf(outStr, "%qd", (long long)val);
|
sprintf(outStr, "%qd", (long long)val);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t taosStrHumanToInt32(const char* str) {
|
int32_t taosStrHumanToInt32(const char* str) {
|
||||||
size_t sLen = strlen(str);
|
size_t sLen = strlen(str);
|
||||||
|
@ -112,6 +114,7 @@ int32_t taosStrHumanToInt32(const char* str) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
void taosInt32ToHumanStr(int32_t val, char* outStr) {
|
void taosInt32ToHumanStr(int32_t val, char* outStr) {
|
||||||
if (((val >= UNIT_ONE_GIBIBYTE) || (-val >= UNIT_ONE_GIBIBYTE)) && ((val % UNIT_ONE_GIBIBYTE) == 0)) {
|
if (((val >= UNIT_ONE_GIBIBYTE) || (-val >= UNIT_ONE_GIBIBYTE)) && ((val % UNIT_ONE_GIBIBYTE) == 0)) {
|
||||||
sprintf(outStr, "%qdG", (long long)val / UNIT_ONE_GIBIBYTE);
|
sprintf(outStr, "%qdG", (long long)val / UNIT_ONE_GIBIBYTE);
|
||||||
|
@ -122,3 +125,4 @@ void taosInt32ToHumanStr(int32_t val, char* outStr) {
|
||||||
} else
|
} else
|
||||||
sprintf(outStr, "%qd", (long long)val);
|
sprintf(outStr, "%qd", (long long)val);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -89,7 +89,7 @@ static void *tQWorkerThreadFp(SQueueWorker *worker) {
|
||||||
if (qinfo.timestamp != 0) {
|
if (qinfo.timestamp != 0) {
|
||||||
int64_t cost = taosGetTimestampUs() - qinfo.timestamp;
|
int64_t cost = taosGetTimestampUs() - qinfo.timestamp;
|
||||||
if (cost > QUEUE_THRESHOLD) {
|
if (cost > QUEUE_THRESHOLD) {
|
||||||
uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost);
|
uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost / QUEUE_THRESHOLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ static void *tAutoQWorkerThreadFp(SQueueWorker *worker) {
|
||||||
if (qinfo.timestamp != 0) {
|
if (qinfo.timestamp != 0) {
|
||||||
int64_t cost = taosGetTimestampUs() - qinfo.timestamp;
|
int64_t cost = taosGetTimestampUs() - qinfo.timestamp;
|
||||||
if (cost > QUEUE_THRESHOLD) {
|
if (cost > QUEUE_THRESHOLD) {
|
||||||
uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost);
|
uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost / QUEUE_THRESHOLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ static void *tWWorkerThreadFp(SWWorker *worker) {
|
||||||
if (qinfo.timestamp != 0) {
|
if (qinfo.timestamp != 0) {
|
||||||
int64_t cost = taosGetTimestampUs() - qinfo.timestamp;
|
int64_t cost = taosGetTimestampUs() - qinfo.timestamp;
|
||||||
if (cost > QUEUE_THRESHOLD) {
|
if (cost > QUEUE_THRESHOLD) {
|
||||||
uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost);
|
uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost / QUEUE_THRESHOLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
"start_timestamp":"now-12d",
|
"start_timestamp":"now-12d",
|
||||||
"columns": [
|
"columns": [
|
||||||
{ "type": "bool", "name": "bc"},
|
{ "type": "bool", "name": "bc"},
|
||||||
{ "type": "float", "name": "fc" },
|
{ "type": "float", "name": "fc", "min": 100, "max": 100},
|
||||||
{ "type": "double", "name": "dc"},
|
{ "type": "double", "name": "dc", "min": 200, "max": 200},
|
||||||
{ "type": "tinyint", "name": "ti"},
|
{ "type": "tinyint", "name": "ti"},
|
||||||
{ "type": "smallint", "name": "si" },
|
{ "type": "smallint", "name": "si" },
|
||||||
{ "type": "int", "name": "ic" },
|
{ "type": "int", "name": "ic" },
|
||||||
|
|
|
@ -29,7 +29,11 @@ from frame import *
|
||||||
|
|
||||||
class TDTestCase(TBase):
|
class TDTestCase(TBase):
|
||||||
updatecfgDict = {
|
updatecfgDict = {
|
||||||
"countAlwaysReturnValue" : "0"
|
"countAlwaysReturnValue" : "0",
|
||||||
|
"lossyColumns" : "float,double",
|
||||||
|
"fPrecision" : "0.000000001",
|
||||||
|
"dPrecision" : "0.00000000000000001",
|
||||||
|
"ifAdtFse" : "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
def insertData(self):
|
def insertData(self):
|
||||||
|
@ -48,6 +52,18 @@ class TDTestCase(TBase):
|
||||||
sql = f"create table {self.db}.ta(ts timestamp, age int) tags(area int)"
|
sql = f"create table {self.db}.ta(ts timestamp, age int) tags(area int)"
|
||||||
tdSql.execute(sql)
|
tdSql.execute(sql)
|
||||||
|
|
||||||
|
def checkFloatDouble(self):
|
||||||
|
sql = f"select * from {self.db}.{self.stb} where fc!=100"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = f"select count(*) from {self.db}.{self.stb} where dc!=200"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = f"select avg(fc) from {self.db}.{self.stb}"
|
||||||
|
tdSql.checkFirstValue(sql, 100)
|
||||||
|
sql = f"select avg(dc) from {self.db}.{self.stb}"
|
||||||
|
tdSql.checkFirstValue(sql, 200)
|
||||||
|
|
||||||
def doAction(self):
|
def doAction(self):
|
||||||
tdLog.info(f"do action.")
|
tdLog.info(f"do action.")
|
||||||
self.flushDb()
|
self.flushDb()
|
||||||
|
@ -85,6 +101,9 @@ class TDTestCase(TBase):
|
||||||
# check insert data correct
|
# check insert data correct
|
||||||
self.checkInsertCorrect()
|
self.checkInsertCorrect()
|
||||||
|
|
||||||
|
# check float double value ok
|
||||||
|
self.checkFloatDouble()
|
||||||
|
|
||||||
# save
|
# save
|
||||||
self.snapshotAgg()
|
self.snapshotAgg()
|
||||||
|
|
||||||
|
@ -97,6 +116,10 @@ class TDTestCase(TBase):
|
||||||
# check insert correct again
|
# check insert correct again
|
||||||
self.checkInsertCorrect()
|
self.checkInsertCorrect()
|
||||||
|
|
||||||
|
# check float double value ok
|
||||||
|
self.checkFloatDouble()
|
||||||
|
|
||||||
|
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,15 @@ from frame import *
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase(TBase):
|
class TDTestCase(TBase):
|
||||||
|
updatecfgDict = {
|
||||||
|
'queryMaxConcurrentTables': '2K',
|
||||||
|
'streamMax': '1M',
|
||||||
|
'totalMemoryKB': '1G',
|
||||||
|
#'rpcQueueMemoryAllowed': '1T',
|
||||||
|
#'mndLogRetention': '1P',
|
||||||
|
'streamBufferSize':'2G'
|
||||||
|
}
|
||||||
|
|
||||||
def insertData(self):
|
def insertData(self):
|
||||||
tdLog.info(f"insert data.")
|
tdLog.info(f"insert data.")
|
||||||
|
|
||||||
|
@ -62,7 +71,7 @@ class TDTestCase(TBase):
|
||||||
|
|
||||||
# TSDB_FQDN_LEN = 128
|
# TSDB_FQDN_LEN = 128
|
||||||
lname = "testhostnamelength"
|
lname = "testhostnamelength"
|
||||||
lname.rjust(130, 'a')
|
lname.rjust(230, 'a')
|
||||||
|
|
||||||
# except test
|
# except test
|
||||||
sql = f"show vgroups;"
|
sql = f"show vgroups;"
|
||||||
|
@ -72,6 +81,9 @@ class TDTestCase(TBase):
|
||||||
etool.exeBinFile("taos", f'-a {lname} -s "{sql}" ', wait=False)
|
etool.exeBinFile("taos", f'-a {lname} -s "{sql}" ', wait=False)
|
||||||
etool.exeBinFile("taos", f'-p{lname} -s "{sql}" ', wait=False)
|
etool.exeBinFile("taos", f'-p{lname} -s "{sql}" ', wait=False)
|
||||||
etool.exeBinFile("taos", f'-w -s "{sql}" ', wait=False)
|
etool.exeBinFile("taos", f'-w -s "{sql}" ', wait=False)
|
||||||
|
etool.exeBinFile("taos", f'abc', wait=False)
|
||||||
|
etool.exeBinFile("taos", f'-V', wait=False)
|
||||||
|
etool.exeBinFile("taos", f'-?', wait=False)
|
||||||
|
|
||||||
# others
|
# others
|
||||||
etool.exeBinFile("taos", f'-N 200 -l 2048 -s "{sql}" ', wait=False)
|
etool.exeBinFile("taos", f'-N 200 -l 2048 -s "{sql}" ', wait=False)
|
||||||
|
@ -121,6 +133,11 @@ class TDTestCase(TBase):
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
eos.exe("pkill -9 taos")
|
eos.exe("pkill -9 taos")
|
||||||
|
|
||||||
|
# call enter password
|
||||||
|
etool.exeBinFile("taos", f'-p', wait=False)
|
||||||
|
time.sleep(1)
|
||||||
|
eos.exe("pkill -9 taos")
|
||||||
|
|
||||||
# run
|
# run
|
||||||
def run(self):
|
def run(self):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
{
|
||||||
|
"filetype": "insert",
|
||||||
|
"cfgdir": "/etc/taos",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 6030,
|
||||||
|
"user": "root",
|
||||||
|
"password": "taosdata",
|
||||||
|
"connection_pool_size": 8,
|
||||||
|
"num_of_records_per_req": 3000,
|
||||||
|
"prepared_rand": 3000,
|
||||||
|
"thread_count": 2,
|
||||||
|
"create_table_thread_count": 1,
|
||||||
|
"confirm_parameter_prompt": "no",
|
||||||
|
"databases": [
|
||||||
|
{
|
||||||
|
"dbinfo": {
|
||||||
|
"name": "db",
|
||||||
|
"drop": "yes",
|
||||||
|
"vgroups": 2,
|
||||||
|
"replica": 3,
|
||||||
|
"wal_retention_period": 10,
|
||||||
|
"wal_retention_size": 100,
|
||||||
|
"keep": "60d,120d,365d",
|
||||||
|
"stt_trigger": 1,
|
||||||
|
"wal_level": 2,
|
||||||
|
"WAL_FSYNC_PERIOD": 3300,
|
||||||
|
"cachemodel": "'last_value'",
|
||||||
|
"TABLE_PREFIX":1,
|
||||||
|
"comp": 1
|
||||||
|
},
|
||||||
|
"super_tables": [
|
||||||
|
{
|
||||||
|
"name": "stb",
|
||||||
|
"child_table_exists": "no",
|
||||||
|
"childtable_count": 10,
|
||||||
|
"insert_rows": 100000,
|
||||||
|
"childtable_prefix": "d",
|
||||||
|
"insert_mode": "taosc",
|
||||||
|
"timestamp_step": 1000,
|
||||||
|
"start_timestamp":"now-360d",
|
||||||
|
"columns": [
|
||||||
|
{ "type": "bool", "name": "bc","max": 1,"min": 1},
|
||||||
|
{ "type": "float", "name": "fc" ,"max": 101,"min": 101},
|
||||||
|
{ "type": "double", "name": "dc" ,"max": 102,"min": 102},
|
||||||
|
{ "type": "tinyint", "name": "ti" ,"max": 103,"min": 103},
|
||||||
|
{ "type": "smallint", "name": "si" ,"max": 104,"min": 104},
|
||||||
|
{ "type": "int", "name": "ic" ,"max": 105,"min": 105},
|
||||||
|
{ "type": "bigint", "name": "bi" ,"max": 106,"min": 106},
|
||||||
|
{ "type": "utinyint", "name": "uti","max": 107,"min": 107},
|
||||||
|
{ "type": "usmallint", "name": "usi","max": 108,"min": 108},
|
||||||
|
{ "type": "uint", "name": "ui" ,"max": 109,"min": 109},
|
||||||
|
{ "type": "ubigint", "name": "ubi","max": 110,"min": 110},
|
||||||
|
{ "type": "binary", "name": "bin", "len": 16},
|
||||||
|
{ "type": "nchar", "name": "nch", "len": 32}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
{"type": "tinyint", "name": "groupid","max": 100,"min": 100},
|
||||||
|
{"name": "location","type": "binary", "len": 16, "values":
|
||||||
|
["San Francisco", "Los Angles", "San Diego", "San Jose", "Palo Alto", "Campbell", "Mountain View","Sunnyvale", "Santa Clara", "Cupertino"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
###################################################################
|
||||||
|
# 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 random
|
||||||
|
|
||||||
|
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):
|
||||||
|
updatecfgDict = {
|
||||||
|
"compressMsgSize" : "100",
|
||||||
|
}
|
||||||
|
|
||||||
|
def insertData(self):
|
||||||
|
tdLog.info(f"insert data.")
|
||||||
|
# taosBenchmark run
|
||||||
|
jfile = etool.curFile(__file__, "oneStageComp.json")
|
||||||
|
etool.benchMark(json=jfile)
|
||||||
|
|
||||||
|
tdSql.execute(f"use {self.db}")
|
||||||
|
# set insert data information
|
||||||
|
self.childtable_count = 10
|
||||||
|
self.insert_rows = 100000
|
||||||
|
self.timestamp_step = 1000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def checkColValueCorrect(self):
|
||||||
|
tdLog.info(f"do action.")
|
||||||
|
self.flushDb()
|
||||||
|
|
||||||
|
# check all columns correct
|
||||||
|
cnt = self.insert_rows * self.childtable_count
|
||||||
|
sql = "select * from stb where bc!=1"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = "select * from stb where fc=101"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(cnt)
|
||||||
|
sql = "select * from stb where dc!=102"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = "select * from stb where ti!=103"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = "select * from stb where si!=104"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = "select * from stb where ic!=105"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = "select * from stb where bi!=106"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = "select * from stb where uti!=107"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = "select * from stb where usi!=108"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = "select * from stb where ui!=109"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = "select * from stb where ubi!=110"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
def insertNull(self):
|
||||||
|
# insert 6 lines
|
||||||
|
sql = "insert into d0(ts) values(now) (now + 1s) (now + 2s) (now + 3s) (now + 4s) (now + 5s)"
|
||||||
|
tdSql.execute(sql)
|
||||||
|
|
||||||
|
self.flushDb()
|
||||||
|
self.trimDb()
|
||||||
|
|
||||||
|
# check all columns correct
|
||||||
|
cnt = self.insert_rows * self.childtable_count
|
||||||
|
sql = "select * from stb where bc!=1"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
sql = "select * from stb where bc is null"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(6)
|
||||||
|
sql = "select * from stb where bc=1"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(cnt)
|
||||||
|
sql = "select * from stb where usi is null"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tdSql.checkRows(6)
|
||||||
|
|
||||||
|
# run
|
||||||
|
def run(self):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
|
||||||
|
# insert data
|
||||||
|
self.insertData()
|
||||||
|
|
||||||
|
# check insert data correct
|
||||||
|
self.checkInsertCorrect()
|
||||||
|
|
||||||
|
# save
|
||||||
|
self.snapshotAgg()
|
||||||
|
|
||||||
|
# do action
|
||||||
|
self.checkColValueCorrect()
|
||||||
|
|
||||||
|
# check save agg result correct
|
||||||
|
self.checkAggCorrect()
|
||||||
|
|
||||||
|
# insert null
|
||||||
|
self.insertNull()
|
||||||
|
|
||||||
|
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -23,7 +23,7 @@ fi
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/query/query_basic.py -N 3
|
,,y,army,./pytest.sh python3 ./test.py -f community/query/query_basic.py -N 3
|
||||||
,,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
|
||||||
|
,,y,army,./pytest.sh python3 ./test.py -f community/storage/oneStageComp.py -N 3 -L 3 -D 1
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -350,6 +350,7 @@ fi
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/ts-4272.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/ts-4272.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_ts4295.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_ts4295.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_td27388.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_td27388.py
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_ts4479.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_timestamp.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_timestamp.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show_tag_index.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show_tag_index.py
|
||||||
|
@ -567,7 +568,7 @@ fi
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/systable_func.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/systable_func.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/test_ts4382.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/test_ts4382.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/test_ts4403.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/test_ts4403.py
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/test_td28163.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/elapsed.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/elapsed.py
|
||||||
|
|
|
@ -211,7 +211,7 @@ function lcovFunc {
|
||||||
'*/AccessBridgeCalls.c' '*/ttszip.c' '*/dataInserter.c' '*/tlinearhash.c' '*/tsimplehash.c' '*/tsdbDiskData.c'\
|
'*/AccessBridgeCalls.c' '*/ttszip.c' '*/dataInserter.c' '*/tlinearhash.c' '*/tsimplehash.c' '*/tsdbDiskData.c'\
|
||||||
'*/texpr.c' '*/runUdf.c' '*/schDbg.c' '*/syncIO.c' '*/tdbOs.c' '*/pushServer.c' '*/osLz4.c'\
|
'*/texpr.c' '*/runUdf.c' '*/schDbg.c' '*/syncIO.c' '*/tdbOs.c' '*/pushServer.c' '*/osLz4.c'\
|
||||||
'*/tbase64.c' '*/tbuffer.c' '*/tdes.c' '*/texception.c' '*/examples/*' '*/tidpool.c' '*/tmempool.c'\
|
'*/tbase64.c' '*/tbuffer.c' '*/tdes.c' '*/texception.c' '*/examples/*' '*/tidpool.c' '*/tmempool.c'\
|
||||||
'*/clientJniConnector.c' '*/clientTmqConnector.c' '*/version.c'\
|
'*/clientJniConnector.c' '*/clientTmqConnector.c' '*/version.c' '*/build_version.cc'\
|
||||||
'*/tthread.c' '*/tversion.c' '*/ctgDbg.c' '*/schDbg.c' '*/qwDbg.c' '*/tencode.h' \
|
'*/tthread.c' '*/tversion.c' '*/ctgDbg.c' '*/schDbg.c' '*/qwDbg.c' '*/tencode.h' \
|
||||||
'*/shellAuto.c' '*/shellTire.c' '*/shellCommand.c'\
|
'*/shellAuto.c' '*/shellTire.c' '*/shellCommand.c'\
|
||||||
'*/sql.c' '*/sql.y'\
|
'*/sql.c' '*/sql.y'\
|
||||||
|
|
|
@ -72,7 +72,7 @@ python_error=$(cat ${LOG_DIR}/*.info | grep -w "stack" | wc -l)
|
||||||
|
|
||||||
#0 0x7f2d64f5a808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
|
#0 0x7f2d64f5a808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
|
||||||
#1 0x7f2d63fcf459 in strerror /build/glibc-SzIz7B/glibc-2.31/string/strerror.c:38
|
#1 0x7f2d63fcf459 in strerror /build/glibc-SzIz7B/glibc-2.31/string/strerror.c:38
|
||||||
runtime_error=$(cat ${LOG_DIR}/*.asan | grep "runtime error" | grep -v "trees.c:873" | grep -v "sclfunc.c.*outside the range of representable values of type" | grep -v "signed integer overflow" | grep -v "strerror.c" | grep -v "asan_malloc_linux.cc" | grep -v "strerror.c" | wc -l)
|
runtime_error=$(cat ${LOG_DIR}/*.asan | grep "runtime error" | grep -v "trees.c:873" | grep -v "sclfunc.c.*outside the range of representable values of type" | grep -v "signed integer overflow" | grep -v "strerror.c" | grep -v "asan_malloc_linux.cc" | grep -v "strerror.c" | grep -v "asan_malloc_linux.cpp" | grep -v "sclvector.c" | wc -l)
|
||||||
|
|
||||||
echo -e "\033[44;32;1m"asan error_num: $error_num"\033[0m"
|
echo -e "\033[44;32;1m"asan error_num: $error_num"\033[0m"
|
||||||
echo -e "\033[44;32;1m"asan memory_leak: $memory_leak"\033[0m"
|
echo -e "\033[44;32;1m"asan memory_leak: $memory_leak"\033[0m"
|
||||||
|
|
|
@ -290,6 +290,213 @@ if $data32 != $now32 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print step 2 max delay 2s
|
||||||
|
sql create database test15 vgroups 4;
|
||||||
|
sql use test15;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
|
||||||
|
sql create stream stream15 trigger max_delay 2s into streamt13 as select _wstart, sum(a), now from t1 session(ts, 10s);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791233001,2,2,3,1.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop4:
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 20 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt13;
|
||||||
|
|
||||||
|
if $rows != 2 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop4
|
||||||
|
endi
|
||||||
|
|
||||||
|
$now02 = $data02
|
||||||
|
$now12 = $data12
|
||||||
|
|
||||||
|
|
||||||
|
print step1 max delay 2s......... sleep 3s
|
||||||
|
sleep 3000
|
||||||
|
|
||||||
|
sql select * from streamt13;
|
||||||
|
|
||||||
|
|
||||||
|
if $data02 != $now02 then
|
||||||
|
print ======data02=$data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != $now12 then
|
||||||
|
print ======data12=$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print step1 max delay 2s......... sleep 3s
|
||||||
|
sleep 3000
|
||||||
|
|
||||||
|
sql select * from streamt13;
|
||||||
|
|
||||||
|
|
||||||
|
if $data02 != $now02 then
|
||||||
|
print ======data02=$data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != $now12 then
|
||||||
|
print ======data12=$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print session max delay over
|
||||||
|
|
||||||
|
print step 3 max delay 2s
|
||||||
|
sql create database test16 vgroups 4;
|
||||||
|
sql use test16;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
|
||||||
|
sql create stream stream16 trigger max_delay 2s into streamt13 as select _wstart, sum(a), now from t1 state_window(a);
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791233001,2,2,3,1.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop5:
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 20 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt13;
|
||||||
|
|
||||||
|
if $rows != 2 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop5
|
||||||
|
endi
|
||||||
|
|
||||||
|
$now02 = $data02
|
||||||
|
$now12 = $data12
|
||||||
|
|
||||||
|
|
||||||
|
print step1 max delay 2s......... sleep 3s
|
||||||
|
sleep 3000
|
||||||
|
|
||||||
|
sql select * from streamt13;
|
||||||
|
|
||||||
|
|
||||||
|
if $data02 != $now02 then
|
||||||
|
print ======data02=$data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != $now12 then
|
||||||
|
print ======data12=$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print step1 max delay 2s......... sleep 3s
|
||||||
|
sleep 3000
|
||||||
|
|
||||||
|
sql select * from streamt13;
|
||||||
|
|
||||||
|
|
||||||
|
if $data02 != $now02 then
|
||||||
|
print ======data02=$data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != $now12 then
|
||||||
|
print ======data12=$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print state max delay over
|
||||||
|
|
||||||
|
print step 4 max delay 2s
|
||||||
|
sql create database test17 vgroups 4;
|
||||||
|
sql use test17;
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
|
||||||
|
sql create stream stream17 trigger max_delay 2s into streamt13 as select _wstart, sum(a), now from t1 event_window start with a = 1 end with a = 9;
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791213000,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791213001,9,2,3,1.0);
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791233001,1,2,3,1.1);
|
||||||
|
sql insert into t1 values(1648791233009,9,2,3,1.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop6:
|
||||||
|
|
||||||
|
sleep 1000
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 20 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from streamt13;
|
||||||
|
|
||||||
|
if $rows != 2 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop6
|
||||||
|
endi
|
||||||
|
|
||||||
|
$now02 = $data02
|
||||||
|
$now12 = $data12
|
||||||
|
|
||||||
|
|
||||||
|
print step1 max delay 2s......... sleep 3s
|
||||||
|
sleep 3000
|
||||||
|
|
||||||
|
sql select * from streamt13;
|
||||||
|
|
||||||
|
|
||||||
|
if $data02 != $now02 then
|
||||||
|
print ======data02=$data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != $now12 then
|
||||||
|
print ======data12=$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print step1 max delay 2s......... sleep 3s
|
||||||
|
sleep 3000
|
||||||
|
|
||||||
|
sql select * from streamt13;
|
||||||
|
|
||||||
|
|
||||||
|
if $data02 != $now02 then
|
||||||
|
print ======data02=$data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != $now12 then
|
||||||
|
print ======data12=$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print event max delay over
|
||||||
|
|
||||||
print ======over
|
print ======over
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
|
@ -263,6 +263,54 @@ class TDTestCase:
|
||||||
tdSql.error(f'select c_active_code from information_schema.ins_dnodes')
|
tdSql.error(f'select c_active_code from information_schema.ins_dnodes')
|
||||||
tdSql.error('alter all dnodes "cActiveCode" ""')
|
tdSql.error('alter all dnodes "cActiveCode" ""')
|
||||||
|
|
||||||
|
def ins_grants_check(self):
|
||||||
|
grant_name_dict = {
|
||||||
|
'stream':'stream',
|
||||||
|
'subscription':'subscription',
|
||||||
|
'view':'view',
|
||||||
|
'audit':'audit',
|
||||||
|
'csv':'csv',
|
||||||
|
'storage':'multi_tier_storage',
|
||||||
|
'backup_restore':'backup_restore',
|
||||||
|
'opc_da':'OPC_DA',
|
||||||
|
'opc_ua':'OPC_UA',
|
||||||
|
'pi':'Pi',
|
||||||
|
'kafka':'Kafka',
|
||||||
|
'influxdb':'InfluxDB',
|
||||||
|
'mqtt':'MQTT',
|
||||||
|
'avevahistorian':'avevaHistorian',
|
||||||
|
'opentsdb':'OpenTSDB',
|
||||||
|
'td2.6':'TDengine2.6',
|
||||||
|
'td3.0':'TDengine3.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
tdSql.execute('drop database if exists db2')
|
||||||
|
tdSql.execute('create database if not exists db2 vgroups 1 replica 1')
|
||||||
|
tdSql.query(f'select * from information_schema.ins_grants_full')
|
||||||
|
result = tdSql.queryResult
|
||||||
|
index = 0
|
||||||
|
for i in range(0, len(result)):
|
||||||
|
if result[i][0] in grant_name_dict:
|
||||||
|
tdSql.checkEqual(result[i][1], grant_name_dict[result[i][0]])
|
||||||
|
index += 1
|
||||||
|
tdSql.checkEqual(index, 17)
|
||||||
|
tdSql.query(f'select * from information_schema.ins_grants_logs')
|
||||||
|
result = tdSql.queryResult
|
||||||
|
tdSql.checkEqual(True, len(result) >= 0)
|
||||||
|
if(len(result) > 0):
|
||||||
|
tdSql.checkEqual(True, result[0][0].find(",init,ungranted,ungranted") >= 16)
|
||||||
|
tdSql.checkEqual(True, len(result[0][1]) == 0)
|
||||||
|
tdSql.checkEqual(True, len(result[0][2]) >= 46)
|
||||||
|
|
||||||
|
tdSql.query(f'select * from information_schema.ins_machines')
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.execute('alter cluster "activeCode" "revoked"')
|
||||||
|
tdSql.execute('alter cluster "activeCode" "revoked"')
|
||||||
|
tdSql.error('alter cluster "activeCode" ""')
|
||||||
|
tdSql.error('alter cluster "activeCode" "abc"')
|
||||||
|
tdSql.error('alter cluster "activeCode" ""')
|
||||||
|
tdSql.execute('alter cluster "activeCode" "revoked"')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.prepare_data()
|
self.prepare_data()
|
||||||
self.count_check()
|
self.count_check()
|
||||||
|
@ -271,6 +319,7 @@ class TDTestCase:
|
||||||
self.ins_stable_check()
|
self.ins_stable_check()
|
||||||
self.ins_stable_check2()
|
self.ins_stable_check2()
|
||||||
self.ins_dnodes_check()
|
self.ins_dnodes_check()
|
||||||
|
self.ins_grants_check()
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.dnodes import tdDnodes
|
||||||
|
from math import inf
|
||||||
|
import taos
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
"""Verify inserting varbinary type data of ts-4479
|
||||||
|
"""
|
||||||
|
def init(self, conn, logSql, replicaVer=1):
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor(), True)
|
||||||
|
self.conn = conn
|
||||||
|
self.db_name = "db"
|
||||||
|
self.stable_name = "st"
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.execute("create database if not exists %s" % self.db_name)
|
||||||
|
tdSql.execute("use %s" % self.db_name)
|
||||||
|
# create super table
|
||||||
|
tdSql.execute("create table %s (ts timestamp, c1 varbinary(65517)) tags (t1 varbinary(16382))" % self.stable_name)
|
||||||
|
|
||||||
|
# varbinary tag length is more than 16382
|
||||||
|
tag = os.urandom(16383).hex()
|
||||||
|
tdSql.error("create table ct using st tags(%s);" % ('\\x' + tag))
|
||||||
|
|
||||||
|
# create child table with max column and tag length
|
||||||
|
child_table_list = []
|
||||||
|
for i in range(2):
|
||||||
|
child_table_name = "ct_" + str(i+1)
|
||||||
|
child_table_list.append(child_table_name)
|
||||||
|
tag = os.urandom(16382).hex()
|
||||||
|
tdSql.execute("create table %s using st tags('%s');" % (child_table_name, '\\x' + tag))
|
||||||
|
tdLog.info("create table %s successfully" % child_table_name)
|
||||||
|
|
||||||
|
# varbinary column length is more than 65517
|
||||||
|
value = os.urandom(65518).hex()
|
||||||
|
tdSql.error("insert into ct_1 values(now, '\\x%s');" % value)
|
||||||
|
|
||||||
|
# insert data
|
||||||
|
for i in range(10):
|
||||||
|
sql = "insert into table_name values"
|
||||||
|
for j in range(5):
|
||||||
|
value = os.urandom(65517).hex()
|
||||||
|
sql += "(now+%ss, '%s')," % (str(j+1), '\\x' + value)
|
||||||
|
for child_table in child_table_list:
|
||||||
|
tdSql.execute(sql.replace("table_name", child_table))
|
||||||
|
tdLog.info("Insert data into %s successfully" % child_table)
|
||||||
|
tdLog.info("Insert data round %s successfully" % str(i+1))
|
||||||
|
tdSql.execute("flush database %s" % self.db_name)
|
||||||
|
|
||||||
|
# insert \\x to varbinary column
|
||||||
|
tdSql.execute("insert into ct_1 values(now, '\\x');")
|
||||||
|
tdSql.query("select * from ct_1 where c1 = '\\x';")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 1, b'')
|
||||||
|
|
||||||
|
# insert \\x to varbinary tag
|
||||||
|
tdSql.execute("create table ct_3 using st tags('\\x');")
|
||||||
|
tdSql.execute("insert into ct_3 values(now, '\\x45');")
|
||||||
|
tdSql.query("select * from st where t1='';")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 2, b'')
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.execute("drop database if exists %s" % self.db_name)
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -42,18 +42,38 @@ class TDTestCase:
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
binPath = self.getPath()
|
binPath = self.getPath()
|
||||||
tdLog.debug("insert full data block and flush db")
|
tdLog.debug("insert full data block that has first time '2021-10-02 00:00:00.001' and flush db")
|
||||||
os.system(f"{binPath} -f ./2-query/megeFileSttQuery.json")
|
os.system(f"{binPath} -f ./2-query/megeFileSttQuery.json")
|
||||||
tdSql.execute("flush database db;")
|
tdSql.execute("flush database db;")
|
||||||
tdLog.debug("insert disorder data and flush db")
|
|
||||||
|
tdLog.debug("insert only a piece of data that is behind the time that already exists and flush db")
|
||||||
|
tdSql.execute("insert into db.d0 values ('2021-10-01 23:59:59.990',12.793,208,0.84) ;")
|
||||||
|
tdSql.execute("flush database db;")
|
||||||
|
tdLog.debug("check data")
|
||||||
|
sleep(1)
|
||||||
|
tdSql.query("select count(*) from db.d0;")
|
||||||
|
tdSql.checkData(0,0,10001)
|
||||||
|
tdSql.execute("drop database db;")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tdLog.debug("insert full data block that has first time '2021-10-02 00:00:00.001' and flush db")
|
||||||
|
os.system(f"{binPath} -f ./2-query/megeFileSttQuery.json")
|
||||||
|
tdSql.execute("flush database db;")
|
||||||
|
|
||||||
|
tdLog.debug("insert four pieces of disorder data, and the time range covers the data file that was previously placed on disk and flush db")
|
||||||
os.system(f"{binPath} -f ./2-query/megeFileSttQueryUpdate.json")
|
os.system(f"{binPath} -f ./2-query/megeFileSttQueryUpdate.json")
|
||||||
tdSql.execute("flush database db;")
|
tdSql.execute("flush database db;")
|
||||||
tdLog.debug("check data")
|
tdLog.debug("check data")
|
||||||
|
tdSql.query("select count(*) from db.d0;",queryTimes=3)
|
||||||
|
tdSql.checkData(0,0,10004)
|
||||||
tdSql.query("select ts from db.d0 limit 5;")
|
tdSql.query("select ts from db.d0 limit 5;")
|
||||||
tdSql.checkData(0, 0, '2021-10-02 00:00:00.001')
|
tdSql.checkData(0, 0, '2021-10-02 00:00:00.001')
|
||||||
tdSql.checkData(1, 0, '2021-10-02 00:01:00.000')
|
tdSql.checkData(1, 0, '2021-10-02 00:01:00.000')
|
||||||
tdLog.debug("update disorder data and flush db")
|
|
||||||
|
|
||||||
|
tdLog.debug("update the same disorder data and flush db")
|
||||||
os.system(f"{binPath} -f ./2-query/megeFileSttQueryUpdate.json")
|
os.system(f"{binPath} -f ./2-query/megeFileSttQueryUpdate.json")
|
||||||
tdSql.query("select ts from db.d0 limit 5;")
|
tdSql.query("select ts from db.d0 limit 5;")
|
||||||
tdSql.checkData(0, 0, '2021-10-02 00:00:00.001')
|
tdSql.checkData(0, 0, '2021-10-02 00:00:00.001')
|
||||||
|
|
|
@ -0,0 +1,265 @@
|
||||||
|
import random
|
||||||
|
import itertools
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.sqlset import *
|
||||||
|
from util import constant
|
||||||
|
from util.common import *
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
"""Verify the jira TD-28163
|
||||||
|
"""
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
def prepareData(self):
|
||||||
|
# db
|
||||||
|
tdSql.execute("create database if not exists db")
|
||||||
|
tdSql.execute("use db")
|
||||||
|
|
||||||
|
# super table
|
||||||
|
tdSql.execute("create stable st(ts timestamp, c_ts_empty timestamp, c_int int, c_int_empty int, c_unsigned_int int unsigned, \
|
||||||
|
c_unsigned_int_empty int unsigned, c_bigint bigint, c_bigint_empty bigint, c_unsigned_bigint bigint unsigned, \
|
||||||
|
c_unsigned_bigint_empty bigint unsigned, c_float float, c_float_empty float, c_double double, c_double_empty double, \
|
||||||
|
c_binary binary(16), c_binary_empty binary(16), c_smallint smallint, c_smallint_empty smallint, \
|
||||||
|
c_smallint_unsigned smallint unsigned, c_smallint_unsigned_empty smallint unsigned, c_tinyint tinyint, \
|
||||||
|
c_tinyint_empty tinyint, c_tinyint_unsigned tinyint unsigned, c_tinyint_unsigned_empty tinyint unsigned, \
|
||||||
|
c_bool bool, c_bool_empty bool, c_nchar nchar(16), c_nchar_empty nchar(16), c_varchar varchar(16), \
|
||||||
|
c_varchar_empty varchar(16), c_varbinary varbinary(16), c_varbinary_empty varbinary(16)) \
|
||||||
|
tags(t_timestamp timestamp, t_timestamp_empty timestamp, t_int int, t_int_empty int, \
|
||||||
|
t_unsigned_int int unsigned, t_unsigned_int_empty int unsigned, t_bigint bigint, t_bigint_empty bigint, \
|
||||||
|
t_unsigned_bigint bigint unsigned, t_unsigned_bigint_empty bigint unsigned, t_float float, t_float_empty float, \
|
||||||
|
t_double double, t_double_empty double, t_binary binary(16), t_binary_empty binary(16), t_smallint smallint, \
|
||||||
|
t_smallint_empty smallint, t_smallint_unsigned smallint unsigned, t_smallint_unsigned_empty smallint unsigned, \
|
||||||
|
t_tinyint tinyint, t_tinyint_empty tinyint, t_tinyint_unsigned tinyint unsigned, t_tinyint_unsigned_empty tinyint unsigned, \
|
||||||
|
t_bool bool, t_bool_empty bool, t_nchar nchar(16), t_nchar_empty nchar(16), t_varchar varchar(16), \
|
||||||
|
t_varchar_empty varchar(16), t_varbinary varbinary(16), t_varbinary_empty varbinary(16));")
|
||||||
|
|
||||||
|
# child tables
|
||||||
|
start_ts = 1704085200000
|
||||||
|
tags = [
|
||||||
|
"'2024-01-01 13:00:01', null, 1, null, 1, null, 1111111111111111, null, 1111111111111111, null, 1.1, null, 1.11, null, 'aaaaaaaa', '', 1, null, 1, null, 1, null, 1, null, True, null, 'ncharaa', null, 'varcharaa', null, '0x7661726331', null",
|
||||||
|
"'2024-01-01 13:00:02', null, 2, null, 2, null, 2222222222222222, null, 2222222222222222, null, 2.2, null, 2.22, null, 'bbbbbbbb', '', 2, null, 2, null, 2, null, 2, null, False, null, 'ncharbb', null, 'varcharbb', null, '0x7661726332', null",
|
||||||
|
"'2024-01-01 13:00:03', null, 3, null, 3, null, 3333333333333333, null, 3333333333333333, null, 3.3, null, 3.33, null, 'cccccccc', '', 3, null, 3, null, 3, null, 3, null, True, null, 'ncharcc', null, 'varcharcc', null, '0x7661726333', null",
|
||||||
|
"'2024-01-01 13:00:04', null, 4, null, 4, null, 4444444444444444, null, 4444444444444444, null, 4.4, null, 4.44, null, 'dddddddd', '', 4, null, 4, null, 4, null, 4, null, False, null, 'nchardd', null, 'varchardd', null, '0x7661726334', null",
|
||||||
|
"'2024-01-01 13:00:05', null, 5, null, 5, null, 5555555555555555, null, 5555555555555555, null, 5.5, null, 5.55, null, 'eeeeeeee', '', 5, null, 5, null, 5, null, 5, null, True, null, 'ncharee', null, 'varcharee', null, '0x7661726335', null",
|
||||||
|
]
|
||||||
|
for i in range(5):
|
||||||
|
tdSql.execute(f"create table ct{i+1} using st tags({tags[i]});")
|
||||||
|
|
||||||
|
# insert data
|
||||||
|
data = "null, 1, null, 1, null, 1111111111111111, null, 1111111111111111, null, 1.1, null, 1.11, null, 'aaaaaaaa', null, 1, null, 1, null, 1, null, 1, null, True, null, 'ncharaa', null, 'varcharaa', null, '0x7661726331', null"
|
||||||
|
for round in range(100):
|
||||||
|
sql = f"insert into ct{i+1} values"
|
||||||
|
for j in range(100):
|
||||||
|
sql += f"({start_ts + (round * 100 + j + 1) * 1000}, {data})"
|
||||||
|
sql += ";"
|
||||||
|
tdSql.execute(sql)
|
||||||
|
tdLog.debug("Prepare data successfully")
|
||||||
|
|
||||||
|
def test_query_with_filter(self):
|
||||||
|
# total row number
|
||||||
|
tdSql.query("select count(*) from st;")
|
||||||
|
total_rows = tdSql.queryResult[0][0]
|
||||||
|
tdLog.debug("Total row number is %s" % total_rows)
|
||||||
|
|
||||||
|
# start_ts and end_ts
|
||||||
|
tdSql.query("select first(ts), last(ts) from st;")
|
||||||
|
start_ts = tdSql.queryResult[0][0]
|
||||||
|
end_ts = tdSql.queryResult[0][1]
|
||||||
|
tdLog.debug("start_ts is %s, end_ts is %s" % (start_ts, end_ts))
|
||||||
|
|
||||||
|
filter_dic = {
|
||||||
|
"all_filter_list": ["ts <= now", "t_timestamp <= now", f"ts between '{start_ts}' and '{end_ts}'",
|
||||||
|
f"t_timestamp between '{start_ts}' and '{end_ts}'", "c_ts_empty is null",
|
||||||
|
"t_timestamp_empty is null", "ts > '1970-01-01 00:00:00'", "t_int in (1, 2, 3, 4, 5)",
|
||||||
|
"c_int=1", "c_int_empty is null", "c_unsigned_int=1", "c_unsigned_int_empty is null",
|
||||||
|
"c_unsigned_int in (1, 2, 3, 4, 5)", "c_unsigned_int_empty is null", "c_bigint=1111111111111111",
|
||||||
|
"c_bigint_empty is null", "c_unsigned_bigint in (1111111111111111)", "c_unsigned_bigint_empty is null",
|
||||||
|
"c_float=1.1", "c_float_empty is null", "c_double=1.11", "c_double_empty is null", "c_binary='aaaaaaaa'",
|
||||||
|
"c_binary_empty is null", "c_smallint=1", "c_smallint_empty is null", "c_smallint_unsigned=1",
|
||||||
|
"c_smallint_unsigned_empty is null", "c_tinyint=1", "c_tinyint_empty is null", "c_tinyint_unsigned=1",
|
||||||
|
"c_tinyint_unsigned_empty is null", "c_bool=True", "c_bool_empty is null", "c_nchar='ncharaa'",
|
||||||
|
"c_nchar_empty is null", "c_varchar='varcharaa'", "c_varchar_empty is null", "c_varbinary='0x7661726331'",
|
||||||
|
"c_varbinary_empty is null"],
|
||||||
|
"empty_filter_list": ["ts > now", "t_timestamp > now", "c_ts_empty is not null","t_timestamp_empty is not null",
|
||||||
|
"ts <= '1970-01-01 00:00:00'", "c_ts_empty < '1970-01-01 00:00:00'", "c_int <> 1", "c_int_empty is not null",
|
||||||
|
"t_int in (10, 11)", "t_int_empty is not null"]
|
||||||
|
}
|
||||||
|
for filter in filter_dic["all_filter_list"]:
|
||||||
|
tdLog.debug("Execute query with filter '%s'" % filter)
|
||||||
|
tdSql.query(f"select * from st where {filter};")
|
||||||
|
tdSql.checkRows(total_rows)
|
||||||
|
|
||||||
|
for filter in filter_dic["empty_filter_list"]:
|
||||||
|
tdLog.debug("Execute query with filter '%s'" % filter)
|
||||||
|
tdSql.query(f"select * from st where {filter};")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
def test_query_with_groupby(self):
|
||||||
|
tdSql.query("select count(*) from st group by tbname;")
|
||||||
|
tdSql.checkRows(5)
|
||||||
|
tdSql.checkData(0, 0, 10000)
|
||||||
|
|
||||||
|
tdSql.query("select count(c_unsigned_int_empty + c_int_empty * c_float_empty - c_double_empty + c_smallint_empty / c_tinyint_empty) from st where c_int_empty is null group by tbname;")
|
||||||
|
tdSql.checkRows(5)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
|
||||||
|
tdSql.query("select sum(t_unsigned_int_empty + t_int_empty * t_float_empty - t_double_empty + t_smallint_empty / t_tinyint_empty) from st where t_int_empty is null group by tbname;")
|
||||||
|
tdSql.checkRows(5)
|
||||||
|
tdSql.checkData(0, 0, None)
|
||||||
|
|
||||||
|
tdSql.query("select max(c_bigint_empty) from st group by tbname, t_bigint_empty, t_float_empty, t_double_empty;")
|
||||||
|
tdSql.checkRows(5)
|
||||||
|
tdSql.checkData(0, 0, None)
|
||||||
|
|
||||||
|
tdSql.query("select min(t_double) as v from st where c_nchar like '%aa%' and t_double is not null group by tbname, t_bigint_empty, t_float_empty, t_double_empty order by v limit 1;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 1.11)
|
||||||
|
|
||||||
|
tdSql.query("select top(c_float, 1) as v from st where c_nchar like '%aa%' group by tbname order by v desc slimit 1 limit 1;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 1.1)
|
||||||
|
|
||||||
|
tdSql.query("select first(ts) from st where c_varchar is not null partition by tbname order by ts slimit 1;")
|
||||||
|
tdSql.checkRows(5)
|
||||||
|
tdSql.checkData(0, 0, '2024-01-01 13:00:01.000')
|
||||||
|
|
||||||
|
tdSql.query("select first(c_nchar_empty) from st group by tbname;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.query("select first(ts), first(c_nchar_empty) from st group by tbname, ts order by ts slimit 1 limit 1;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, '2024-01-01 13:00:01.000')
|
||||||
|
tdSql.checkData(0, 1, None)
|
||||||
|
|
||||||
|
tdSql.query("select first(c_nchar_empty) from st group by t_timestamp_empty order by t_timestamp;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.query("select last(ts), last(c_nchar_empty) from st group by tbname, ts order by ts slimit 1 limit 1;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, '2024-01-01 13:00:01.000')
|
||||||
|
tdSql.checkData(0, 1, None)
|
||||||
|
|
||||||
|
tdSql.query("select elapsed(ts, 1s) t from st where c_int = 1 and c_nchar like '%aa%' group by tbname order by t desc slimit 1 limit 1;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 9999)
|
||||||
|
|
||||||
|
tdSql.query("select elapsed(ts, 1s) t from st where c_int_empty is not null and c_nchar like '%aa%' group by tbname order by t desc slimit 1 limit 1;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
def test_query_with_join(self):
|
||||||
|
tdSql.query("select count(*) from st as t1 join st as t2 on t1.ts = t2.ts and t1.c_float_empty is not null;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
|
||||||
|
tdSql.query("select count(t1.c_ts_empty) as v from st as t1 join st as t2 on t1.ts = t2.ts and t1.c_float_empty is null order by v desc;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
|
||||||
|
tdSql.query("select avg(t1.c_tinyint), sum(t2.c_bigint) from st t1, st t2 where t1.ts=t2.ts and t1.c_int > t2.c_int;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.query("select avg(t1.c_tinyint), sum(t2.c_bigint) from st t1, st t2 where t1.ts=t2.ts and t1.c_int <= t2.c_int;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 1)
|
||||||
|
tdSql.checkData(0, 1, 1076616672134475760)
|
||||||
|
|
||||||
|
tdSql.query("select count(t1.c_float_empty) from st t1, st t2 where t1.ts=t2.ts and t1.c_int = t2.c_int and t1.t_int_empty=t2.t_int_empty;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
|
||||||
|
def test_query_with_window(self):
|
||||||
|
# time window
|
||||||
|
tdSql.query("select sum(c_int_empty) from st where ts > '2024-01-01 00:00:00.000' and ts <= '2024-01-01 14:00:00.000' interval(5m) sliding(1m) fill(value, 10);")
|
||||||
|
tdSql.checkRows(841)
|
||||||
|
tdSql.checkData(0, 0, 10)
|
||||||
|
|
||||||
|
tdSql.query("select _wstart, _wend, sum(c_int) from st where ts > '2024-01-01 00:00:00.000' and ts <= '2024-01-01 14:00:00.000' interval(5m) sliding(1m);")
|
||||||
|
tdSql.checkRows(65)
|
||||||
|
|
||||||
|
# status window
|
||||||
|
tdSql.error("select _wstart, count(*) from st state_window(t_bool);")
|
||||||
|
tdSql.query("select _wstart, count(*) from st partition by tbname state_window(c_bool);")
|
||||||
|
tdSql.checkRows(5)
|
||||||
|
tdSql.checkData(0, 1, 10000)
|
||||||
|
|
||||||
|
# session window
|
||||||
|
tdSql.query("select _wstart, count(*) from st partition by tbname, t_int session(ts, 1m);")
|
||||||
|
tdSql.checkRows(5)
|
||||||
|
tdSql.checkData(0, 1, 10000)
|
||||||
|
|
||||||
|
# event window
|
||||||
|
tdSql.query("select _wstart, _wend, count(*) from (select * from st order by ts, tbname) event_window start with t_bool=true end with t_bool=false;")
|
||||||
|
tdSql.checkRows(20000)
|
||||||
|
|
||||||
|
def test_query_with_union(self):
|
||||||
|
tdSql.query("select count(ts) from (select * from ct1 union select * from ct2 union select * from ct3);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 10000)
|
||||||
|
|
||||||
|
tdSql.query("select count(ts) from (select * from ct1 union all select * from ct2 union all select * from ct3);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 30000)
|
||||||
|
|
||||||
|
tdSql.query("select count(*) from (select * from ct1 union select * from ct2 union select * from ct3);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 10000)
|
||||||
|
|
||||||
|
tdSql.query("select count(c_ts_empty) from (select * from ct1 union select * from ct2 union select * from ct3);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
|
||||||
|
tdSql.query("select count(*) from (select ts from st union select c_ts_empty from st);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 10001)
|
||||||
|
|
||||||
|
tdSql.query("select count(*) from (select ts from st union all select c_ts_empty from st);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 100000)
|
||||||
|
|
||||||
|
tdSql.query("select count(ts) from (select ts from st union select c_ts_empty from st);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 10000)
|
||||||
|
|
||||||
|
tdSql.query("select count(ts) from (select ts from st union all select c_ts_empty from st);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 50000)
|
||||||
|
|
||||||
|
def test_nested_query(self):
|
||||||
|
tdSql.query("select elapsed(ts, 1s) from (select * from (select * from st where c_int = 1) where c_int_empty is null);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 9999)
|
||||||
|
|
||||||
|
tdSql.query("select first(ts) as t, avg(c_int) as v from (select * from (select * from st where c_int = 1) where c_int_empty is null) group by t_timestamp order by t_timestamp desc slimit 1 limit 1;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, '2024-01-01 13:00:01.000')
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
|
||||||
|
tdSql.query("select max(c_tinyint) from (select c_tinyint, tbname from st where c_float_empty is null or t_int_empty is null) group by tbname order by c_tinyint desc slimit 1 limit 1;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 1)
|
||||||
|
|
||||||
|
tdSql.query("select top(c_int, 3) from (select c_int, tbname from st where t_int in (2, 3)) group by tbname slimit 3;")
|
||||||
|
tdSql.checkRows(6)
|
||||||
|
tdSql.checkData(0, 0, 1)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.prepareData()
|
||||||
|
self.test_query_with_filter()
|
||||||
|
self.test_query_with_groupby()
|
||||||
|
self.test_query_with_join()
|
||||||
|
self.test_query_with_window()
|
||||||
|
self.test_query_with_union()
|
||||||
|
self.test_nested_query()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -58,8 +58,8 @@ class TDTestCase:
|
||||||
tdSql.query(f'select wstart, {self.tdCom.stb_output_select_str} from {tbname}')
|
tdSql.query(f'select wstart, {self.tdCom.stb_output_select_str} from {tbname}')
|
||||||
else:
|
else:
|
||||||
tdSql.query(f'select wstart, {self.tdCom.tb_output_select_str} from {tbname}')
|
tdSql.query(f'select wstart, {self.tdCom.tb_output_select_str} from {tbname}')
|
||||||
if not fill_history_value:
|
# if not fill_history_value:
|
||||||
tdSql.checkEqual(tdSql.queryRows, init_num)
|
# tdSql.checkEqual(tdSql.queryRows, init_num)
|
||||||
|
|
||||||
self.tdCom.sinsert_rows(tbname=self.ctb_name, ts_value=window_close_ts)
|
self.tdCom.sinsert_rows(tbname=self.ctb_name, ts_value=window_close_ts)
|
||||||
self.tdCom.sinsert_rows(tbname=self.tb_name, ts_value=window_close_ts)
|
self.tdCom.sinsert_rows(tbname=self.tb_name, ts_value=window_close_ts)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue