• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #4986

15 Mar 2026 08:32AM UTC coverage: 37.305% (-31.3%) from 68.601%
#4986

push

travis-ci

tomchon
test: keep docs and unit test

125478 of 336361 relevant lines covered (37.3%)

1134847.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/source/dnode/vnode/src/vnd/vnodeScan.c
1
/*
2
 * Copyright (c) 2023 Hongze Cheng <hzcheng@umich.edu>.
3
 * All rights reserved.
4
 *
5
 * This code is the intellectual property of Hongze Cheng.
6
 * Any reproduction or distribution, in whole or in part,
7
 * without the express written permission of Hongze Cheng is
8
 * strictly prohibited.
9
 */
10

11
#include "vnd.h"
12
#include "vnode.h"
13
#include "vnodeInt.h"
14

15
extern int32_t tsdbAsyncScan(STsdb *tsdb, const STimeWindow *tw);
16

17
static int32_t vnodeAsyncScan(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
×
18
  SScanVnodeReq req = {0};
×
19

20
  int32_t code = tDeserializeSScanVnodeReq(pReq, len, &req);
×
21
  if (code) return code;
×
22

23
  vInfo("vgId:%d, scan msg will be processed, db:%s dbUid:%" PRId64 " scanStartTime:%" PRId64, TD_VID(pVnode), req.db,
×
24
        req.dbUid, req.scanStartTime);
25

26
  return tsdbAsyncScan(pVnode->pTsdb, &req.tw);
×
27
}
28

29
int32_t vnodeProcessScanVnodeReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) {
×
30
  if (!pVnode->restored) {
×
31
    vInfo("vgId:%d, ignore scan req during restoring. ver:%" PRId64, TD_VID(pVnode), ver);
×
32
    return 0;
×
33
  }
34
  return vnodeAsyncScan(pVnode, ver, pReq, len, pRsp);
×
35
}
36

37
extern void tsdbScanMonitorGetInfo(STsdb *tsdb, SQueryScanProgressRsp *rsp);
38

39
int32_t vnodeQueryScanProgress(SVnode *pVnode, SRpcMsg *pMsg) {
×
40
  int32_t code = 0;
×
41

42
  SQueryScanProgressReq req = {0};
×
43

44
  int32_t               rspSize = 0;
×
45
  SRpcMsg               rspMsg = {0};
×
46
  void                 *pRsp = NULL;
×
47
  SQueryScanProgressRsp rsp = {0};
×
48

49
  // deserialize request
50
  code = tDeserializeSQueryScanProgressReq(pMsg->pCont, pMsg->contLen, &req);
×
51
  if (code) {
×
52
    code = TSDB_CODE_INVALID_MSG;
×
53
    goto _exit;
×
54
  }
55

56
  // query scan progress
57
  rsp.dnodeId = req.dnodeId;
×
58
  tsdbScanMonitorGetInfo(pVnode->pTsdb, &rsp);
×
59
  vDebug("update scan progress, scanId:%d vgId:%d, dnodeId:%d, numberFileset:%d, finished:%d", rsp.scanId, rsp.vgId,
×
60
         rsp.dnodeId, rsp.numberFileset, rsp.finished);
61
  rsp.scanId = req.scanId;
×
62

63
  // serialize response
64
  rspSize = tSerializeSQueryScanProgressRsp(NULL, 0, &rsp);
×
65
  if (rspSize < 0) {
×
66
    code = TSDB_CODE_INVALID_MSG;
×
67
    goto _exit;
×
68
  }
69

70
  pRsp = rpcMallocCont(rspSize);
×
71
  if (pRsp == NULL) {
×
72
    vError("rpcMallocCont %d failed", rspSize);
×
73
    code = TSDB_CODE_OUT_OF_MEMORY;
×
74
    goto _exit;
×
75
  }
76
  code = tSerializeSQueryScanProgressRsp(pRsp, rspSize, &rsp);
×
77
  if (code < 0) {
×
78
    goto _exit;
×
79
  }
80
  code = 0;
×
81

82
_exit:
×
83
  rspMsg.info = pMsg->info;
×
84
  rspMsg.pCont = pRsp;
×
85
  rspMsg.contLen = rspSize;
×
86
  rspMsg.code = code;
×
87
  rspMsg.msgType = TDMT_VND_QUERY_COMPACT_PROGRESS_RSP;
×
88

89
  tmsgSendRsp(&rspMsg);
×
90

91
  return 0;
×
92
}
93

94
extern void tsdbCancelScanTask(STsdb *tsdb);
95

96
int32_t vnodeProcessKillScanReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) {
×
97
  SVKillScanReq req = {0};
×
98

99
  vDebug("vgId:%d, kill scan msg will be processed, pReq:%p, len:%d", TD_VID(pVnode), pReq, len);
×
100
  int32_t code = tDeserializeSVKillScanReq(pReq, len, &req);
×
101
  if (code) {
×
102
    return TSDB_CODE_INVALID_MSG;
×
103
  }
104

105
  vInfo("vgId:%d, kill scan msg will be processed, scanId:%d, dnodeId:%d, vgId:%d", TD_VID(pVnode), req.scanId,
×
106
        req.dnodeId, req.vgId);
107

108
  tsdbCancelScanTask(pVnode->pTsdb);
×
109

110
  pRsp->msgType = TDMT_VND_KILL_SCAN_RSP;
×
111
  pRsp->code = TSDB_CODE_SUCCESS;
×
112
  pRsp->pCont = NULL;
×
113
  pRsp->contLen = 0;
×
114

115
  return 0;
×
116
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc