2021-09-22 05:21:07 +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-09-22 12:29:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _TD_VNODE_H_
|
|
|
|
|
#define _TD_VNODE_H_
|
|
|
|
|
|
2021-11-09 05:24:22 +00:00
|
|
|
#include "os.h"
|
2026-02-26 09:06:07 +00:00
|
|
|
#include "thash.h"
|
2022-03-21 11:08:25 +00:00
|
|
|
#include "tmsgcb.h"
|
2022-03-29 10:58:15 +00:00
|
|
|
#include "tqueue.h"
|
|
|
|
|
#include "trpc.h"
|
2021-11-09 05:24:22 +00:00
|
|
|
|
2022-04-19 09:07:42 +00:00
|
|
|
#include "sync.h"
|
2021-11-11 03:41:16 +00:00
|
|
|
#include "tarray.h"
|
2022-01-19 06:04:01 +00:00
|
|
|
#include "tfs.h"
|
2021-11-24 08:29:02 +00:00
|
|
|
#include "wal.h"
|
2021-11-01 11:49:44 +00:00
|
|
|
|
2023-05-23 03:46:02 +00:00
|
|
|
#include "filter.h"
|
2022-04-14 02:01:04 +00:00
|
|
|
#include "tcommon.h"
|
|
|
|
|
#include "tfs.h"
|
2022-07-23 07:32:18 +00:00
|
|
|
#include "tgrant.h"
|
2022-04-08 06:09:15 +00:00
|
|
|
#include "tmsg.h"
|
|
|
|
|
#include "trow.h"
|
|
|
|
|
|
2023-05-23 10:29:23 +00:00
|
|
|
#include "storageapi.h"
|
2023-08-18 08:38:26 +00:00
|
|
|
#include "tdb.h"
|
2022-04-24 06:19:12 +00:00
|
|
|
|
2025-06-30 02:33:34 +00:00
|
|
|
#include "libs/metrics/metrics.h"
|
|
|
|
|
|
2021-09-22 12:29:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
2022-05-01 16:30:47 +00:00
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
// vnode
|
2025-06-30 02:33:34 +00:00
|
|
|
typedef struct SVnode SVnode;
|
|
|
|
|
typedef struct STsdbCfg STsdbCfg; // todo: remove
|
|
|
|
|
typedef struct SVnodeCfg SVnodeCfg;
|
|
|
|
|
typedef struct SVSnapReader SVSnapReader;
|
|
|
|
|
typedef struct SVSnapWriter SVSnapWriter;
|
|
|
|
|
typedef struct SVnodeWriteMetrics SVnodeWriteMetrics;
|
2022-04-14 02:10:56 +00:00
|
|
|
|
2022-04-19 01:57:46 +00:00
|
|
|
extern const SVnodeCfg vnodeCfgDefault;
|
|
|
|
|
|
2024-08-15 03:55:20 +00:00
|
|
|
typedef void (*StopDnodeFp)();
|
|
|
|
|
|
2024-12-19 06:51:21 +00:00
|
|
|
int32_t vnodeInit(StopDnodeFp stopDnodeFp);
|
2022-04-14 02:01:04 +00:00
|
|
|
void vnodeCleanup();
|
2023-07-14 10:24:53 +00:00
|
|
|
int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs *pTfs);
|
2024-06-12 07:16:58 +00:00
|
|
|
bool vnodeShouldRemoveWal(SVnode *pVnode);
|
2023-07-14 10:24:53 +00:00
|
|
|
int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, int32_t diskPrimary, STfs *pTfs);
|
|
|
|
|
int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnodeHashRangeReq *pReq,
|
|
|
|
|
int32_t diskPrimary, STfs *pTfs);
|
|
|
|
|
int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t srcVgId, int32_t dstVgId,
|
|
|
|
|
int32_t diskPrimary, STfs *pTfs);
|
2024-04-08 02:31:49 +00:00
|
|
|
void vnodeDestroy(int32_t vgId, const char *path, STfs *pTfs, int32_t nodeId);
|
2025-07-12 07:39:29 +00:00
|
|
|
SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, STfs *pMountTfs, SMsgCb msgCb, bool force);
|
2022-07-12 06:46:52 +00:00
|
|
|
void vnodePreClose(SVnode *pVnode);
|
2023-01-05 03:35:39 +00:00
|
|
|
void vnodePostClose(SVnode *pVnode);
|
|
|
|
|
void vnodeSyncCheckTimeout(SVnode *pVnode);
|
2022-04-14 02:01:04 +00:00
|
|
|
void vnodeClose(SVnode *pVnode);
|
2023-01-31 02:35:27 +00:00
|
|
|
int32_t vnodeSyncCommit(SVnode *pVnode);
|
2023-02-13 03:40:40 +00:00
|
|
|
int32_t vnodeBegin(SVnode *pVnode);
|
2022-07-06 07:15:55 +00:00
|
|
|
|
2023-08-18 08:38:26 +00:00
|
|
|
int32_t vnodeStart(SVnode *pVnode);
|
|
|
|
|
void vnodeStop(SVnode *pVnode);
|
|
|
|
|
int64_t vnodeGetSyncHandle(SVnode *pVnode);
|
2024-04-08 02:31:49 +00:00
|
|
|
int32_t vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot);
|
2025-11-13 01:28:26 +00:00
|
|
|
int32_t vnodeSetWalKeepVersion(SVnode *pVnode, int64_t keepVersion);
|
2023-08-18 08:38:26 +00:00
|
|
|
void vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId, int64_t *numOfTables, int64_t *numOfNormalTables);
|
2026-04-22 12:26:42 +00:00
|
|
|
int8_t vnodeGetSecurityLevel(void *pVnode);
|
2023-08-18 08:38:26 +00:00
|
|
|
int32_t vnodeGetTableList(void *pVnode, int8_t type, SArray *pList);
|
2023-05-10 08:02:16 +00:00
|
|
|
int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list);
|
|
|
|
|
int32_t vnodeIsCatchUp(SVnode *pVnode);
|
2023-04-24 02:23:43 +00:00
|
|
|
ESyncRole vnodeGetRole(SVnode *pVnode);
|
2024-03-15 01:14:54 +00:00
|
|
|
int32_t vnodeGetArbToken(SVnode *pVnode, char *outToken);
|
2024-11-06 07:25:50 +00:00
|
|
|
int32_t vnodeGetDBSize(void *pVnode, SDbSizeStatisInfo *pInfo);
|
2024-03-15 01:14:54 +00:00
|
|
|
|
|
|
|
|
int32_t vnodeUpdateArbTerm(SVnode *pVnode, int64_t arbTerm);
|
2022-09-28 14:07:16 +00:00
|
|
|
|
2023-05-24 05:22:05 +00:00
|
|
|
int32_t vnodeGetCtbIdList(void *pVnode, int64_t suid, SArray *list);
|
2022-09-28 14:07:16 +00:00
|
|
|
int32_t vnodeGetCtbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg), void *arg);
|
2022-08-25 08:22:55 +00:00
|
|
|
int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list);
|
2023-08-18 08:38:26 +00:00
|
|
|
int32_t vnodeGetStbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg, void *arg1),
|
|
|
|
|
void *arg);
|
2023-05-24 05:22:05 +00:00
|
|
|
void *vnodeGetIdx(void *pVnode);
|
|
|
|
|
void *vnodeGetIvtIdx(void *pVnode);
|
2022-04-19 09:07:42 +00:00
|
|
|
|
2022-08-01 10:01:44 +00:00
|
|
|
int32_t vnodeGetCtbNum(SVnode *pVnode, int64_t suid, int64_t *num);
|
2023-09-22 12:07:51 +00:00
|
|
|
int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num);
|
2025-04-27 10:03:20 +00:00
|
|
|
int32_t vnodeGetStbInfo(SVnode *pVnode, tb_uid_t suid, int64_t *keep, int8_t *flags);
|
2022-08-01 10:01:44 +00:00
|
|
|
int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num);
|
|
|
|
|
int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num);
|
|
|
|
|
|
2025-06-21 07:11:09 +00:00
|
|
|
int32_t vnodeGetTableSchema(void *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid, SSchemaWrapper **pTagSchema);
|
2024-02-02 03:26:47 +00:00
|
|
|
|
2022-10-11 10:22:29 +00:00
|
|
|
void vnodeResetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
2025-09-08 01:02:28 +00:00
|
|
|
int32_t vnodeSetSyncTimeout(SVnode *pVnode, int32_t ms);
|
2022-07-06 07:15:55 +00:00
|
|
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
2023-09-22 12:07:51 +00:00
|
|
|
int32_t vnodeGetLoadLite(SVnode *pVnode, SVnodeLoadLite *pLoad);
|
2022-07-06 07:15:55 +00:00
|
|
|
int32_t vnodeValidateTableHash(SVnode *pVnode, char *tableFName);
|
|
|
|
|
|
|
|
|
|
int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
|
|
|
|
int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
|
|
|
|
|
|
|
|
|
int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp);
|
|
|
|
|
int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
2024-11-05 11:57:13 +00:00
|
|
|
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
2022-07-06 07:15:55 +00:00
|
|
|
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
2026-03-16 06:10:31 +00:00
|
|
|
int32_t vnodeProcessStreamReaderMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
2022-07-06 07:15:55 +00:00
|
|
|
void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs);
|
|
|
|
|
void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs);
|
2023-04-11 06:16:31 +00:00
|
|
|
void vnodeProposeCommitOnNeed(SVnode *pVnode, bool atExit);
|
2026-03-21 03:38:22 +00:00
|
|
|
void vnodeAlterTagForTmq(SVnode *pVnode, const SArray* tbUidList, const SArray *tags, const SArray* uidTags);
|
2022-06-08 06:44:42 +00:00
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
// meta
|
2023-08-18 08:38:26 +00:00
|
|
|
void _metaReaderInit(SMetaReader *pReader, void *pVnode, int32_t flags, SStoreMeta *pAPI);
|
2022-10-12 09:44:42 +00:00
|
|
|
void metaReaderReleaseLock(SMetaReader *pReader);
|
2022-05-12 11:21:44 +00:00
|
|
|
void metaReaderClear(SMetaReader *pReader);
|
2023-05-24 05:22:05 +00:00
|
|
|
int32_t metaReaderGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid);
|
2025-11-15 10:50:27 +00:00
|
|
|
int32_t metaReaderGetTableEntryByVersionUid(SMetaReader *pReader, int64_t version, tb_uid_t uid);
|
2023-05-24 05:22:05 +00:00
|
|
|
int32_t metaReaderGetTableEntryByUidCache(SMetaReader *pReader, tb_uid_t uid);
|
2023-05-24 13:53:40 +00:00
|
|
|
int32_t metaGetTableTags(void *pVnode, uint64_t suid, SArray *uidList);
|
2023-08-18 08:38:26 +00:00
|
|
|
int32_t metaGetTableTagsByUids(void *pVnode, int64_t suid, SArray *uidList);
|
2022-05-20 02:30:48 +00:00
|
|
|
int32_t metaReadNext(SMetaReader *pReader);
|
2023-05-24 05:22:05 +00:00
|
|
|
const void *metaGetTableTagVal(const void *tag, int16_t type, STagVal *tagVal);
|
2024-09-16 04:59:21 +00:00
|
|
|
int32_t metaGetTableNameByUid(void *pVnode, uint64_t uid, char *tbName);
|
2022-11-29 14:19:36 +00:00
|
|
|
|
2022-12-01 03:38:34 +00:00
|
|
|
int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName);
|
2023-05-24 15:49:26 +00:00
|
|
|
int metaGetTableUidByName(void *pVnode, char *tbName, uint64_t *uid);
|
2025-06-30 02:33:34 +00:00
|
|
|
int metaGetTableTypeSuidByName(void *meta, char *tbName, ETableType *tbType, uint64_t *suid);
|
2023-06-01 06:17:12 +00:00
|
|
|
int metaGetTableTtlByUid(void *meta, uint64_t uid, int64_t *ttlDays);
|
2023-08-18 08:38:26 +00:00
|
|
|
bool metaIsTableExist(void *pVnode, tb_uid_t uid);
|
2023-05-29 02:12:27 +00:00
|
|
|
int32_t metaGetCachedTableUidList(void *pVnode, tb_uid_t suid, const uint8_t *key, int32_t keyLen, SArray *pList,
|
2022-12-01 03:38:34 +00:00
|
|
|
bool *acquired);
|
2023-05-29 02:12:27 +00:00
|
|
|
int32_t metaUidFilterCachePut(void *pVnode, uint64_t suid, const void *pKey, int32_t keyLen, void *pPayload,
|
2022-12-01 03:38:34 +00:00
|
|
|
int32_t payloadLen, double selectivityRatio);
|
2025-11-10 02:20:29 +00:00
|
|
|
int32_t metaStableTagFilterCacheGet(void* pVnode, tb_uid_t suid,
|
|
|
|
|
const uint8_t* pTagCondKey, int32_t tagCondKeyLen,
|
|
|
|
|
const uint8_t* pKey, int32_t keyLen, SArray* pList, bool* acquired);
|
|
|
|
|
int32_t metaStableTagFilterCachePut(void* pVnode, uint64_t suid,
|
|
|
|
|
const void* pTagCondKey, int32_t tagCondKeyLen,
|
2025-11-10 08:53:15 +00:00
|
|
|
const void* pKey, int32_t keyLen, SArray* pUidList, SArray** pTagColIds);
|
2025-11-10 02:20:29 +00:00
|
|
|
int32_t metaStableTagFilterCacheDropSTable(SMeta* pMeta, tb_uid_t suid);
|
|
|
|
|
typedef enum {
|
|
|
|
|
STABLE_TAG_FILTER_CACHE_DROP_TABLE = 1,
|
|
|
|
|
STABLE_TAG_FILTER_CACHE_ADD_TABLE = 2,
|
|
|
|
|
} ETagFilterCacheAction;
|
|
|
|
|
int32_t metaStableTagFilterCacheUpdateUid(
|
2025-11-11 12:46:09 +00:00
|
|
|
SMeta* pMeta, const SMetaEntry* pDroppedTable,
|
|
|
|
|
const SMetaEntry* pSuperTable, ETagFilterCacheAction action);
|
2025-11-10 02:20:29 +00:00
|
|
|
int32_t metaStableTagFilterCacheDropTag(
|
2025-11-11 12:46:09 +00:00
|
|
|
SMeta* pMeta, tb_uid_t suid, col_id_t tagColId);
|
2022-12-01 03:38:34 +00:00
|
|
|
tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name);
|
2023-05-29 02:50:50 +00:00
|
|
|
int32_t metaGetCachedTbGroup(void *pVnode, tb_uid_t suid, const uint8_t *pKey, int32_t keyLen, SArray **pList);
|
2023-08-18 08:38:26 +00:00
|
|
|
int32_t metaPutTbGroupToCache(void *pVnode, uint64_t suid, const void *pKey, int32_t keyLen, void *pPayload,
|
2023-05-23 03:46:02 +00:00
|
|
|
int32_t payloadLen);
|
2024-04-08 02:31:49 +00:00
|
|
|
bool metaTbInFilterCache(SMeta *pMeta, const void *key, int8_t type);
|
|
|
|
|
int32_t metaPutTbToFilterCache(SMeta *pMeta, const void *key, int8_t type);
|
2023-10-07 01:30:32 +00:00
|
|
|
int32_t metaSizeOfTbFilterCache(SMeta *pMeta, int8_t type);
|
|
|
|
|
int32_t metaInitTbFilterCache(SMeta *pMeta);
|
2023-05-09 09:04:20 +00:00
|
|
|
|
2025-04-27 10:03:20 +00:00
|
|
|
int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables, int32_t *numOfCols, int8_t *flags);
|
2022-04-08 06:09:15 +00:00
|
|
|
|
2025-06-30 02:33:34 +00:00
|
|
|
int32_t metaGetCachedRefDbs(void *pVnode, tb_uid_t suid, SArray *pList);
|
|
|
|
|
int32_t metaPutRefDbsToCache(void *pVnode, tb_uid_t suid, SArray *pList);
|
2025-03-28 02:07:08 +00:00
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
// tsdb
|
2022-06-16 09:18:30 +00:00
|
|
|
typedef struct STsdbReader STsdbReader;
|
2022-04-14 02:10:56 +00:00
|
|
|
|
2022-09-08 10:36:08 +00:00
|
|
|
#define TSDB_DEFAULT_STT_FILE 8
|
|
|
|
|
#define TSDB_DEFAULT_PAGE_SIZE 4096
|
2022-09-08 08:56:29 +00:00
|
|
|
|
2022-07-25 03:18:30 +00:00
|
|
|
#define TIMEWINDOW_RANGE_CONTAINED 1
|
|
|
|
|
#define TIMEWINDOW_RANGE_EXTERNAL 2
|
2022-04-14 02:53:10 +00:00
|
|
|
|
2022-08-26 07:27:19 +00:00
|
|
|
#define CACHESCAN_RETRIEVE_TYPE_ALL 0x1
|
|
|
|
|
#define CACHESCAN_RETRIEVE_TYPE_SINGLE 0x2
|
|
|
|
|
#define CACHESCAN_RETRIEVE_LAST_ROW 0x4
|
|
|
|
|
#define CACHESCAN_RETRIEVE_LAST 0x8
|
2022-06-28 07:22:32 +00:00
|
|
|
|
2024-12-04 09:39:28 +00:00
|
|
|
int32_t tsdbReaderOpen2(void *pVnode, SQueryTableDataCond *pCond, void *pTableList, int32_t numOfTables,
|
|
|
|
|
SSDataBlock *pResBlock, void **ppReader, const char *idstr, SHashObj **pIgnoreTables);
|
2025-07-16 06:42:16 +00:00
|
|
|
int32_t tsdbSetTableList2(void *pReader, const void *pTableList, int32_t num);
|
2024-12-04 09:39:28 +00:00
|
|
|
int32_t tsdbReaderSetId(void *pReader, const char *idstr);
|
2025-07-16 06:42:16 +00:00
|
|
|
void tsdbReaderClose2(void *pReader);
|
|
|
|
|
int32_t tsdbNextDataBlock2(void *pReader, bool *hasNext);
|
2024-12-04 09:39:28 +00:00
|
|
|
int32_t tsdbRetrieveDatablockSMA2(STsdbReader *pReader, SSDataBlock *pDataBlock, bool *allHave, bool *hasNullSMA);
|
2025-07-16 06:42:16 +00:00
|
|
|
void tsdbReleaseDataBlock2(void *pReader);
|
2025-11-07 07:45:12 +00:00
|
|
|
int32_t tsdbRetrieveDataBlock2(void *pReader, SSDataBlock **pBlock);
|
2025-07-16 06:42:16 +00:00
|
|
|
int32_t tsdbReaderReset2(void *pReader, SQueryTableDataCond *pCond);
|
2024-12-04 09:39:28 +00:00
|
|
|
int32_t tsdbGetFileBlocksDistInfo2(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
|
2025-10-17 05:18:37 +00:00
|
|
|
void tsdbGetDataBlock(STsdbReader* pReader, SSDataBlock** pBlock);
|
|
|
|
|
void tsdbSetDataBlock(STsdbReader* pReader, SSDataBlock* pBlock);
|
2024-12-04 09:39:28 +00:00
|
|
|
int64_t tsdbGetNumOfRowsInMemTable2(STsdbReader *pHandle, uint32_t *rows);
|
|
|
|
|
void *tsdbGetIdx2(SMeta *pMeta);
|
|
|
|
|
void *tsdbGetIvtIdx2(SMeta *pMeta);
|
|
|
|
|
uint64_t tsdbGetReaderMaxVersion2(STsdbReader *pReader);
|
|
|
|
|
void tsdbReaderSetCloseFlag(STsdbReader *pReader);
|
|
|
|
|
int64_t tsdbGetLastTimestamp2(SVnode *pVnode, void *pTableList, int32_t numOfTables, const char *pIdStr);
|
|
|
|
|
void tsdbSetFilesetDelimited(STsdbReader *pReader);
|
|
|
|
|
void tsdbReaderSetNotifyCb(STsdbReader *pReader, TsdReaderNotifyCbFn notifyFn, void *param);
|
2025-11-12 03:02:17 +00:00
|
|
|
int32_t tsdbCreateFirstLastTsIter(void *pVnode, STimeWindow *pWindow, SVersionRange *pVerRange, uint64_t suid, void *pTableList,
|
|
|
|
|
int32_t numOfTables, int32_t order, void **pIter, const char *idstr);
|
2025-11-20 01:39:26 +00:00
|
|
|
int32_t tsdbNextFirstLastTsBlock(void *pIter, SSDataBlock *pRes, bool* hasNext);
|
2025-11-12 03:02:17 +00:00
|
|
|
void tsdbDestroyFirstLastTsIter(void *pIter);
|
2026-01-16 02:32:01 +00:00
|
|
|
int32_t tsdbReaderStepDone(STsdbReader *pReader, int64_t notifyTs);
|
2026-03-20 02:08:49 +00:00
|
|
|
void tsdbReaderSetExecInfo(const STsdbReader *pReader, STableScanAnalyzeInfo *pExecInfo);
|
2023-06-15 09:31:59 +00:00
|
|
|
|
2023-05-23 03:46:02 +00:00
|
|
|
int32_t tsdbReuseCacherowsReader(void *pReader, void *pTableIdList, int32_t numOfTables);
|
2022-10-29 10:27:22 +00:00
|
|
|
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
2024-01-14 05:44:40 +00:00
|
|
|
SArray *pCidList, int32_t *pSlotIds, uint64_t suid, void **pReader, const char *idstr,
|
2024-06-12 07:16:58 +00:00
|
|
|
SArray *pFuncTypeList, SColumnInfo *pkCol, int32_t numOfPks);
|
2023-04-20 08:26:27 +00:00
|
|
|
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, const int32_t *dstSlotIds,
|
2024-09-03 11:16:10 +00:00
|
|
|
SArray *pTableUids, bool *pGotAllRows);
|
2024-07-23 06:47:29 +00:00
|
|
|
void tsdbCacherowsReaderClose(void *pReader);
|
2022-07-11 12:16:48 +00:00
|
|
|
|
2023-03-13 07:05:24 +00:00
|
|
|
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
|
|
|
|
size_t tsdbCacheGetCapacity(SVnode *pVnode);
|
|
|
|
|
size_t tsdbCacheGetUsage(SVnode *pVnode);
|
|
|
|
|
int32_t tsdbCacheGetElems(SVnode *pVnode);
|
2022-04-14 02:01:04 +00:00
|
|
|
|
2023-05-23 10:29:23 +00:00
|
|
|
//// tq
|
2022-08-30 02:07:33 +00:00
|
|
|
typedef struct SIdInfo {
|
|
|
|
|
int64_t version;
|
|
|
|
|
int32_t index;
|
|
|
|
|
} SIdInfo;
|
2022-08-09 11:06:24 +00:00
|
|
|
|
2025-03-15 09:06:48 +00:00
|
|
|
typedef struct SVTColInfo {
|
|
|
|
|
int32_t vColId; // column id of virtual table
|
|
|
|
|
int32_t pColId; // column id of physical table
|
|
|
|
|
int64_t pTbUid; // uid of physical table
|
|
|
|
|
} SVTColInfo;
|
|
|
|
|
|
|
|
|
|
typedef struct SVTSourceScanInfo {
|
|
|
|
|
SHashObj *pVirtualTables; // source column info of each vtable column. key: vtUid, value: SArray<SVTColInfo>*
|
|
|
|
|
SHashObj *pPhysicalTables; // set of vtables for each ptable. Key: ptUid, value: SArray<vtUid>*
|
|
|
|
|
SLRUCache *pPhyTblSchemaCache; // cache for physical table schema
|
|
|
|
|
int32_t nextVirtualTableIdx; // index in the value of pVirtualTables
|
|
|
|
|
uint64_t metaFetch;
|
|
|
|
|
uint64_t cacheHit;
|
|
|
|
|
} SVTSourceScanInfo;
|
|
|
|
|
|
2022-07-07 09:16:12 +00:00
|
|
|
typedef struct STqReader {
|
2025-06-30 02:33:34 +00:00
|
|
|
SPackedData msg;
|
|
|
|
|
SSubmitReq2 submit;
|
|
|
|
|
int32_t nextBlk;
|
|
|
|
|
int64_t lastBlkUid;
|
|
|
|
|
SWalReader *pWalReader;
|
2026-02-26 09:06:07 +00:00
|
|
|
SVnode *pVnode;
|
2025-06-30 02:33:34 +00:00
|
|
|
SHashObj *tbIdHash;
|
|
|
|
|
int32_t cachedSchemaVer;
|
|
|
|
|
int64_t cachedSchemaSuid;
|
|
|
|
|
int64_t cachedSchemaUid;
|
|
|
|
|
SSchemaWrapper *pSchemaWrapper;
|
2026-02-26 09:06:07 +00:00
|
|
|
STSchema *pTSchema;
|
2025-06-30 02:33:34 +00:00
|
|
|
int64_t lastTs;
|
|
|
|
|
bool hasPrimaryKey;
|
|
|
|
|
SExtSchema *extSchema;
|
2026-02-26 09:06:07 +00:00
|
|
|
SHashObj *pTableTagCacheForTmq;
|
|
|
|
|
SRWLatch tagCachelock;
|
2022-07-07 09:16:12 +00:00
|
|
|
} STqReader;
|
|
|
|
|
|
2023-04-27 08:06:06 +00:00
|
|
|
STqReader *tqReaderOpen(SVnode *pVnode);
|
2023-05-24 05:22:05 +00:00
|
|
|
void tqReaderClose(STqReader *);
|
2022-07-07 09:16:12 +00:00
|
|
|
|
2024-06-12 07:16:58 +00:00
|
|
|
bool tqGetTablePrimaryKey(STqReader *pReader);
|
|
|
|
|
void tqSetTablePrimaryKey(STqReader *pReader, int64_t uid);
|
2024-03-22 09:48:59 +00:00
|
|
|
|
2025-03-15 09:06:48 +00:00
|
|
|
int32_t tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList, const char *id);
|
2025-06-30 02:33:34 +00:00
|
|
|
void tqReaderAddTbUidList(STqReader *pReader, const SArray *pTableUidList);
|
|
|
|
|
void tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
|
2022-07-07 09:16:12 +00:00
|
|
|
|
2023-08-18 08:38:26 +00:00
|
|
|
bool tqReaderIsQueriedTable(STqReader *pReader, uint64_t uid);
|
|
|
|
|
bool tqCurrentBlockConsumed(const STqReader *pReader);
|
2023-05-24 05:22:05 +00:00
|
|
|
|
2023-08-18 08:38:26 +00:00
|
|
|
int32_t tqReaderSeek(STqReader *pReader, int64_t ver, const char *id);
|
2026-02-26 09:06:07 +00:00
|
|
|
int32_t tqNextBlockInWal(STqReader *pReader, SSDataBlock* pRes, SHashObj* pCol2SlotId, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr,
|
|
|
|
|
int sourceExcluded, int32_t minPollRows, int64_t timeout, int8_t enableReplay);
|
2023-08-18 08:38:26 +00:00
|
|
|
bool tqNextBlockImpl(STqReader *pReader, const char *idstr);
|
|
|
|
|
SWalReader *tqGetWalReader(STqReader *pReader);
|
2023-10-08 08:06:15 +00:00
|
|
|
int64_t tqGetResultBlockTime(STqReader *pReader);
|
2022-07-08 09:48:34 +00:00
|
|
|
|
2026-02-26 09:06:07 +00:00
|
|
|
void tqUpdateTableTagCache(STqReader* pReader, SExprInfo* pExprInfo, int32_t numOfExpr, int64_t uid, col_id_t colId);
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 02:23:02 +00:00
|
|
|
int32_t tqReaderSetSubmitMsg(STqReader *pReader, void *msgStr, int32_t msgLen, int64_t ver, SArray* rawList, SDecoder* decoder);
|
2025-01-24 06:56:00 +00:00
|
|
|
void tqReaderClearSubmitMsg(STqReader *pReader);
|
2023-04-27 01:28:20 +00:00
|
|
|
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
|
2026-02-26 09:06:07 +00:00
|
|
|
int32_t tqRetrieveTaosxBlock(STqReader *pReader, SMqDataRsp *pRsp, SArray *blocks, SArray *schemas, SSubmitTbData **pSubmitTbDataRet, SArray* rawList, int8_t fetchMeta);
|
2022-04-14 02:01:04 +00:00
|
|
|
|
2025-05-15 10:15:01 +00:00
|
|
|
int32_t tqCommitOffset(void* p);
|
2022-06-01 11:06:58 +00:00
|
|
|
// sma
|
|
|
|
|
int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days);
|
|
|
|
|
|
2022-07-04 06:47:41 +00:00
|
|
|
// SVSnapReader
|
2023-09-12 06:34:06 +00:00
|
|
|
int32_t vnodeSnapReaderOpen(SVnode *pVnode, SSnapshotParam *pParam, SVSnapReader **ppReader);
|
2022-12-20 07:07:27 +00:00
|
|
|
void vnodeSnapReaderClose(SVSnapReader *pReader);
|
2022-07-04 12:04:40 +00:00
|
|
|
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData);
|
|
|
|
|
// SVSnapWriter
|
2023-09-15 11:58:48 +00:00
|
|
|
int32_t vnodeSnapWriterOpen(SVnode *pVnode, SSnapshotParam *pParam, SVSnapWriter **ppWriter);
|
2022-07-16 10:19:54 +00:00
|
|
|
int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *pSnapshot);
|
2022-07-05 11:19:37 +00:00
|
|
|
int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData);
|
2022-04-08 06:09:15 +00:00
|
|
|
|
2024-11-05 11:57:13 +00:00
|
|
|
bool taosXGetTablePrimaryKey(SSnapContext *ctx);
|
|
|
|
|
void taosXSetTablePrimaryKey(SSnapContext *ctx, int64_t uid);
|
|
|
|
|
int32_t buildSnapContext(SVnode *pVnode, int64_t snapVersion, int64_t suid, int8_t subType, int8_t withMeta,
|
|
|
|
|
SSnapContext **ctxRet);
|
|
|
|
|
int32_t getTableInfoFromSnapshot(SSnapContext *ctx, void **pBuf, int32_t *contLen, int16_t *type, int64_t *uid);
|
|
|
|
|
int32_t getMetaTableInfoFromSnapshot(SSnapContext *ctx, SMetaTableInfo *info);
|
|
|
|
|
int32_t setForSnapShot(SSnapContext *ctx, int64_t uid);
|
|
|
|
|
void destroySnapContext(SSnapContext *ctx);
|
2022-08-04 07:01:59 +00:00
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
// structs
|
|
|
|
|
struct STsdbCfg {
|
2022-05-08 09:09:00 +00:00
|
|
|
int8_t precision;
|
|
|
|
|
int8_t update;
|
|
|
|
|
int8_t compression;
|
|
|
|
|
int8_t slLevel;
|
|
|
|
|
int32_t minRows;
|
|
|
|
|
int32_t maxRows;
|
|
|
|
|
int32_t days; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
|
|
|
|
int32_t keep0; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
|
|
|
|
int32_t keep1; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
|
|
|
|
int32_t keep2; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
2023-09-19 10:44:27 +00:00
|
|
|
int32_t keepTimeOffset; // just for save config, use STsdbKeepCfg in STsdb instead
|
2022-05-07 14:33:19 +00:00
|
|
|
SRetention retentions[TSDB_RETENTION_MAX];
|
2025-12-05 05:26:28 +00:00
|
|
|
int32_t encryptAlgr;
|
|
|
|
|
SEncryptData encryptData;
|
2022-05-07 14:33:19 +00:00
|
|
|
};
|
|
|
|
|
|
2022-08-01 10:01:44 +00:00
|
|
|
typedef struct {
|
|
|
|
|
int64_t numOfSTables;
|
|
|
|
|
int64_t numOfCTables;
|
|
|
|
|
int64_t numOfNTables;
|
2025-03-15 06:10:46 +00:00
|
|
|
int64_t numOfVTables;
|
|
|
|
|
int64_t numOfVCTables;
|
2025-09-26 09:32:32 +00:00
|
|
|
int64_t numOfRSMAs;
|
2023-09-22 12:07:51 +00:00
|
|
|
int64_t numOfReportedTimeSeries;
|
2022-08-25 08:22:55 +00:00
|
|
|
int64_t numOfNTimeSeries;
|
2022-08-01 10:01:44 +00:00
|
|
|
int64_t numOfTimeSeries;
|
2023-09-22 12:07:51 +00:00
|
|
|
// int64_t itvTimeSeries;
|
2022-08-01 10:01:44 +00:00
|
|
|
int64_t pointsWritten;
|
|
|
|
|
int64_t totalStorage;
|
|
|
|
|
int64_t compStorage;
|
2025-07-03 08:44:29 +00:00
|
|
|
int64_t storageLastUpd;
|
2022-08-01 10:01:44 +00:00
|
|
|
} SVnodeStats;
|
|
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
struct SVnodeCfg {
|
2022-08-01 10:01:44 +00:00
|
|
|
int32_t vgId;
|
2025-07-12 07:39:29 +00:00
|
|
|
int32_t mountVgId;
|
2022-08-01 10:01:44 +00:00
|
|
|
char dbname[TSDB_DB_FNAME_LEN];
|
|
|
|
|
uint64_t dbId;
|
|
|
|
|
int32_t cacheLastSize;
|
2026-03-20 05:56:20 +00:00
|
|
|
int32_t cacheLastShardBits; // Number of shards for last cache LRU, -1 for auto
|
2022-08-01 10:01:44 +00:00
|
|
|
int32_t szPage;
|
|
|
|
|
int32_t szCache;
|
|
|
|
|
uint64_t szBuf;
|
|
|
|
|
bool isHeap;
|
|
|
|
|
bool isWeak;
|
|
|
|
|
int8_t cacheLast;
|
|
|
|
|
int8_t isTsma;
|
|
|
|
|
int8_t isRsma;
|
|
|
|
|
int8_t hashMethod;
|
|
|
|
|
int8_t standby;
|
|
|
|
|
STsdbCfg tsdbCfg;
|
|
|
|
|
SWalCfg walCfg;
|
|
|
|
|
SSyncCfg syncCfg;
|
|
|
|
|
SVnodeStats vndStats;
|
|
|
|
|
uint32_t hashBegin;
|
|
|
|
|
uint32_t hashEnd;
|
2023-05-04 05:51:48 +00:00
|
|
|
bool hashChange;
|
2022-09-08 08:56:29 +00:00
|
|
|
int16_t sttTrigger;
|
2022-09-02 09:12:08 +00:00
|
|
|
int16_t hashPrefix;
|
|
|
|
|
int16_t hashSuffix;
|
2022-09-08 10:36:08 +00:00
|
|
|
int32_t tsdbPageSize;
|
2025-12-05 05:26:28 +00:00
|
|
|
int32_t tdbEncryptAlgr;
|
|
|
|
|
SEncryptData tdbEncryptData;
|
2025-07-14 08:33:53 +00:00
|
|
|
int32_t ssChunkSize;
|
|
|
|
|
int32_t ssKeepLocal;
|
|
|
|
|
int8_t ssCompact;
|
2026-01-28 11:06:16 +00:00
|
|
|
int8_t isAudit;
|
|
|
|
|
int8_t allowDrop;
|
2026-03-16 12:26:22 +00:00
|
|
|
int8_t secureDelete;
|
2026-04-22 12:26:42 +00:00
|
|
|
int8_t securityLevel;
|
2022-04-14 02:01:04 +00:00
|
|
|
};
|
2021-11-07 07:58:32 +00:00
|
|
|
|
2025-09-26 09:32:32 +00:00
|
|
|
#define TABLE_ROLLUP_ON ((int8_t)0x1)
|
|
|
|
|
#define TABLE_IS_ROLLUP(FLG) (((FLG) & (TABLE_ROLLUP_ON)) != 0)
|
|
|
|
|
#define TABLE_SET_ROLLUP(FLG) ((FLG) |= TABLE_ROLLUP_ON)
|
|
|
|
|
#define TABLE_RESET_ROLLUP(FLG) ((FLG) &= ~TABLE_ROLLUP_ON)
|
2022-04-24 06:19:12 +00:00
|
|
|
|
2024-03-06 12:06:26 +00:00
|
|
|
#define TABLE_COL_COMPRESSED ((int8_t)0x2)
|
|
|
|
|
#define TABLE_IS_COL_COMPRESSED(FLG) (((FLG) & (TABLE_COL_COMPRESSED)) != 0)
|
|
|
|
|
#define TABLE_SET_COL_COMPRESSED(FLG) ((FLG) |= TABLE_COL_COMPRESSED)
|
|
|
|
|
|
2025-03-15 06:10:46 +00:00
|
|
|
#define TABLE_VIRTUAL ((int8_t)0x4)
|
|
|
|
|
#define TABLE_IS_VIRTUAL(FLG) (((FLG) & (TABLE_VIRTUAL)) != 0)
|
|
|
|
|
#define TABLE_SET_VIRTUAL(FLG) ((FLG) |= TABLE_VIRTUAL)
|
|
|
|
|
|
2024-11-27 09:53:53 +00:00
|
|
|
struct SFileSetReader;
|
|
|
|
|
int32_t tsdbFileSetReaderOpen(void *pVnode, struct SFileSetReader **ppReader);
|
|
|
|
|
int32_t tsdbFileSetReaderNext(struct SFileSetReader *pReader);
|
|
|
|
|
int32_t tsdbFileSetGetEntryField(struct SFileSetReader *pReader, const char *field, void *value);
|
|
|
|
|
void tsdbFileSetReaderClose(struct SFileSetReader **ppReader);
|
|
|
|
|
|
2025-03-14 08:10:13 +00:00
|
|
|
int32_t metaFetchEntryByUid(SMeta *pMeta, int64_t uid, SMetaEntry **ppEntry);
|
|
|
|
|
void metaFetchEntryFree(SMetaEntry **ppEntry);
|
|
|
|
|
|
2025-06-30 02:33:34 +00:00
|
|
|
/**
|
|
|
|
|
* @brief Get raw write metrics for a vnode
|
|
|
|
|
*
|
|
|
|
|
* @param pVnode Pointer to the vnode object
|
|
|
|
|
* @param pRawMetrics Pointer to the SRawWriteMetrics struct to fill with raw metrics
|
|
|
|
|
* @return 0 on success, non-zero on error
|
|
|
|
|
*/
|
|
|
|
|
int32_t vnodeGetRawWriteMetrics(void *pVnode, SRawWriteMetrics *pRawMetrics);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Reset raw write metrics for a vnode by subtracting old values
|
|
|
|
|
*
|
|
|
|
|
* @param pVnode Pointer to the vnode object
|
|
|
|
|
* @param pOldMetrics Pointer to the SRawWriteMetrics struct containing values to subtract
|
|
|
|
|
* @return 0 on success, non-zero on error
|
|
|
|
|
*/
|
|
|
|
|
int32_t vnodeResetRawWriteMetrics(void *pVnode, const SRawWriteMetrics *pOldMetrics);
|
|
|
|
|
|
2021-09-22 12:29:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-09-29 11:26:11 +00:00
|
|
|
#endif /*_TD_VNODE_H_*/
|