mirror of
https://github.com/taosdata/TDengine
synced 2026-05-24 10:09:01 +00:00
* fix: remove debug log * fix: remove assert * fix: delete unused code * enh: [TD-37251] Support expr in state window. * feat(stream): support expr in state window trigger * enh: [TD-37251] Fix SCL_IS_CONST_CALC condition. * fix(stream): set ver in wal * fix: print code * fix: increase runner replica num * fix: trigger mem error * fix: sliding _tnext_ts value * fix(stream): disable tagFilterCache in stream reader trigger * fix: crash * Revert "fix(stream): fix history calc finish check" This reverts commitf93d17f1d2. * Revert "fix(stream): fix calc request allocation in trigger" This reverts commitc5410f6da0. * fix(stream): fix calc request allocation in trigger * enh: [TD-37251] External window support more placeholder. * fix(stream): modify size of return from 1000000->4096 * enh: [TD-37251] Modify error msg when stream query do not have from clause. * fix(stream): add log for group not found * fix(stream): do not return gid=0 in walMetaData interface * enh: [TD-37251] Fix missing ts column in vtable query. * fix: test case build failed * fix: invalid read issue * fix(stream): add vtable logic * fix(stream): encode error in wal * fix(stream): add vtable logic * fix(stream): add log * fix: diff funcition crash * Revert "Merge branch 'enh/TD-37251-3.0-dropoutput' into enh/TD-37251-3.0" This reverts commite93cbd6fd4, reversing changes made todc3230591d. * Revert "Merge branch 'enh/TD-37251-3.0-vtable' into enh/TD-37251-3.0" This reverts commitdc3230591d, reversing changes made to085e086782. * fix(stream): fix block data len is too large if data type is vchar * fix: drop output table * feat: runner delete output table * process pDropBlock in trigger task. * fix(stream): opti log level * fix(stream): build block for drop table * fix(stream): set gid for normal table * fix(stream): set gid for normal table * feat: Support delete output. * fix(stream): rows error * fix(stream): memory leak * enh: [TD-37251] Fix external window wrong ts column. * fix(stream): fix calc time check in batch mode * fix: merge aligned external window issue * Revert "fix(stream): fix calc time check in batch mode" This reverts commitd895b7f577. * fix(stream): add test case * fix(stream): add insert drop table logic * fix: external window end issue * fix(stream): add test case * fix(stream): fix trigger pull data * fix(stream): fix history calc request * enh: drop table on snode * fix(stream): adjust hash index if data is filtered in wal * fix(stream): rollback * enh: add merge aligned extwin window row idx * fix: drop output table * fix: compile issue * enh: [TD-37251] Add flag to identify interval window is overlapped * fix: overlap * fix(stream): set gid=-1 for initialized * fix(stream): modify log level * fix: trigger slow issue * fix(stream): add basic test for obj pool * fix(stream): fix metadata clear in trigger * fix(stream): fix idle runner allocation in trigger * fix: handle agg output on externalWin * fix: test case * fix(stream): adjust log * fix: reset pCtx pOutput * fix: memory leak * fix: search first win for tsCol * fix(stream): add test case for schema change * fix: mem leak * fix: mem leak * Reapply "Merge branch 'enh/TD-37251-3.0-vtable' into enh/TD-37251-3.0" This reverts commitb508e66958. * fix(stream): fix virtual table data pull * fix(stream): fix set table request * fix(stream): process empty uidlist * fix(stream): fix set table request * fix(stream): fix data new request in trigger * fix(stream): tablelist error for vtable * fix(stream): block ver is null * fix(stream): remove version limition for wal * fix(stream): block rows error * fix(stream): fix pending calc param in batch mode * fix(stream): auto create table * fix(stream): fix stream vtable data merge * fix: _tcurrentts * fix(stream): destroy hash * fix(stream): fix trigger status * fix(stream): colId error in vtable * fix(stream): update nrows of vtable data block * fix(stream): fix trigger status * fix(stream): enable low latency calc for period trigger * fix: test case file path * fix: test case file path * fix: string to node in reader * enh: add test log * fix(stream): increase wait time of non-low-latency mode * fix(stream): fix column capacity in scalar calculation * fix(stream): fix column capacity in trigger expr calculation * fix: get origTableInfos * fix(stream): fix calc data pull in trigger * fix(stream): fix calc data cache write in trigger * enh: [TD-37251] Add flag to identify interval wind * fix: external window memory usage issue * fix(stream): fix epxr result column in trigger * fix(stream): add metaCache for calc plan * fix(stream): fix stream obj list clear * fix(stream): rollback * enh: [TD-37251] Add flag to identify interval wind * fix: mem free * fix(stream): add metaCache for calc plan * fix(stream): fix calc data cache write in trigger * fix(stream): fix calc data cache write in trigger * enh: optimize external result block memory * fix(stream): modify logic of judge table for create table * fix(stream): fix event window check in trigger * fix(stream): fix count window check in trigger * fix(stream): colSize=0 while encoding block because pDataCol->hasNull is false in secode time & reload table list if create table * enh: optimize stream memory * fix(stream): trigger tag error * fix: add log * fix(stream): fix calc data write in trigger * fix: drop output table * fix(stream): fix max delay in trigger * fix: drop output table * fix(stream): fix max delay in trigger * fix(build): handle return value of function * fix(stream): read gid error if it is child table in stream * fix(stream): fix calc param of history calculation * fix(stream): fix recalc of delete data * fix(stream): fix calc data of period trigger * fix(stream): fix cache read check * fix(stream): filter error in calc plan * fix: reset externla window expr * fix(stream): fix calc parm of max delay * fix: time range and case issues * fix(stream): fix crash in trigger * fix: case issues * fix: fix window node mem leak. * fix(stream): fix meta data clear in trigger * fix(stream): table schema is old in TsdbDataRequest for vtable * fix: fix slingding window place holder check condition. * Revert "fix: fix slingding window place holder check condition." This reverts commitad864a1dc1. * fix(stream): null pointer error * fix: case issue * fix(stream): calc data error for vtable * fix(stream): fix data sorter in trigger * fix(stream): add log for delete data * fix(stream): fix start version of realtime calculation * fix(stream): fix cache data merger of vtable * fix: case issues * fix(ci): upgrade stream cases in test_cols_function * fix(stream): gid not found if change tag value * fix: fix slingding window place holder check condition. * fix(stream): fix virt table info request in trigger * fix(stream): set gid = uid if stream table type != SUPER table * fix: clean cache data by group * fix: add block info and case issues * fix: fix heap-buffer-overflow. * fix(stream): fix state window with extend param * fix: fix access null pointer. * fix: case issues * fix: case issue * fix(stream): fix ignore_nodata_trigger option for period trigger * fix(stream): fix pseudo col fetch for calc data * fix: Extend checking time to avoid timeout. * fix: case issues * fix(stream): fix group col fetch for virtual tables * fix(stream): tag is NULL for non vtable * fix(stream): fix sliding check of virtual table * test(stream): check stream status after create all streams * fix: add log * fix(stream): fix wal meta truncate when ignore disorder * fix(stream): gid not found for child table * fix: fix place holder condition pushdown error. * fix(stream): suid not equal when delete data for child table * fix: id issue * fix(stream): disable recalc for count trigger * fix: cast result rowSize error in project * fix(stream): add log for tsdb meta * fix(stream): fix gid in tsdb meta request * fix(stream): fix wend of unclosed windows * fix(stream): fix ignore_nodata_trigger option for period trigger * fix: case issues * fix(stream): fix calc data pull for empty interval window * fix: fix ext window condition. * fix(ci): smaBasic performance check affectd by debug level log * fix(stream): add suid when set table list for vtable * fix: forbid using prefilter when using %%trows an trigger table is virtual table. * fix: forbid prefilter %%trows cases. * fix(stream): sort cid in tsdbVirtalDataReq * fix: forbid prefilter %%trows cases. * fix(stream): add log for virtual table tsdb data * fix(stream): get delete msg for vtable * fix: winRowIndex * Revert "fix: winRowIndex" This reverts commite08b41cf96. * fix(stream): fix data merge in trigger * test(stream): fix case ans * fix(stream): fix empty calc data pull for period trigger * fix(stream): col index error for tsdbVirtalDataReq * fix(stream): pTableList is NULL for vtable * test(stream): fix case ans * fix(stream): fix notification in trigger * fix(stream): memory leak * fix(stream): fix virtual data pull in trigger * test(stream): fix case ans * fix(stream): col index error for tsdbVirtalDataReq * fix(stream): pTableList is NULL for vtable * test(stream): fix case ans * fix(stream): fix notification in trigger * fix(stream): memory leak * fix(stream): fix virtual data pull in trigger * test(stream): fix case ans * fix: case issue * fix: crash issue * fix: forbid prefilter %%trows cases. * fix(stream): session case * fix(stream): fix data pull for virtual tables * fix(stream): add log * fix(stream): fix calc req send in batch mode * fix: fix stream UT * fix(stream): tablelist is null for non vtable * fix: mem leak * fix(stream): fix compile error in trigger * fix: return code issue --------- Co-authored-by: dapan1121 <wpan@taosdata.com> Co-authored-by: facetosea <285808407@qq.com> Co-authored-by: Jing Sima <simondominic9997@outlook.com> Co-authored-by: Jinqing Kuang <kuangjinqingcn@gmail.com> Co-authored-by: Tony Zhang <tonyzhang@taosdata.com>
215 lines
5.5 KiB
C
215 lines
5.5 KiB
C
/*
|
|
* 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/>.
|
|
*/
|
|
|
|
#ifndef _TD_WAL_H_
|
|
#define _TD_WAL_H_
|
|
|
|
#include "os.h"
|
|
#include "tarray.h"
|
|
#include "tdef.h"
|
|
#include "tlog.h"
|
|
#include "tmsg.h"
|
|
#include "ttrace.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define WAL_PROTO_VER 0
|
|
#define WAL_NOSUFFIX_LEN 20
|
|
#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1)
|
|
#define WAL_LOG_SUFFIX "log"
|
|
#define WAL_INDEX_SUFFIX "idx"
|
|
#define WAL_REFRESH_MS 1000
|
|
#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12)
|
|
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
|
|
#define WAL_MAGIC 0xFAFBFCFDF4F3F2F1ULL
|
|
#define WAL_SCAN_BUF_SIZE (1024 * 1024 * 3)
|
|
#define WAL_JSON_BUF_SIZE 30
|
|
|
|
typedef enum {
|
|
TAOS_WAL_SKIP = 0,
|
|
TAOS_WAL_WRITE = 1,
|
|
TAOS_WAL_FSYNC = 2,
|
|
} EWalType;
|
|
|
|
typedef struct {
|
|
int32_t vgId;
|
|
int32_t fsyncPeriod; // millisecond
|
|
int32_t retentionPeriod; // secs
|
|
int32_t rollPeriod; // secs
|
|
int64_t retentionSize;
|
|
int64_t segSize;
|
|
int64_t committed;
|
|
EWalType level; // wal level
|
|
int32_t encryptAlgorithm;
|
|
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
|
int8_t clearFiles;
|
|
} SWalCfg;
|
|
|
|
typedef struct {
|
|
int64_t firstVer;
|
|
int64_t verInSnapshotting;
|
|
int64_t snapshotVer;
|
|
int64_t commitVer;
|
|
int64_t appliedVer;
|
|
int64_t lastVer;
|
|
int64_t logRetention;
|
|
} SWalVer;
|
|
|
|
#pragma pack(push, 1)
|
|
// used by sync module
|
|
typedef struct {
|
|
int8_t isWeek;
|
|
uint64_t seqNum;
|
|
uint64_t term;
|
|
} SWalSyncInfo;
|
|
|
|
typedef struct {
|
|
int64_t version;
|
|
int64_t ingestTs;
|
|
int32_t bodyLen;
|
|
int16_t msgType;
|
|
int8_t protoVer;
|
|
|
|
// sync meta
|
|
SWalSyncInfo syncMeta;
|
|
|
|
char body[];
|
|
} SWalCont;
|
|
|
|
typedef struct {
|
|
uint64_t magic;
|
|
uint32_t cksumHead;
|
|
uint32_t cksumBody;
|
|
SWalCont head;
|
|
} SWalCkHead;
|
|
#pragma pack(pop)
|
|
|
|
typedef void (*stopDnodeFn)();
|
|
typedef struct SWal {
|
|
// cfg
|
|
SWalCfg cfg;
|
|
int32_t fsyncSeq;
|
|
// meta
|
|
SWalVer vers;
|
|
TdFilePtr pLogFile;
|
|
TdFilePtr pIdxFile;
|
|
int32_t writeCur;
|
|
SArray *fileInfoSet; // SArray<SWalFileInfo>
|
|
// gc
|
|
SArray *toDeleteFiles; // SArray<SWalFileInfo>
|
|
// status
|
|
int64_t totSize;
|
|
int64_t lastRollSeq;
|
|
// ctl
|
|
int64_t refId;
|
|
TdThreadRwlock mutex;
|
|
// ref
|
|
SHashObj *pRefHash; // refId -> SWalRef
|
|
// path
|
|
char path[WAL_PATH_LEN];
|
|
|
|
stopDnodeFn stopDnode;
|
|
|
|
// reusable write head
|
|
SWalCkHead writeHead;
|
|
} SWal;
|
|
|
|
typedef struct {
|
|
int64_t refId;
|
|
int64_t refVer;
|
|
SWal *pWal;
|
|
} SWalRef;
|
|
|
|
// todo hide this struct
|
|
typedef struct SWalReader {
|
|
SWal *pWal;
|
|
int64_t readerId;
|
|
TdFilePtr pLogFile;
|
|
TdFilePtr pIdxFile;
|
|
int64_t curFileFirstVer;
|
|
int64_t curVersion;
|
|
int64_t capacity;
|
|
TdThreadMutex mutex;
|
|
SWalCkHead *pHead;
|
|
} SWalReader;
|
|
|
|
// module initialization
|
|
int32_t walInit(stopDnodeFn stopDnode);
|
|
void walCleanUp();
|
|
|
|
// handle open and ctl
|
|
SWal *walOpen(const char *path, SWalCfg *pCfg);
|
|
int32_t walAlter(SWal *, SWalCfg *pCfg);
|
|
int32_t walPersist(SWal *);
|
|
void walClose(SWal *);
|
|
|
|
// write interfaces
|
|
// By assigning index by the caller, wal gurantees linearizability
|
|
int32_t walAppendLog(SWal *, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body, int32_t bodyLen,
|
|
const STraceId *trace);
|
|
int32_t walFsync(SWal *, bool force);
|
|
|
|
// apis for lifecycle management
|
|
int32_t walCommit(SWal *, int64_t ver);
|
|
int32_t walRollback(SWal *, int64_t ver);
|
|
// notify that previous logs can be pruned safely
|
|
int32_t walBeginSnapshot(SWal *, int64_t ver, int64_t logRetention);
|
|
int32_t walEndSnapshot(SWal *);
|
|
int32_t walRestoreFromSnapshot(SWal *, int64_t ver);
|
|
void walApplyVer(SWal *, int64_t ver);
|
|
|
|
// wal reader
|
|
SWalReader *walOpenReader(SWal *, int64_t id);
|
|
void walCloseReader(SWalReader *pRead);
|
|
void walReadReset(SWalReader *pReader);
|
|
int32_t walReadVer(SWalReader *pRead, int64_t ver);
|
|
int32_t walReaderSeekVer(SWalReader *pRead, int64_t ver);
|
|
int32_t walNextValidMsg(SWalReader *pRead, bool scanMeta);
|
|
int64_t walReaderGetCurrentVer(const SWalReader *pReader);
|
|
int64_t walReaderGetValidFirstVer(const SWalReader *pReader);
|
|
int64_t walReaderGetSkipToVersion(SWalReader *pReader);
|
|
void walReaderSetSkipToVersion(SWalReader *pReader, int64_t ver);
|
|
void walReaderValidVersionRange(SWalReader *pReader, int64_t *sver, int64_t *ever);
|
|
void walReaderVerifyOffset(SWalReader *pWalReader, STqOffsetVal *pOffset);
|
|
|
|
// only for tq usage
|
|
int32_t walFetchHead(SWalReader *pRead, int64_t ver);
|
|
int32_t walFetchBody(SWalReader *pRead);
|
|
int32_t walSkipFetchBody(SWalReader *pRead);
|
|
|
|
SWalRef *walOpenRef(SWal *);
|
|
void walCloseRef(SWal *pWal, int64_t refId);
|
|
void walRefFirstVer(SWal *, SWalRef *);
|
|
void walRefLastVer(SWal *, SWalRef *);
|
|
|
|
// helper function for raft
|
|
bool walLogExist(SWal *, int64_t ver);
|
|
bool walIsEmpty(SWal *);
|
|
|
|
// lifecycle check
|
|
int64_t walGetFirstVer(SWal *);
|
|
int64_t walGetSnapshotVer(SWal *);
|
|
int64_t walGetLastVer(SWal *);
|
|
int64_t walGetVerRetention(SWal *pWal, int64_t bytes);
|
|
int64_t walGetCommittedVer(SWal *);
|
|
int64_t walGetAppliedVer(SWal *);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // _TD_WAL_H_
|