vnodeOpen.c 13.1 KB
Newer Older
H
save  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

H
Hongze Cheng 已提交
16
#include "vnd.h"
H
save  
Hongze Cheng 已提交
17

S
Shengliang Guan 已提交
18
int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
H
Hongze Cheng 已提交
19
  SVnodeInfo info = {0};
S
Shengliang Guan 已提交
20
  char       dir[TSDB_FILENAME_LEN] = {0};
H
Hongze Cheng 已提交
21 22 23

  // check config
  if (vnodeCheckCfg(pCfg) < 0) {
S
Shengliang Guan 已提交
24
    vError("vgId:%d, failed to create vnode since:%s", pCfg->vgId, tstrerror(terrno));
H
Hongze Cheng 已提交
25 26 27 28
    return -1;
  }

  // create vnode env
H
Hongze Cheng 已提交
29 30 31 32 33 34 35 36 37 38
  if (pTfs) {
    if (tfsMkdirAt(pTfs, path, (SDiskID){0}) < 0) {
      vError("vgId:%d, failed to create vnode since:%s", pCfg->vgId, tstrerror(terrno));
      return -1;
    }
    snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path);
  } else {
    if (taosMkDir(path)) {
      return TAOS_SYSTEM_ERROR(errno);
    }
H
Hongze Cheng 已提交
39
    snprintf(dir, TSDB_FILENAME_LEN, "%s", path);
H
Hongze Cheng 已提交
40 41
  }

H
Hongze Cheng 已提交
42 43 44 45 46
  if (pCfg) {
    info.config = *pCfg;
  } else {
    info.config = vnodeCfgDefault;
  }
M
Minghao Li 已提交
47 48
  info.state.committed = -1;
  info.state.applied = -1;
H
Hongze Cheng 已提交
49
  info.state.commitID = 0;
H
Hongze Cheng 已提交
50

H
Hongze Cheng 已提交
51
  vInfo("vgId:%d, save config while create", info.config.vgId);
H
Hongze Cheng 已提交
52
  if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir) < 0) {
H
Hongze Cheng 已提交
53
    vError("vgId:%d, failed to save vnode config since %s", pCfg ? pCfg->vgId : 0, tstrerror(terrno));
H
Hongze Cheng 已提交
54 55 56
    return -1;
  }

H
Hongze Cheng 已提交
57
  vInfo("vgId:%d, vnode is created", info.config.vgId);
S
Shengliang Guan 已提交
58 59 60
  return 0;
}

61
int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) {
S
Shengliang Guan 已提交
62 63 64 65 66 67 68 69 70
  SVnodeInfo info = {0};
  char       dir[TSDB_FILENAME_LEN] = {0};
  int32_t    ret = 0;

  if (pTfs) {
    snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path);
  } else {
    snprintf(dir, TSDB_FILENAME_LEN, "%s", path);
  }
H
Hongze Cheng 已提交
71

S
Shengliang Guan 已提交
72 73 74 75 76 77 78 79 80 81 82
  ret = vnodeLoadInfo(dir, &info);
  if (ret < 0) {
    vError("vgId:%d, failed to read vnode config from %s since %s", pReq->vgId, path, tstrerror(terrno));
    return -1;
  }

  SSyncCfg *pCfg = &info.config.syncCfg;
  pCfg->myIndex = pReq->selfIndex;
  pCfg->replicaNum = pReq->replica;
  memset(&pCfg->nodeInfo, 0, sizeof(pCfg->nodeInfo));

83
  vInfo("vgId:%d, save config while alter, replicas:%d selfIndex:%d", pReq->vgId, pCfg->replicaNum, pCfg->myIndex);
S
Shengliang Guan 已提交
84 85
  for (int i = 0; i < pReq->replica; ++i) {
    SNodeInfo *pNode = &pCfg->nodeInfo[i];
86
    pNode->nodeId = pReq->replicas[i].id;
S
Shengliang Guan 已提交
87 88
    pNode->nodePort = pReq->replicas[i].port;
    tstrncpy(pNode->nodeFqdn, pReq->replicas[i].fqdn, sizeof(pNode->nodeFqdn));
89
    (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort);
90
    vInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId);
S
Shengliang Guan 已提交
91 92
  }

S
Shengliang Guan 已提交
93
  info.config.syncCfg = *pCfg;
S
Shengliang Guan 已提交
94 95 96 97 98 99
  ret = vnodeSaveInfo(dir, &info);
  if (ret < 0) {
    vError("vgId:%d, failed to save vnode config since %s", pReq->vgId, tstrerror(terrno));
    return -1;
  }

H
Hongze Cheng 已提交
100
  ret = vnodeCommitInfo(dir);
S
Shengliang Guan 已提交
101 102 103 104 105
  if (ret < 0) {
    vError("vgId:%d, failed to commit vnode config since %s", pReq->vgId, tstrerror(terrno));
    return -1;
  }

S
Shengliang Guan 已提交
106
  vInfo("vgId:%d, vnode config is saved", info.config.vgId);
H
Hongze Cheng 已提交
107 108 109
  return 0;
}

S
Shengliang Guan 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
int32_t vnodeRenameVgroupId(const char *srcPath, const char *dstPath, int32_t srcVgId, int32_t dstVgId, STfs *pTfs) {
  int32_t ret = tfsRename(pTfs, srcPath, dstPath);
  if (ret != 0) return ret;

  char oldRname[TSDB_FILENAME_LEN] = {0};
  char newRname[TSDB_FILENAME_LEN] = {0};
  char tsdbPath[TSDB_FILENAME_LEN] = {0};
  char tsdbFilePrefix[TSDB_FILENAME_LEN] = {0};
  snprintf(tsdbPath, TSDB_FILENAME_LEN, "%s%stsdb", dstPath, TD_DIRSEP);
  snprintf(tsdbFilePrefix, TSDB_FILENAME_LEN, "tsdb%sv", TD_DIRSEP);

  STfsDir *tsdbDir = tfsOpendir(pTfs, tsdbPath);
  if (tsdbDir == NULL) return 0;

  while (1) {
    const STfsFile *tsdbFile = tfsReaddir(tsdbDir);
    if (tsdbFile == NULL) break;
H
Hongze Cheng 已提交
127
    if (tsdbFile->rname[0] == '\0') continue;
S
Shengliang Guan 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
    tstrncpy(oldRname, tsdbFile->rname, TSDB_FILENAME_LEN);

    char *tsdbFilePrefixPos = strstr(oldRname, tsdbFilePrefix);
    if (tsdbFilePrefixPos == NULL) continue;

    int32_t tsdbFileVgId = atoi(tsdbFilePrefixPos + 6);
    if (tsdbFileVgId == srcVgId) {
      char *tsdbFileSurfixPos = strstr(tsdbFilePrefixPos, "f");
      if (tsdbFileSurfixPos == NULL) continue;

      tsdbFilePrefixPos[6] = 0;
      snprintf(newRname, TSDB_FILENAME_LEN, "%s%d%s", oldRname, dstVgId, tsdbFileSurfixPos);
      vInfo("vgId:%d, rename file from %s to %s", dstVgId, tsdbFile->rname, newRname);

      ret = tfsRename(pTfs, tsdbFile->rname, newRname);
      if (ret != 0) {
        vInfo("vgId:%d, failed to rename file from %s to %s since %s", dstVgId, tsdbFile->rname, newRname, terrstr());
        tfsClosedir(tsdbDir);
        return ret;
      }
    }
  }

  tfsClosedir(tsdbDir);
  return 0;
}

155 156 157 158 159 160 161 162 163 164 165
int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnodeHashRangeReq *pReq, STfs *pTfs) {
  SVnodeInfo info = {0};
  char       dir[TSDB_FILENAME_LEN] = {0};
  int32_t    ret = 0;

  if (pTfs) {
    snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, srcPath);
  } else {
    snprintf(dir, TSDB_FILENAME_LEN, "%s", srcPath);
  }

S
Shengliang Guan 已提交
166 167
  // todo add stat file to handle exception while vnode open

168 169 170 171 172 173
  ret = vnodeLoadInfo(dir, &info);
  if (ret < 0) {
    vError("vgId:%d, failed to read vnode config from %s since %s", pReq->srcVgId, srcPath, tstrerror(terrno));
    return -1;
  }

174 175
  vInfo("vgId:%d, alter hashrange from [%u, %u] to [%u, %u]", pReq->srcVgId, info.config.hashBegin, info.config.hashEnd,
        pReq->hashBegin, pReq->hashEnd);
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
  info.config.vgId = pReq->dstVgId;
  info.config.hashBegin = pReq->hashBegin;
  info.config.hashEnd = pReq->hashEnd;
  info.config.walCfg.vgId = pReq->dstVgId;

  SSyncCfg *pCfg = &info.config.syncCfg;
  pCfg->myIndex = 0;
  pCfg->replicaNum = 1;
  memset(&pCfg->nodeInfo, 0, sizeof(pCfg->nodeInfo));

  vInfo("vgId:%d, alter vnode replicas to 1", pReq->srcVgId);
  SNodeInfo *pNode = &pCfg->nodeInfo[0];
  pNode->nodePort = tsServerPort;
  tstrncpy(pNode->nodeFqdn, tsLocalFqdn, TSDB_FQDN_LEN);
  (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort);
  vInfo("vgId:%d, ep:%s:%u dnode:%d", pReq->srcVgId, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId);

  info.config.syncCfg = *pCfg;

  ret = vnodeSaveInfo(dir, &info);
  if (ret < 0) {
    vError("vgId:%d, failed to save vnode config since %s", pReq->dstVgId, tstrerror(terrno));
    return -1;
  }

H
Hongze Cheng 已提交
201
  ret = vnodeCommitInfo(dir);
202 203 204 205 206
  if (ret < 0) {
    vError("vgId:%d, failed to commit vnode config since %s", pReq->dstVgId, tstrerror(terrno));
    return -1;
  }

207
  vInfo("vgId:%d, rename %s to %s", pReq->dstVgId, srcPath, dstPath);
S
Shengliang Guan 已提交
208
  ret = vnodeRenameVgroupId(srcPath, dstPath, pReq->srcVgId, pReq->dstVgId, pTfs);
209 210 211 212 213 214
  if (ret < 0) {
    vError("vgId:%d, failed to rename vnode from %s to %s since %s", pReq->dstVgId, srcPath, dstPath,
           tstrerror(terrno));
    return -1;
  }

S
Shengliang Guan 已提交
215
  // todo vnode compact here
S
Shengliang Guan 已提交
216

217 218 219 220
  vInfo("vgId:%d, vnode hashrange is altered", info.config.vgId);
  return 0;
}

S
Shengliang Guan 已提交
221 222 223 224
void vnodeDestroy(const char *path, STfs *pTfs) {
  vInfo("path:%s is removed while destroy vnode", path);
  tfsRmdir(pTfs, path);
}
H
refact  
Hongze Cheng 已提交
225

H
Hongze Cheng 已提交
226 227 228
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
  SVnode    *pVnode = NULL;
  SVnodeInfo info = {0};
S
Shengliang Guan 已提交
229 230 231
  char       dir[TSDB_FILENAME_LEN] = {0};
  char       tdir[TSDB_FILENAME_LEN * 2] = {0};
  int32_t    ret = 0;
H
more  
Hongze Cheng 已提交
232

H
Hongze Cheng 已提交
233 234 235 236 237
  if (pTfs) {
    snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path);
  } else {
    snprintf(dir, TSDB_FILENAME_LEN, "%s", path);
  }
H
Hongze Cheng 已提交
238

H
Hongze Cheng 已提交
239 240
  info.config = vnodeCfgDefault;

H
Hongze Cheng 已提交
241 242 243 244
  // load vnode info
  ret = vnodeLoadInfo(dir, &info);
  if (ret < 0) {
    vError("failed to open vnode from %s since %s", path, tstrerror(terrno));
H
more  
Hongze Cheng 已提交
245 246 247
    return NULL;
  }

248 249 250 251 252 253 254 255 256 257 258 259
  // save vnode info on dnode ep changed
  bool      updated = false;
  SSyncCfg *pCfg = &info.config.syncCfg;
  for (int32_t i = 0; i < pCfg->replicaNum; ++i) {
    SNodeInfo *pNode = &pCfg->nodeInfo[i];
    if (tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort)) {
      updated = true;
    }
  }
  if (updated) {
    vInfo("vgId:%d, save vnode info since dnode info changed", info.config.vgId);
    (void)vnodeSaveInfo(dir, &info);
H
Hongze Cheng 已提交
260
    (void)vnodeCommitInfo(dir);
261 262
  }

H
Hongze Cheng 已提交
263
  // create handle
S
Shengliang Guan 已提交
264
  pVnode = taosMemoryCalloc(1, sizeof(*pVnode) + strlen(path) + 1);
H
more  
Hongze Cheng 已提交
265
  if (pVnode == NULL) {
H
Hongze Cheng 已提交
266
    terrno = TSDB_CODE_OUT_OF_MEMORY;
S
Shengliang Guan 已提交
267
    vError("vgId:%d, failed to open vnode since %s", info.config.vgId, tstrerror(terrno));
H
more  
Hongze Cheng 已提交
268 269 270
    return NULL;
  }

H
Hongze Cheng 已提交
271 272
  pVnode->path = (char *)&pVnode[1];
  strcpy(pVnode->path, path);
H
Hongze Cheng 已提交
273
  pVnode->config = info.config;
