TDengine/source/dnode/mnode/impl/inc/mndDef.h

910 lines
22 KiB
C
Raw Normal View History

2021-09-22 08:15:20 +00:00
/*
* 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/>.
*/
2021-11-27 15:02:20 +00:00
#ifndef _TD_MND_DEF_H_
#define _TD_MND_DEF_H_
2021-10-04 09:44:39 +00:00
#include "os.h"
2021-12-15 02:48:49 +00:00
#include "cJSON.h"
2022-01-24 02:46:55 +00:00
#include "scheduler.h"
2021-12-15 02:48:49 +00:00
#include "sync.h"
#include "thash.h"
2022-01-04 02:40:34 +00:00
#include "tlist.h"
2021-10-17 03:42:05 +00:00
#include "tlog.h"
2022-01-24 02:46:55 +00:00
#include "tmsg.h"
2021-10-17 03:42:05 +00:00
#include "trpc.h"
2022-03-25 13:03:12 +00:00
#include "tstream.h"
2021-10-17 03:42:05 +00:00
#include "ttimer.h"
2021-12-15 02:48:49 +00:00
2021-10-17 03:42:05 +00:00
#include "mnode.h"
2021-10-04 09:44:39 +00:00
2021-10-16 07:16:05 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2021-10-04 09:44:39 +00:00
typedef enum {
MND_OPER_CONNECT = 1,
MND_OPER_CREATE_ACCT,
MND_OPER_DROP_ACCT,
MND_OPER_ALTER_ACCT,
MND_OPER_CREATE_USER,
MND_OPER_DROP_USER,
MND_OPER_ALTER_USER,
MND_OPER_CREATE_DNODE,
MND_OPER_DROP_DNODE,
MND_OPER_CONFIG_DNODE,
MND_OPER_CREATE_MNODE,
MND_OPER_DROP_MNODE,
MND_OPER_CREATE_QNODE,
MND_OPER_DROP_QNODE,
MND_OPER_CREATE_SNODE,
MND_OPER_DROP_SNODE,
MND_OPER_REDISTRIBUTE_VGROUP,
MND_OPER_MERGE_VGROUP,
MND_OPER_SPLIT_VGROUP,
MND_OPER_BALANCE_VGROUP,
MND_OPER_CREATE_FUNC,
MND_OPER_DROP_FUNC,
MND_OPER_KILL_TRANS,
MND_OPER_KILL_CONN,
MND_OPER_KILL_QUERY,
MND_OPER_CREATE_DB,
MND_OPER_ALTER_DB,
MND_OPER_DROP_DB,
MND_OPER_COMPACT_DB,
MND_OPER_TRIM_DB,
MND_OPER_USE_DB,
MND_OPER_WRITE_DB,
MND_OPER_READ_DB,
MND_OPER_READ_OR_WRITE_DB,
MND_OPER_SHOW_VARIBALES,
2022-12-01 03:45:31 +00:00
MND_OPER_SUBSCRIBE,
2022-12-01 04:22:43 +00:00
MND_OPER_CREATE_TOPIC,
MND_OPER_DROP_TOPIC,
2023-10-24 03:29:04 +00:00
MND_OPER_CREATE_VIEW,
MND_OPER_DROP_VIEW,
2023-12-18 08:34:31 +00:00
MND_OPER_CONFIG_CLUSTER,
MND_OPER_BALANCE_VGROUP_LEADER,
} EOperType;
2021-10-17 03:42:05 +00:00
typedef enum {
2021-11-29 04:09:18 +00:00
MND_AUTH_ACCT_START = 0,
MND_AUTH_ACCT_USER,
MND_AUTH_ACCT_DNODE,
MND_AUTH_ACCT_MNODE,
MND_AUTH_ACCT_DB,
MND_AUTH_ACCT_TABLE,
MND_AUTH_ACCT_MAX
} EAuthAcct;
2021-10-17 03:42:05 +00:00
typedef enum {
2021-11-29 04:09:18 +00:00
MND_AUTH_OP_START = 0,
MND_AUTH_OP_CREATE_USER,
MND_AUTH_OP_ALTER_USER,
MND_AUTH_OP_DROP_USER,
MND_AUTH_MAX
} EAuthOp;
2021-10-17 03:42:05 +00:00
2022-05-30 01:47:16 +00:00
typedef enum {
TRN_CONFLICT_NOTHING = 0,
TRN_CONFLICT_GLOBAL = 1,
TRN_CONFLICT_DB = 2,
TRN_CONFLICT_DB_INSIDE = 3,
// TRN_CONFLICT_TOPIC = 4,
// TRN_CONFLICT_TOPIC_INSIDE = 5,
TRN_CONFLICT_ARBGROUP = 6,
} ETrnConflct;
2022-05-30 01:47:16 +00:00
2021-11-19 06:46:06 +00:00
typedef enum {
TRN_STAGE_PREPARE = 0,
TRN_STAGE_REDO_ACTION = 1,
TRN_STAGE_ROLLBACK = 2,
TRN_STAGE_UNDO_ACTION = 3,
TRN_STAGE_COMMIT = 4,
TRN_STAGE_COMMIT_ACTION = 5,
TRN_STAGE_FINISH = 6,
TRN_STAGE_PRE_FINISH = 7
2021-11-19 06:46:06 +00:00
} ETrnStage;
2022-05-07 01:36:36 +00:00
typedef enum {
TRN_POLICY_ROLLBACK = 0,
TRN_POLICY_RETRY = 1,
} ETrnPolicy;
2021-11-19 06:46:06 +00:00
typedef enum {
2023-05-05 10:57:15 +00:00
TRN_EXEC_PARALLEL = 0,
TRN_EXEC_SERIAL = 1,
} ETrnExec;
2021-11-30 07:28:51 +00:00
typedef enum {
DND_REASON_ONLINE = 0,
DND_REASON_STATUS_MSG_TIMEOUT,
DND_REASON_STATUS_NOT_RECEIVED,
DND_REASON_VERSION_NOT_MATCH,
DND_REASON_DNODE_ID_NOT_MATCH,
DND_REASON_CLUSTER_ID_NOT_MATCH,
DND_REASON_STATUS_INTERVAL_NOT_MATCH,
DND_REASON_TIME_ZONE_NOT_MATCH,
DND_REASON_LOCALE_NOT_MATCH,
DND_REASON_CHARSET_NOT_MATCH,
DND_REASON_TTL_CHANGE_ON_WRITE_NOT_MATCH,
2023-09-01 07:11:25 +00:00
DND_REASON_ENABLE_WHITELIST_NOT_MATCH,
2024-03-27 12:03:38 +00:00
DND_REASON_ENCRYPTION_KEY_NOT_MATCH,
DND_REASON_STATUS_MONITOR_NOT_MATCH,
2024-06-26 10:32:09 +00:00
DND_REASON_STATUS_MONITOR_SWITCH_NOT_MATCH,
DND_REASON_STATUS_MONITOR_INTERVAL_NOT_MATCH,
DND_REASON_STATUS_MONITOR_SLOW_LOG_THRESHOLD_NOT_MATCH,
DND_REASON_STATUS_MONITOR_SLOW_LOG_SQL_MAX_LEN_NOT_MATCH,
DND_REASON_STATUS_MONITOR_SLOW_LOG_SCOPE_NOT_MATCH,
2021-11-30 07:28:51 +00:00
DND_REASON_OTHERS
} EDndReason;
2022-05-07 01:36:36 +00:00
typedef enum {
CONSUMER_UPDATE_REB = 1, // update after rebalance
CONSUMER_ADD_REB, // add after rebalance
CONSUMER_REMOVE_REB, // remove after rebalance
CONSUMER_UPDATE_REC, // update after recover
CONSUMER_UPDATE_SUB, // update after subscribe req
2024-03-12 11:42:26 +00:00
CONSUMER_INSERT_SUB,
2022-05-07 01:36:36 +00:00
} ECsmUpdateType;
2021-12-15 10:13:39 +00:00
typedef struct {
2023-06-16 09:28:50 +00:00
int32_t id;
ETrnStage stage;
ETrnPolicy policy;
ETrnConflct conflict;
ETrnExec exec;
EOperType oper;
bool changeless;
2023-06-16 09:28:50 +00:00
int32_t code;
int32_t failedTimes;
void* rpcRsp;
int32_t rpcRspLen;
int32_t actionPos;
2023-06-16 09:28:50 +00:00
SArray* prepareActions;
SArray* redoActions;
SArray* undoActions;
SArray* commitActions;
int64_t createdTime;
int64_t lastExecTime;
int32_t lastAction;
int32_t lastErrorNo;
SEpSet lastEpset;
tmsg_t lastMsgType;
tmsg_t originRpcType;
char dbname[TSDB_TABLE_FNAME_LEN];
char stbname[TSDB_TABLE_FNAME_LEN];
2024-05-21 09:10:57 +00:00
SHashObj* arbGroupIds;
2023-06-16 09:28:50 +00:00
int32_t startFunc;
int32_t stopFunc;
int32_t paramLen;
void* param;
char opername[TSDB_TRANS_OPER_LEN];
SArray* pRpcArray;
SRWLatch lockRpcArray;
int64_t mTraceId;
TdThreadMutex mutex;
2021-11-19 06:46:06 +00:00
} STrans;
2021-10-17 03:42:05 +00:00
2021-12-15 10:13:39 +00:00
typedef struct {
2021-12-27 02:57:31 +00:00
int64_t id;
2021-12-06 10:21:14 +00:00
char name[TSDB_CLUSTER_ID_LEN];
2021-10-17 03:42:05 +00:00
int64_t createdTime;
int64_t updateTime;
2022-08-23 09:29:31 +00:00
int32_t upTime;
2021-10-17 03:42:05 +00:00
} SClusterObj;
2021-12-15 02:48:49 +00:00
typedef struct {
2021-11-30 07:28:51 +00:00
int32_t id;
int64_t createdTime;
int64_t updateTime;
int64_t rebootTime;
2021-12-12 04:14:26 +00:00
int64_t lastAccessTime;
2021-11-30 11:42:51 +00:00
int32_t accessTimes;
2021-12-30 07:09:07 +00:00
int32_t numOfVnodes;
int32_t numOfOtherNodes;
2021-12-30 03:35:46 +00:00
int32_t numOfSupportVnodes;
2024-01-24 11:08:19 +00:00
int32_t numOfDiskCfg;
2022-07-04 10:30:10 +00:00
float numOfCores;
int64_t memTotal;
int64_t memAvail;
int64_t memUsed;
2021-11-30 07:28:51 +00:00
EDndReason offlineReason;
2024-03-28 08:17:35 +00:00
uint32_t encryptionKeyChksum;
2024-03-27 12:03:38 +00:00
int8_t encryptionKeyStat;
2021-11-30 07:28:51 +00:00
uint16_t port;
char fqdn[TSDB_FQDN_LEN];
char ep[TSDB_EP_LEN];
2023-12-06 11:13:54 +00:00
char machineId[TSDB_MACHINE_ID_LEN + 1];
2021-10-17 03:42:05 +00:00
} SDnodeObj;
2021-12-15 10:13:39 +00:00
typedef struct {
2021-10-17 03:42:05 +00:00
int32_t id;
2021-11-30 07:28:51 +00:00
int64_t createdTime;
int64_t updateTime;
ESyncState syncState;
SyncTerm syncTerm;
bool syncRestore;
int64_t roleTimeMs;
2022-01-24 02:46:55 +00:00
SDnodeObj* pDnode;
2023-04-18 11:03:45 +00:00
int32_t role;
SyncIndex lastIndex;
2021-10-17 03:42:05 +00:00
} SMnodeObj;
2021-12-29 12:05:10 +00:00
typedef struct {
int32_t id;
int64_t createdTime;
int64_t updateTime;
2022-01-24 02:46:55 +00:00
SDnodeObj* pDnode;
2022-06-02 02:18:11 +00:00
SQnodeLoad load;
2021-12-29 12:05:10 +00:00
} SQnodeObj;
typedef struct {
int32_t id;
int64_t createdTime;
int64_t updateTime;
2022-01-24 02:46:55 +00:00
SDnodeObj* pDnode;
2021-12-29 12:05:10 +00:00
} SSnodeObj;
typedef struct {
int32_t dnodeId;
char token[TSDB_ARB_TOKEN_SIZE];
int8_t acked;
} SArbAssignedLeader;
typedef struct {
int32_t dnodeId;
} SArbMemberInfo;
typedef struct {
int32_t nextHbSeq;
int32_t responsedHbSeq;
char token[TSDB_ARB_TOKEN_SIZE];
int64_t lastHbMs;
} SArbMemberState;
typedef struct {
SArbMemberInfo info;
SArbMemberState state;
} SArbGroupMember;
typedef struct {
int32_t vgId;
int64_t dbUid;
2024-03-18 03:26:54 +00:00
SArbGroupMember members[TSDB_ARB_GROUP_MEMBER_NUM];
int8_t isSync;
SArbAssignedLeader assignedLeader;
2024-03-18 03:26:54 +00:00
int64_t version;
// following fields will not be duplicated
bool mutexInited;
TdThreadMutex mutex;
} SArbGroup;
2021-10-17 03:42:05 +00:00
typedef struct {
int32_t maxUsers;
int32_t maxDbs;
2021-12-31 06:32:59 +00:00
int32_t maxStbs;
int32_t maxTbs;
2021-10-17 03:42:05 +00:00
int32_t maxTimeSeries;
int32_t maxStreams;
2021-12-31 06:32:59 +00:00
int32_t maxFuncs;
int32_t maxConsumers;
int32_t maxConns;
int32_t maxTopics;
int64_t maxStorage;
2021-11-09 03:37:58 +00:00
int32_t accessState; // Configured only by command
2021-10-17 03:42:05 +00:00
} SAcctCfg;
typedef struct {
int32_t numOfUsers;
int32_t numOfDbs;
int32_t numOfTimeSeries;
int32_t numOfStreams;
2021-10-17 14:26:38 +00:00
int64_t totalStorage; // Total storage wrtten from this account
int64_t compStorage; // Compressed storage on disk
2021-10-17 03:42:05 +00:00
} SAcctInfo;
2021-12-15 10:13:39 +00:00
typedef struct {
2021-10-17 03:42:05 +00:00
char acct[TSDB_USER_LEN];
int64_t createdTime;
int64_t updateTime;
int32_t acctId;
2021-11-09 03:37:58 +00:00
int32_t status;
2021-10-17 03:42:05 +00:00
SAcctCfg cfg;
SAcctInfo info;
} SAcctObj;
2021-12-15 02:48:49 +00:00
typedef struct {
2024-05-22 11:00:47 +00:00
char user[TSDB_USER_LEN];
char pass[TSDB_PASSWORD_LEN];
char acct[TSDB_USER_LEN];
int64_t createdTime;
int64_t updateTime;
int8_t superUser;
int8_t sysInfo;
int8_t enable;
union {
uint8_t flag;
2024-05-22 11:00:47 +00:00
struct {
uint8_t createdb : 1;
uint8_t reserve : 7;
2024-05-22 11:00:47 +00:00
};
};
2023-09-04 13:15:46 +00:00
int32_t acctId;
int32_t authVersion;
int32_t passVersion;
2023-09-12 03:31:06 +00:00
int64_t ipWhiteListVer;
2023-09-04 13:15:46 +00:00
SIpWhiteList* pIpWhiteList;
2022-02-10 14:49:53 +00:00
SHashObj* readDbs;
SHashObj* writeDbs;
2022-12-01 03:45:31 +00:00
SHashObj* topics;
2023-03-30 05:59:48 +00:00
SHashObj* readTbs;
SHashObj* writeTbs;
2023-10-19 00:31:31 +00:00
SHashObj* alterTbs;
SHashObj* readViews;
SHashObj* writeViews;
SHashObj* alterViews;
2023-04-11 02:11:25 +00:00
SHashObj* useDbs;
2022-05-05 13:52:18 +00:00
SRWLatch lock;
2021-10-17 03:42:05 +00:00
} SUserObj;
typedef struct {
int32_t numOfVgroups;
2022-04-25 13:12:03 +00:00
int32_t numOfStables;
int32_t buffer;
int32_t pageSize;
int32_t pages;
int32_t cacheLastSize;
2022-04-28 07:30:23 +00:00
int32_t daysPerFile;
int32_t daysToKeep0;
int32_t daysToKeep1;
int32_t daysToKeep2;
int32_t keepTimeOffset;
2021-12-16 05:35:51 +00:00
int32_t minRows;
int32_t maxRows;
int32_t walFsyncPeriod;
2021-12-09 05:07:00 +00:00
int8_t walLevel;
2021-10-17 03:42:05 +00:00
int8_t precision;
int8_t compression;
int8_t replications;
2022-04-20 01:47:38 +00:00
int8_t strict;
int8_t hashMethod; // default is 1
int8_t cacheLast;
2022-07-26 05:26:52 +00:00
int8_t schemaless;
int16_t hashPrefix;
int16_t hashSuffix;
int16_t sstTrigger;
2022-09-13 09:49:35 +00:00
int32_t tsdbPageSize;
2022-03-24 06:54:10 +00:00
int32_t numOfRetensions;
SArray* pRetensions;
2022-07-26 05:26:52 +00:00
int32_t walRetentionPeriod;
int32_t walRollPeriod;
int64_t walRetentionSize;
2022-07-26 08:03:00 +00:00
int64_t walSegmentSize;
int32_t s3ChunkSize;
int32_t s3KeepLocal;
int8_t s3Compact;
int8_t withArbitrator;
2024-03-27 12:03:38 +00:00
int8_t encryptAlgorithm;
2021-10-17 03:42:05 +00:00
} SDbCfg;
2021-12-15 05:22:04 +00:00
typedef struct {
char name[TSDB_DB_FNAME_LEN];
char acct[TSDB_USER_LEN];
char createUser[TSDB_USER_LEN];
int64_t createdTime;
int64_t updateTime;
int64_t uid;
int32_t cfgVersion;
int32_t vgVersion;
SDbCfg cfg;
SRWLatch lock;
int64_t stateTs;
int64_t compactStartTime;
int32_t tsmaVersion;
2021-10-17 03:42:05 +00:00
} SDbObj;
typedef struct {
int32_t dnodeId;
ESyncState syncState;
int64_t syncTerm;
bool syncRestore;
bool syncCanRead;
int64_t roleTimeMs;
int64_t startTimeMs;
2023-04-18 11:03:45 +00:00
ESyncRole nodeRole;
2023-07-18 08:09:38 +00:00
int32_t learnerProgress;
2021-10-17 03:42:05 +00:00
} SVnodeGid;
2021-12-15 10:13:39 +00:00
typedef struct {
2021-12-09 08:47:23 +00:00
int32_t vgId;
2021-10-17 03:42:05 +00:00
int64_t createdTime;
int64_t updateTime;
2021-12-09 08:47:23 +00:00
int32_t version;
2021-12-16 10:04:07 +00:00
uint32_t hashBegin;
uint32_t hashEnd;
2021-12-28 08:06:01 +00:00
char dbName[TSDB_DB_FNAME_LEN];
2021-12-16 09:05:13 +00:00
int64_t dbUid;
int64_t cacheUsage;
2022-02-10 08:26:56 +00:00
int64_t numOfTables;
int64_t numOfTimeSeries;
2021-10-17 03:42:05 +00:00
int64_t totalStorage;
int64_t compStorage;
int64_t pointsWritten;
2021-12-09 08:47:23 +00:00
int8_t compact;
2022-05-26 05:18:39 +00:00
int8_t isTsma;
2021-12-09 08:47:23 +00:00
int8_t replica;
2023-04-18 11:03:45 +00:00
SVnodeGid vnodeGid[TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA];
2022-05-31 13:07:52 +00:00
void* pTsma;
2023-03-22 08:08:16 +00:00
int32_t numOfCachedTables;
2023-07-18 08:09:38 +00:00
int32_t syncConfChangeVer;
2021-10-17 03:42:05 +00:00
} SVgObj;
2021-12-10 07:20:04 +00:00
typedef struct {
2022-06-07 12:49:27 +00:00
char name[TSDB_TABLE_FNAME_LEN];
char stb[TSDB_TABLE_FNAME_LEN];
char db[TSDB_DB_FNAME_LEN];
char dstTbName[TSDB_TABLE_FNAME_LEN];
int64_t createdTime;
int64_t uid;
int64_t stbUid;
int64_t dbUid;
int64_t dstTbUid;
int8_t intervalUnit;
int8_t slidingUnit;
int8_t timezone;
int32_t dstVgId; // for stream
int64_t interval;
int64_t offset;
int64_t sliding;
int32_t exprLen; // strlen + 1
int32_t tagsFilterLen;
int32_t sqlLen;
int32_t astLen;
2023-11-29 11:07:23 +00:00
int32_t version;
2022-06-07 12:49:27 +00:00
char* expr;
char* tagsFilter;
char* sql;
char* ast;
SSchemaWrapper schemaRow; // for dstVgroup
SSchemaWrapper schemaTag; // for dstVgroup
2024-02-22 10:24:35 +00:00
char baseSmaName[TSDB_TABLE_FNAME_LEN];
2022-03-23 05:50:53 +00:00
} SSmaObj;
2023-02-03 14:19:01 +00:00
typedef struct {
2023-03-17 02:26:18 +00:00
char name[TSDB_INDEX_FNAME_LEN];
2023-02-03 14:19:01 +00:00
char stb[TSDB_TABLE_FNAME_LEN];
char db[TSDB_DB_FNAME_LEN];
char dstTbName[TSDB_TABLE_FNAME_LEN];
char colName[TSDB_COL_NAME_LEN];
int64_t createdTime;
int64_t uid;
int64_t stbUid;
int64_t dbUid;
} SIdxObj;
2021-12-10 07:20:04 +00:00
typedef struct {
2024-03-01 06:19:37 +00:00
col_id_t colId;
2024-03-25 13:48:24 +00:00
int32_t cmprAlg;
2024-03-01 06:19:37 +00:00
} SCmprObj;
typedef struct {
char name[TSDB_TABLE_FNAME_LEN];
char db[TSDB_DB_FNAME_LEN];
int64_t createdTime;
int64_t updateTime;
int64_t uid;
int64_t dbUid;
int32_t tagVer;
int32_t colVer;
int32_t smaVer;
int32_t nextColId;
int64_t maxdelay[2];
int64_t watermark[2];
int32_t ttl;
int32_t numOfColumns;
int32_t numOfTags;
int32_t numOfFuncs;
int32_t commentLen;
int32_t ast1Len;
int32_t ast2Len;
SArray* pFuncs;
SSchema* pColumns;
SSchema* pTags;
char* comment;
char* pAst1;
char* pAst2;
SRWLatch lock;
int8_t source;
2024-03-25 13:48:24 +00:00
SColCmpr* pCmpr;
2021-12-10 07:20:04 +00:00
} SStbObj;
2021-10-17 03:42:05 +00:00
2021-12-15 10:13:39 +00:00
typedef struct {
2023-06-16 09:28:50 +00:00
char name[TSDB_FUNC_NAME_LEN];
int64_t createdTime;
int8_t funcType;
int8_t scriptType;
int8_t align;
int8_t outputType;
int32_t outputLen;
int32_t bufSize;
int64_t signature;
int32_t commentSize;
int32_t codeSize;
char* pComment;
char* pCode;
int32_t funcVersion;
2023-04-10 08:40:16 +00:00
SRWLatch lock;
2021-10-17 03:42:05 +00:00
} SFuncObj;
2021-12-08 10:50:52 +00:00
typedef struct {
2022-04-14 12:34:42 +00:00
int64_t id;
int8_t type;
int8_t replica;
int16_t numOfColumns;
int32_t numOfRows;
2023-06-26 10:43:00 +00:00
int32_t curIterPackedRows;
2022-04-14 12:34:42 +00:00
void* pIter;
SMnode* pMnode;
STableMetaRsp* pMeta;
2023-03-22 08:08:16 +00:00
bool restore;
2022-04-14 12:34:42 +00:00
bool sysDbRsp;
char db[TSDB_DB_FNAME_LEN];
2023-01-11 15:55:53 +00:00
char filterTb[TSDB_TABLE_NAME_LEN];
2021-10-17 03:42:05 +00:00
} SShowObj;
2022-02-10 03:22:50 +00:00
typedef struct {
2022-06-02 03:01:05 +00:00
char name[TSDB_TOPIC_FNAME_LEN];
char db[TSDB_DB_FNAME_LEN];
2022-12-06 04:02:32 +00:00
char createUser[TSDB_USER_LEN];
2022-06-02 03:01:05 +00:00
int64_t createTime;
int64_t updateTime;
int64_t uid;
int64_t dbUid;
int32_t version;
2022-06-21 05:50:33 +00:00
int8_t subType; // column, db or stable
int8_t withMeta; // TODO
2022-03-26 12:12:45 +00:00
SRWLatch lock;
int32_t sqlLen;
2022-04-14 12:34:42 +00:00
int32_t astLen;
2022-03-26 12:12:45 +00:00
char* sql;
2022-04-14 12:34:42 +00:00
char* ast;
2022-03-26 12:12:45 +00:00
char* physicalPlan;
SSchemaWrapper schema;
2022-06-02 02:18:11 +00:00
int64_t stbUid;
char stbName[TSDB_TABLE_FNAME_LEN];
2022-07-22 08:05:28 +00:00
// forbid condition
int64_t ntbUid;
SArray* ntbColIds;
2022-07-22 09:10:40 +00:00
int64_t ctbStbUid;
2022-01-06 02:28:34 +00:00
} SMqTopicObj;
2022-02-10 03:22:50 +00:00
typedef struct {
2022-05-07 01:36:36 +00:00
int64_t consumerId;
char cgroup[TSDB_CGROUP_LEN];
char clientId[TSDB_CLIENT_ID_LEN];
2022-05-07 01:36:36 +00:00
int8_t updateType; // used only for update
int32_t epoch;
int32_t status;
int32_t hbStatus; // hbStatus is not applicable to serialization
int32_t pollStatus; // pollStatus is not applicable to serialization
2022-05-07 01:36:36 +00:00
SRWLatch lock; // lock is used for topics update
2022-04-21 08:37:55 +00:00
SArray* currentTopics; // SArray<char*>
SArray* rebNewTopics; // SArray<char*>
SArray* rebRemovedTopics; // SArray<char*>
2022-04-27 07:16:57 +00:00
2022-04-27 09:15:02 +00:00
// subscribed by user
SArray* assignedTopics; // SArray<char*>
2022-04-27 07:16:57 +00:00
// data for display
int32_t pid;
SEpSet ep;
2023-06-15 07:44:52 +00:00
int64_t createTime;
2022-04-27 07:16:57 +00:00
int64_t subscribeTime;
int64_t rebalanceTime;
2023-06-16 09:28:50 +00:00
int8_t withTbName;
int8_t autoCommit;
int32_t autoCommitInterval;
int32_t resetOffsetCfg;
int32_t sessionTimeoutMs;
int32_t maxPollIntervalMs;
2022-01-06 02:28:34 +00:00
} SMqConsumerObj;
int32_t tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType,
char *topic, SCMSubscribeReq *subscribe, SMqConsumerObj** ppConsumer);
2024-03-12 11:42:26 +00:00
void tClearSMqConsumerObj(SMqConsumerObj* pConsumer);
void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer);
int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer);
void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer, int8_t sver);
2022-01-19 08:28:13 +00:00
typedef struct {
int32_t vgId;
2023-06-16 09:28:50 +00:00
// char* qmsg; // SubPlanToString
SEpSet epSet;
} SMqVgEp;
2023-06-13 09:10:23 +00:00
SMqVgEp* tCloneSMqVgEp(const SMqVgEp* pVgEp);
void tDeleteSMqVgEp(SMqVgEp* pVgEp);
int32_t tEncodeSMqVgEp(void** buf, const SMqVgEp* pVgEp);
void* tDecodeSMqVgEp(const void* buf, SMqVgEp* pVgEp, int8_t sver);
typedef struct {
int64_t consumerId; // -1 for unassigned
SArray* vgs; // SArray<SMqVgEp*>
SArray* offsetRows; // SArray<OffsetRows*>
} SMqConsumerEp;
2023-06-16 09:28:50 +00:00
// SMqConsumerEp* tCloneSMqConsumerEp(const SMqConsumerEp* pEp);
// void tDeleteSMqConsumerEp(void* pEp);
int32_t tEncodeSMqConsumerEp(void** buf, const SMqConsumerEp* pEp);
void* tDecodeSMqConsumerEp(const void* buf, SMqConsumerEp* pEp, int8_t sver);
typedef struct {
2022-06-02 03:01:05 +00:00
char key[TSDB_SUBSCRIBE_KEY_LEN];
SRWLatch lock;
int64_t dbUid;
int32_t vgNum;
int8_t subType;
2022-06-21 05:50:33 +00:00
int8_t withMeta;
2022-06-02 03:01:05 +00:00
int64_t stbUid;
SHashObj* consumerHash; // consumerId -> SMqConsumerEp
SArray* unassignedVgs; // SArray<SMqVgEp*>
SArray* offsetRows;
2022-06-10 07:20:57 +00:00
char dbName[TSDB_DB_FNAME_LEN];
2023-06-16 09:28:50 +00:00
char* qmsg; // SubPlanToString
} SMqSubscribeObj;
int32_t tNewSubscribeObj(const char *key, SMqSubscribeObj **ppSub);
int32_t tCloneSubscribeObj(const SMqSubscribeObj* pSub, SMqSubscribeObj **ppSub);
void tDeleteSubscribeObj(SMqSubscribeObj* pSub);
int32_t tEncodeSubscribeObj(void** buf, const SMqSubscribeObj* pSub);
void* tDecodeSubscribeObj(const void* buf, SMqSubscribeObj* pSub, int8_t sver);
2023-08-31 01:28:43 +00:00
// typedef struct {
// int32_t epoch;
// SArray* consumers; // SArray<SMqConsumerEp*>
// } SMqSubActionLogEntry;
// SMqSubActionLogEntry* tCloneSMqSubActionLogEntry(SMqSubActionLogEntry* pEntry);
// void tDeleteSMqSubActionLogEntry(SMqSubActionLogEntry* pEntry);
// int32_t tEncodeSMqSubActionLogEntry(void** buf, const SMqSubActionLogEntry* pEntry);
// void* tDecodeSMqSubActionLogEntry(const void* buf, SMqSubActionLogEntry* pEntry);
2023-06-26 10:43:00 +00:00
//
2023-08-31 01:28:43 +00:00
// typedef struct {
// char key[TSDB_SUBSCRIBE_KEY_LEN];
// SArray* logs; // SArray<SMqSubActionLogEntry*>
// } SMqSubActionLogObj;
2023-06-26 10:43:00 +00:00
//
2023-08-31 01:28:43 +00:00
// SMqSubActionLogObj* tCloneSMqSubActionLogObj(SMqSubActionLogObj* pLog);
// void tDeleteSMqSubActionLogObj(SMqSubActionLogObj* pLog);
// int32_t tEncodeSMqSubActionLogObj(void** buf, const SMqSubActionLogObj* pLog);
// void* tDecodeSMqSubActionLogObj(const void* buf, SMqSubActionLogObj* pLog);
typedef struct {
2022-04-29 13:01:13 +00:00
int32_t oldConsumerNum;
const SMqRebInfo* pRebInfo;
} SMqRebInputObj;
typedef struct {
int64_t oldConsumerId;
int64_t newConsumerId;
SMqVgEp* pVgEp;
} SMqRebOutputVg;
typedef struct {
2023-08-31 01:28:43 +00:00
SArray* rebVgs; // SArray<SMqRebOutputVg>
SArray* newConsumers; // SArray<int64_t>
SArray* removedConsumers; // SArray<int64_t>
SArray* modifyConsumers; // SArray<int64_t>
SMqSubscribeObj* pSub;
// SMqSubActionLogEntry* pLogEntry;
} SMqRebOutputObj;
2022-01-19 08:28:13 +00:00
2023-05-30 01:41:19 +00:00
typedef struct SStreamConf {
int8_t igExpired;
int8_t trigger;
int8_t fillHistory;
int64_t triggerParam;
int64_t watermark;
} SStreamConf;
2022-03-07 08:30:28 +00:00
typedef struct {
char name[TSDB_STREAM_FNAME_LEN];
2022-06-16 08:01:22 +00:00
SRWLatch lock;
2022-06-16 08:01:22 +00:00
// create info
int64_t createTime;
int64_t updateTime;
int32_t version;
2022-08-08 03:09:39 +00:00
int32_t totalLevel;
2022-06-16 08:01:22 +00:00
int64_t smaId; // 0 for unused
// info
2023-08-31 01:28:43 +00:00
int64_t uid;
int8_t status;
2023-05-30 01:41:19 +00:00
SStreamConf conf;
2022-06-16 08:01:22 +00:00
// source and target
int64_t sourceDbUid;
int64_t targetDbUid;
char sourceDb[TSDB_DB_FNAME_LEN];
char targetDb[TSDB_DB_FNAME_LEN];
char targetSTbName[TSDB_TABLE_FNAME_LEN];
int64_t targetStbUid;
2023-05-29 09:50:39 +00:00
2022-06-16 08:22:58 +00:00
// fixedSinkVg is not applicable for encode and decode
2023-06-16 09:28:50 +00:00
SVgObj fixedSinkVg;
2023-05-29 09:50:39 +00:00
int32_t fixedSinkVgId; // 0 for shuffle
2022-06-16 08:22:58 +00:00
2022-06-16 08:01:22 +00:00
// transformation
2023-08-31 01:28:43 +00:00
char* sql;
char* ast;
char* physicalPlan;
SArray* tasks; // SArray<SArray<SStreamTask>>
2023-05-30 01:41:19 +00:00
2023-08-31 01:28:43 +00:00
SArray* pHTasksList; // generate the results for already stored ts data
int64_t hTaskUid; // stream task for history ts data
2023-05-30 01:41:19 +00:00
2022-03-26 08:48:14 +00:00
SSchemaWrapper outputSchema;
SSchemaWrapper tagSchema;
// 3.0.20
int64_t checkpointFreq; // ms
int64_t currentTick; // do not serialize
2022-12-06 08:07:11 +00:00
int64_t deleteMark;
int8_t igCheckUpdate;
2023-06-16 09:28:50 +00:00
// 3.0.5.
int64_t checkpointId;
int32_t indexForMultiAggBalance;
int8_t subTableWithoutMd5;
2023-08-31 01:28:43 +00:00
char reserve[256];
2022-03-10 09:15:45 +00:00
} SStreamObj;
2023-11-08 11:54:57 +00:00
typedef struct SStreamSeq {
char name[24];
uint64_t seq;
SRWLatch lock;
} SStreamSeq;
2022-05-07 10:03:06 +00:00
int32_t tEncodeSStreamObj(SEncoder* pEncoder, const SStreamObj* pObj);
2022-12-01 23:57:22 +00:00
int32_t tDecodeSStreamObj(SDecoder* pDecoder, SStreamObj* pObj, int32_t sver);
2022-08-18 06:26:11 +00:00
void tFreeStreamObj(SStreamObj* pObj);
2022-03-07 08:30:28 +00:00
2023-10-09 09:19:36 +00:00
#define VIEW_TYPE_UPDATABLE (1 << 0)
#define VIEW_TYPE_MATERIALIZED (1 << 1)
2023-09-19 06:19:54 +00:00
2023-09-28 03:44:38 +00:00
typedef struct {
char fullname[TSDB_VIEW_FNAME_LEN];
char name[TSDB_VIEW_NAME_LEN];
char dbFName[TSDB_DB_FNAME_LEN];
2023-10-19 00:31:31 +00:00
char user[TSDB_USER_LEN];
2023-09-28 03:44:38 +00:00
char* querySql;
2023-10-09 09:19:36 +00:00
char* parameters;
void** defaultValues;
char* targetTable;
2023-09-28 03:44:38 +00:00
uint64_t viewId;
uint64_t dbId;
2023-10-09 09:19:36 +00:00
int64_t createdTime;
2023-09-28 03:44:38 +00:00
int32_t version;
int8_t precision;
2023-10-09 09:19:36 +00:00
int8_t type;
2023-09-28 03:44:38 +00:00
int32_t numOfCols;
SSchema* pSchema;
2023-11-08 11:54:57 +00:00
SRWLatch lock;
2023-09-28 03:44:38 +00:00
} SViewObj;
2023-09-19 06:19:54 +00:00
int32_t tEncodeSViewObj(SEncoder* pEncoder, const SViewObj* pObj);
int32_t tDecodeSViewObj(SDecoder* pDecoder, SViewObj* pObj, int32_t sver);
void tFreeSViewObj(SViewObj* pObj);
2023-11-23 04:43:28 +00:00
typedef struct {
int32_t compactDetailId;
int32_t compactId;
int32_t vgId;
int32_t dnodeId;
int32_t numberFileset;
int32_t finished;
int64_t startTime;
2023-11-23 07:36:33 +00:00
int32_t newNumberFileset;
int32_t newFinished;
} SCompactDetailObj;
2023-11-23 04:43:28 +00:00
typedef struct {
int32_t compactId;
char dbname[TSDB_TABLE_FNAME_LEN];
int64_t startTime;
SArray* compactDetail;
} SCompactObj;
2023-09-19 06:19:54 +00:00
2024-01-31 01:47:10 +00:00
// SGrantLogObj
2024-01-18 07:23:38 +00:00
typedef enum {
2024-01-22 05:20:15 +00:00
GRANT_STATE_INIT = 0,
2024-01-18 11:40:41 +00:00
GRANT_STATE_UNGRANTED = 1,
GRANT_STATE_GRANTED = 2,
GRANT_STATE_EXPIRED = 3,
GRANT_STATE_REVOKED = 4,
2024-01-26 11:06:56 +00:00
GRANT_STATE_MAX,
2024-01-18 07:23:38 +00:00
} EGrantState;
typedef enum {
2024-01-22 05:20:15 +00:00
GRANT_STATE_REASON_INIT = 0,
2024-01-18 11:40:41 +00:00
GRANT_STATE_REASON_ALTER = 1, // alter activeCode 'revoked' or 'xxx'
GRANT_STATE_REASON_MISMATCH = 2, // dnode machine mismatch
GRANT_STATE_REASON_EXPIRE = 3, // expire
2024-01-26 11:06:56 +00:00
GRANT_STATE_REASON_MAX,
2024-01-18 07:23:38 +00:00
} EGrantStateReason;
#define GRANT_STATE_NUM 30
#define GRANT_ACTIVE_NUM 10
2024-01-18 11:40:41 +00:00
#define GRANT_ACTIVE_HEAD_LEN 30
2024-01-18 07:23:38 +00:00
typedef struct {
union {
int64_t u0;
struct {
2024-01-18 11:40:41 +00:00
int64_t ts : 40;
int64_t lastState : 4;
int64_t state : 4;
2024-01-18 07:23:38 +00:00
int64_t reason : 8;
2024-01-18 11:40:41 +00:00
int64_t reserve : 8;
2024-01-18 07:23:38 +00:00
};
};
} SGrantState;
typedef struct {
union {
int64_t u0;
struct {
2024-01-18 11:40:41 +00:00
int64_t ts : 40;
int64_t reserve : 24;
2024-01-18 07:23:38 +00:00
};
};
2024-01-18 11:40:41 +00:00
char active[GRANT_ACTIVE_HEAD_LEN + 1];
2024-01-18 07:23:38 +00:00
} SGrantActive;
typedef struct {
union {
int64_t u0;
struct {
2024-01-18 11:40:41 +00:00
int64_t ts : 40;
2024-01-18 07:23:38 +00:00
int64_t id : 24;
};
};
char machine[TSDB_MACHINE_ID_LEN + 1];
2024-01-18 07:23:38 +00:00
} SGrantMachine;
typedef struct {
int32_t id;
2024-01-19 06:59:02 +00:00
int8_t nStates;
int8_t nActives;
2024-01-18 07:23:38 +00:00
int64_t createTime;
int64_t updateTime;
2024-01-31 02:02:44 +00:00
int64_t upgradeTime;
2024-01-19 09:01:19 +00:00
SGrantState states[GRANT_STATE_NUM];
2024-01-19 06:59:02 +00:00
SGrantActive actives[GRANT_ACTIVE_NUM];
char* active;
2024-01-30 16:40:47 +00:00
SArray* pMachines; // SGrantMachine
2024-01-18 07:23:38 +00:00
SRWLatch lock;
2024-01-31 01:47:10 +00:00
} SGrantLogObj;
2024-01-18 07:23:38 +00:00
2021-10-16 07:16:05 +00:00
#ifdef __cplusplus
}
#endif
2021-10-04 09:44:39 +00:00
2021-11-27 15:02:20 +00:00
#endif /*_TD_MND_DEF_H_*/