H
Hongze Cheng 已提交
274
  pVnode->state.committed = info.state.committed;
H
Hongze Cheng 已提交
275
  pVnode->state.commitTerm = info.state.commitTerm;
H
Hongze Cheng 已提交
276
  pVnode->state.commitID = info.state.commitID;
277 278
  pVnode->state.applied = info.state.committed;
  pVnode->state.applyTerm = info.state.commitTerm;
H
Hongze Cheng 已提交
279 280
  pVnode->pTfs = pTfs;
  pVnode->msgCb = msgCb;
281
  taosThreadMutexInit(&pVnode->lock, NULL);
282
  pVnode->blocked = false;
H
Hongze Cheng 已提交
283

284
  tsem_init(&pVnode->syncSem, 0, 0);
H
Hongze Cheng 已提交
285
  tsem_init(&(pVnode->canCommit), 0, 1);
H
Hongze Cheng 已提交
286 287
  taosThreadMutexInit(&pVnode->mutex, NULL);
  taosThreadCondInit(&pVnode->poolNotEmpty, NULL);
H
Hongze Cheng 已提交
288

289 290
  vnodeUpdCommitSched(pVnode);

H
Hongze Cheng 已提交
291 292
  int8_t rollback = vnodeShouldRollback(pVnode);

H
Hongze Cheng 已提交
293
  // open buffer pool
H
Hongze Cheng 已提交
294
  if (vnodeOpenBufPool(pVnode) < 0) {
S
Shengliang Guan 已提交
295
    vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
H
Hongze Cheng 已提交
296
    goto _err;
H
more  
Hongze Cheng 已提交
297 298
  }

H
Hongze Cheng 已提交
299
  // open meta
H
Hongze Cheng 已提交
300
  if (metaOpen(pVnode, &pVnode->pMeta, rollback) < 0) {
S
Shengliang Guan 已提交
301
    vError("vgId:%d, failed to open vnode meta since %s", TD_VID(pVnode), tstrerror(terrno));
H
Hongze Cheng 已提交
302
    goto _err;
H
refact  
Hongze Cheng 已提交
303 304
  }

H
Hongze Cheng 已提交
305
  // open tsdb
H
Hongze Cheng 已提交
306
  if (!VND_IS_RSMA(pVnode) && tsdbOpen(pVnode, &VND_TSDB(pVnode), VNODE_TSDB_DIR, NULL, rollback) < 0) {
S
Shengliang Guan 已提交
307
    vError("vgId:%d, failed to open vnode tsdb since %s", TD_VID(pVnode), tstrerror(terrno));
308 309 310 311
    goto _err;
  }

  // open sma
H
Hongze Cheng 已提交
312
  if (smaOpen(pVnode, rollback)) {
S
Shengliang Guan 已提交
313
    vError("vgId:%d, failed to open vnode sma since %s", TD_VID(pVnode), tstrerror(terrno));
314
    goto _err;
H
refact  
Hongze Cheng 已提交
315 316
  }

H
Hongze Cheng 已提交
317 318
  // open wal
  sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
wafwerar's avatar
wafwerar 已提交
319
  taosRealPath(tdir, NULL, sizeof(tdir));
320

H
Hongze Cheng 已提交
321
  pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
H
merge  
Hongze Cheng 已提交
322
  if (pVnode->pWal == NULL) {
323
    vError("vgId:%d, failed to open vnode wal since %s. wal:%s", TD_VID(pVnode), tstrerror(terrno), tdir);
H
Hongze Cheng 已提交
324
    goto _err;
H
merge  
Hongze Cheng 已提交
325
  }
H
refact  
Hongze Cheng 已提交
326

H
Hongze Cheng 已提交
327 328
  // open tq
  sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
wafwerar's avatar
wafwerar 已提交
329
  taosRealPath(tdir, NULL, sizeof(tdir));
L
Liu Jicong 已提交
330
  pVnode->pTq = tqOpen(tdir, pVnode);
L
Liu Jicong 已提交
331
  if (pVnode->pTq == NULL) {
S
Shengliang Guan 已提交
332
    vError("vgId:%d, failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
H
Hongze Cheng 已提交
333
    goto _err;
L
Liu Jicong 已提交
334 335
  }

H
Hongze Cheng 已提交
336
  // open query
D
dapan1121 已提交
337
  if (vnodeQueryOpen(pVnode)) {
S
Shengliang Guan 已提交
338
    vError("vgId:%d, failed to open vnode query since %s", TD_VID(pVnode), tstrerror(terrno));
339
    terrno = TSDB_CODE_OUT_OF_MEMORY;
H
Hongze Cheng 已提交
340
    goto _err;
D
dapan1121 已提交
341 342
  }

H
Hongze Cheng 已提交
343 344
  // vnode begin
  if (vnodeBegin(pVnode) < 0) {
S
Shengliang Guan 已提交
345
    vError("vgId:%d, failed to begin since %s", TD_VID(pVnode), tstrerror(terrno));
346
    terrno = TSDB_CODE_OUT_OF_MEMORY;
H
Hongze Cheng 已提交
347 348 349
    goto _err;
  }

350 351
  // open sync
  if (vnodeSyncOpen(pVnode, dir)) {
S
Shengliang Guan 已提交
352
    vError("vgId:%d, failed to open sync since %s", TD_VID(pVnode), tstrerror(terrno));
H
Hongze Cheng 已提交
353 354
    goto _err;
  }
H
Hongze Cheng 已提交
355 356 357 358

  if (rollback) {
    vnodeRollback(pVnode);
  }
H
Hongze Cheng 已提交
359 360 361 362 363 364 365

  return pVnode;

_err:
  if (pVnode->pQuery) vnodeQueryClose(pVnode);
  if (pVnode->pTq) tqClose(pVnode->pTq);
  if (pVnode->pWal) walClose(pVnode->pWal);
366
  if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb);
C
Cary Xu 已提交
367
  if (pVnode->pSma) smaClose(pVnode->pSma);
368
  if (pVnode->pMeta) metaClose(&pVnode->pMeta);
H
Hongze Cheng 已提交
369
  if (pVnode->freeList) vnodeCloseBufPool(pVnode);
C
Cary Xu 已提交
370

H
Hongze Cheng 已提交
371 372 373
  tsem_destroy(&(pVnode->canCommit));
  taosMemoryFree(pVnode);
  return NULL;
H
refact  
Hongze Cheng 已提交
374 375
}

H
Hongze Cheng 已提交
376
void vnodePreClose(SVnode *pVnode) {
D
dapan1121 已提交
377
  vnodeQueryPreClose(pVnode);
H
Hongze Cheng 已提交
378
  vnodeSyncPreClose(pVnode);
D
dapan1121 已提交
379
}
380

381
void vnodePostClose(SVnode *pVnode) { vnodeSyncPostClose(pVnode); }
382

H
Hongze Cheng 已提交
383
void vnodeClose(SVnode *pVnode) {
H
refact  
Hongze Cheng 已提交
384
  if (pVnode) {
385
    tsem_wait(&pVnode->canCommit);
M
Minghao Li 已提交
386
    vnodeSyncClose(pVnode);
D
dapan1121 已提交
387
    vnodeQueryClose(pVnode);
H
Hongze Cheng 已提交
388 389
    walClose(pVnode->pWal);
    tqClose(pVnode->pTq);
390
    if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb);
C
Cary Xu 已提交
391
    smaClose(pVnode->pSma);
392
    if (pVnode->pMeta) metaClose(&pVnode->pMeta);
H
Hongze Cheng 已提交
393
    vnodeCloseBufPool(pVnode);
B
Benguang Zhao 已提交
394 395
    tsem_post(&pVnode->canCommit);

H
Hongze Cheng 已提交
396 397
    // destroy handle
    tsem_destroy(&(pVnode->canCommit));
398
    tsem_destroy(&pVnode->syncSem);
H
Hongze Cheng 已提交
399 400
    taosThreadCondDestroy(&pVnode->poolNotEmpty);
    taosThreadMutexDestroy(&pVnode->mutex);
401
    taosThreadMutexDestroy(&pVnode->lock);
H
Hongze Cheng 已提交
402
    taosMemoryFree(pVnode);
H
refact  
Hongze Cheng 已提交
403
  }
L
Liu Jicong 已提交
404
}
H
Hongze Cheng 已提交
405

406
// start the sync timer after the queue is ready
407
int32_t vnodeStart(SVnode *pVnode) { return vnodeSyncStart(pVnode); }
408 409 410

void vnodeStop(SVnode *pVnode) {}

H
Hongze Cheng 已提交
411 412
int64_t vnodeGetSyncHandle(SVnode *pVnode) { return pVnode->sync; }

H
Hongze Cheng 已提交
413 414 415 416 417 418
void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot) {
  pSnapshot->data = NULL;
  pSnapshot->lastApplyIndex = pVnode->state.committed;
  pSnapshot->lastApplyTerm = pVnode->state.commitTerm;
  pSnapshot->lastConfigIndex = -1;
}