tsdbCommit.c 15.1 KB
Newer Older
H
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 "dev.h"
H
Hongze Cheng 已提交
17

H
Hongze Cheng 已提交
18
// extern dependencies
H
Hongze Cheng 已提交
19 20 21 22 23 24 25 26 27 28 29
typedef struct {
  STsdb *pTsdb;
  // config
  int32_t minutes;
  int8_t  precision;
  int32_t minRow;
  int32_t maxRow;
  int8_t  cmprAlg;
  int8_t  sttTrigger;
  SArray *aTbDataP;
  // context
H
Hongze Cheng 已提交
30 31 32 33 34 35
  TSKEY      nextKey;
  int32_t    fid;
  int32_t    expLevel;
  TSKEY      minKey;
  TSKEY      maxKey;
  STFileSet *pFileSet;
H
Hongze Cheng 已提交
36
  // writer
H
Hongze Cheng 已提交
37 38
  SArray         *aFileOp;
  SSttFileWriter *pWriter;
H
Hongze Cheng 已提交
39
} SCommitter;
H
Hongze Cheng 已提交
40

H
Hongze Cheng 已提交
41
static int32_t open_committer_writer(SCommitter *pCommitter) {
H
Hongze Cheng 已提交
42
  int32_t code = 0;
H
Hongze Cheng 已提交
43 44
  int32_t lino;

H
Hongze Cheng 已提交
45 46
  STsdb *pTsdb = pCommitter->pTsdb;

H
Hongze Cheng 已提交
47
  SSttFileWriterConfig conf = {
H
Hongze Cheng 已提交
48 49 50 51
      .pTsdb = pCommitter->pTsdb,
      .maxRow = pCommitter->maxRow,
      .szPage = pCommitter->pTsdb->pVnode->config.tsdbPageSize,
      .cmprAlg = pCommitter->cmprAlg,
H
Hongze Cheng 已提交
52 53
      .pSkmTb = NULL,
      .pSkmRow = NULL,
H
Hongze Cheng 已提交
54 55
      .aBuf = NULL,
  };
H
Hongze Cheng 已提交
56

H
Hongze Cheng 已提交
57 58
  if (pCommitter->pFileSet) {
    ASSERTS(0, "TODO: Not implemented yet");
H
Hongze Cheng 已提交
59
  } else {
H
Hongze Cheng 已提交
60 61
    conf.file.type = TSDB_FTYPE_STT;

H
Hongze Cheng 已提交
62
    if (tfsAllocDisk(pTsdb->pVnode->pTfs, pCommitter->expLevel, &conf.file.did) < 0) {
H
Hongze Cheng 已提交
63 64 65 66 67 68 69 70 71
      code = TSDB_CODE_FS_NO_VALID_DISK;
      TSDB_CHECK_CODE(code, lino, _exit);
    }

    conf.file.size = 0;
    conf.file.cid = 1;
    conf.file.fid = pCommitter->fid;

    tsdbTFileInit(pTsdb, &conf.file);
H
Hongze Cheng 已提交
72
  }
H
Hongze Cheng 已提交
73 74

  code = tsdbSttFWriterOpen(&conf, &pCommitter->pWriter);
H
Hongze Cheng 已提交
75 76 77 78
  TSDB_CHECK_CODE(code, lino, _exit);

_exit:
  if (code) {
H
Hongze Cheng 已提交
79 80 81 82 83 84 85
    tsdbError(                                            //
        "vgId:%d %s failed at line %d since %s, fid:%d",  //
        TD_VID(pCommitter->pTsdb->pVnode),                //
        __func__,                                         //
        lino,                                             //
        tstrerror(code),                                  //
        pCommitter->fid);
H
Hongze Cheng 已提交
86
  }
H
Hongze Cheng 已提交
87 88 89
  return code;
}

H
Hongze Cheng 已提交
90
static int32_t tsdbCommitWriteTSData(SCommitter *pCommitter, TABLEID *tbid, TSDBROW *pRow) {
H
Hongze Cheng 已提交
91 92 93 94
  int32_t code = 0;
  int32_t lino;

  if (pCommitter->pWriter == NULL) {
H
Hongze Cheng 已提交
95
    code = open_committer_writer(pCommitter);
H
Hongze Cheng 已提交
96 97 98
    TSDB_CHECK_CODE(code, lino, _exit);
  }

H
Hongze Cheng 已提交
99
  code = tsdbSttFWriteTSData(pCommitter->pWriter, tbid, pRow);
H
Hongze Cheng 已提交
100 101 102 103
  TSDB_CHECK_CODE(code, lino, _exit);

_exit:
  if (code) {
H
Hongze Cheng 已提交
104 105 106 107 108
    tsdbError(                                 //
        "vgId:%d failed at line %d since %s",  //
        TD_VID(pCommitter->pTsdb->pVnode),     //
        lino,                                  //
        tstrerror(code));
H
Hongze Cheng 已提交
109
  } else {
H
Hongze Cheng 已提交
110 111 112 113 114 115 116
    tsdbTrace("vgId:%d %s done, fid:%d suid:%" PRId64 " uid:%" PRId64 " ts:%" PRId64 " version:%" PRId64,  //
              TD_VID(pCommitter->pTsdb->pVnode),                                                           //
              __func__,                                                                                    //
              pCommitter->fid,                                                                             //
              tbid->suid,                                                                                  //
              tbid->uid,                                                                                   //
              TSDBROW_KEY(pRow).ts,                                                                        //
H
Hongze Cheng 已提交
117 118
              TSDBROW_KEY(pRow).version);
  }
H
Hongze Cheng 已提交
119
  return 0;
H
Hongze Cheng 已提交
120 121
}

H
Hongze Cheng 已提交
122 123 124 125 126 127 128
static int32_t tsdbCommitWriteDelData(SCommitter *pCommitter, int64_t suid, int64_t uid, int64_t version, int64_t sKey,
                                      int64_t eKey) {
  int32_t code = 0;
  // TODO
  return code;
}

H
Hongze Cheng 已提交
129
static int32_t commit_timeseries_data(SCommitter *pCommitter) {
H
Hongze Cheng 已提交
130 131 132
  int32_t code = 0;
  int32_t lino;

H
Hongze Cheng 已提交
133
  int64_t    nRow = 0;
H
Hongze Cheng 已提交
134 135
  SMemTable *pMem = pCommitter->pTsdb->imem;

H
Hongze Cheng 已提交
136 137 138
  if (pMem->nRow == 0) {  // no time-series data to commit
    goto _exit;
  }
H
Hongze Cheng 已提交
139

H
Hongze Cheng 已提交
140
  TSDBKEY from = {.ts = pCommitter->minKey, .version = VERSION_MIN};
H
Hongze Cheng 已提交
141 142
  for (int32_t iTbData = 0; iTbData < taosArrayGetSize(pCommitter->aTbDataP); iTbData++) {
    STbDataIter iter;
H
Hongze Cheng 已提交
143 144
    STbData    *pTbData = (STbData *)taosArrayGetP(pCommitter->aTbDataP, iTbData);

H
Hongze Cheng 已提交
145 146 147 148 149 150
    tsdbTbDataIterOpen(pTbData, &from, 0, &iter);

    for (TSDBROW *pRow; (pRow = tsdbTbDataIterGet(&iter)) != NULL; tsdbTbDataIterNext(&iter)) {
      TSDBKEY rowKey = TSDBROW_KEY(pRow);

      if (rowKey.ts > pCommitter->maxKey) {
H
Hongze Cheng 已提交
151
        pCommitter->nextKey = TMIN(pCommitter->nextKey, rowKey.ts);
H
Hongze Cheng 已提交
152 153 154
        break;
      }

H
Hongze Cheng 已提交
155
      code = tsdbCommitWriteTSData(pCommitter, (TABLEID *)pTbData, pRow);
H
Hongze Cheng 已提交
156
      TSDB_CHECK_CODE(code, lino, _exit);
H
Hongze Cheng 已提交
157 158

      nRow++;
H
Hongze Cheng 已提交
159 160 161 162 163
    }
  }

_exit:
  if (code) {
H
Hongze Cheng 已提交
164 165 166 167 168 169
    tsdbError(                                    //
        "vgId:%d %s failed at line %d since %s",  //
        TD_VID(pCommitter->pTsdb->pVnode),        //
        __func__,                                 //
        lino,                                     //
        tstrerror(code));
H
Hongze Cheng 已提交
170
  } else {
H
Hongze Cheng 已提交
171 172 173 174 175 176
    tsdbDebug(                                    //
        "vgId:%d %s done, fid:%d nRow:%" PRId64,  //
        TD_VID(pCommitter->pTsdb->pVnode),        //
        __func__,                                 //
        pCommitter->fid,                          //
        nRow);
H
Hongze Cheng 已提交
177 178 179 180
  }
  return code;
}

H
Hongze Cheng 已提交
181
static int32_t commit_delete_data(SCommitter *pCommitter) {
H
Hongze Cheng 已提交
182 183 184
  int32_t code = 0;
  int32_t lino;

H
Hongze Cheng 已提交
185
  ASSERTS(0, "TODO: Not implemented yet");
H
Hongze Cheng 已提交
186

H
Hongze Cheng 已提交
187
  int64_t    nDel = 0;
H
Hongze Cheng 已提交
188 189
  SMemTable *pMem = pCommitter->pTsdb->imem;

H
Hongze Cheng 已提交
190 191 192
  if (pMem->nDel == 0) {  // no del data
    goto _exit;
  }
H
Hongze Cheng 已提交
193 194 195 196 197

  for (int32_t iTbData = 0; iTbData < taosArrayGetSize(pCommitter->aTbDataP); iTbData++) {
    STbData *pTbData = (STbData *)taosArrayGetP(pCommitter->aTbDataP, iTbData);

    for (SDelData *pDelData = pTbData->pHead; pDelData; pDelData = pDelData->pNext) {
H
Hongze Cheng 已提交
198 199 200 201 202
      if (pDelData->eKey < pCommitter->minKey) continue;
      if (pDelData->sKey > pCommitter->maxKey) {
        pCommitter->nextKey = TMIN(pCommitter->nextKey, pDelData->sKey);
        continue;
      }
H
Hongze Cheng 已提交
203

H
Hongze Cheng 已提交
204 205
      code = tsdbCommitWriteDelData(pCommitter, pTbData->suid, pTbData->uid, pDelData->version,
                                    pDelData->sKey /* TODO */, pDelData->eKey /* TODO */);
H
Hongze Cheng 已提交
206 207 208 209 210 211 212 213 214 215 216 217 218 219
      TSDB_CHECK_CODE(code, lino, _exit);
    }
  }

_exit:
  if (code) {
    tsdbError("vgId:%d failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), lino, tstrerror(code));
  } else {
    tsdbDebug("vgId:%d %s done, fid:%d nDel:%" PRId64, TD_VID(pCommitter->pTsdb->pVnode), __func__, pCommitter->fid,
              pMem->nDel);
  }
  return code;
}

H
Hongze Cheng 已提交
220
static int32_t start_commit_file_set(SCommitter *pCommitter) {
H
Hongze Cheng 已提交
221 222 223 224
  pCommitter->fid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision);
  tsdbFidKeyRange(pCommitter->fid, pCommitter->minutes, pCommitter->precision, &pCommitter->minKey,
                  &pCommitter->maxKey);
  pCommitter->expLevel = tsdbFidLevel(pCommitter->fid, &pCommitter->pTsdb->keepCfg, taosGetTimestampSec());
H
Hongze Cheng 已提交
225
  pCommitter->nextKey = TSKEY_MAX;
H
Hongze Cheng 已提交
226

H
Hongze Cheng 已提交
227 228
  pCommitter->pFileSet = NULL;  // TODO: need to search the file system

H
Hongze Cheng 已提交
229 230 231 232 233 234 235 236
  tsdbDebug(                                                                        //
      "vgId:%d %s done, fid:%d minKey:%" PRId64 " maxKey:%" PRId64 " expLevel:%d",  //
      TD_VID(pCommitter->pTsdb->pVnode),                                            //
      __func__,                                                                     //
      pCommitter->fid,                                                              //
      pCommitter->minKey,                                                           //
      pCommitter->maxKey,                                                           //
      pCommitter->expLevel);
H
Hongze Cheng 已提交
237
  return 0;
H
Hongze Cheng 已提交
238 239
}

H
Hongze Cheng 已提交
240
static int32_t end_commit_file_set(SCommitter *pCommitter) {
H
Hongze Cheng 已提交
241
  int32_t code = 0;
H
Hongze Cheng 已提交
242
  int32_t lino;
H
Hongze Cheng 已提交
243

H
Hongze Cheng 已提交
244 245 246 247 248 249 250 251
  if (pCommitter->pWriter == NULL) return 0;

  struct SFileOp *pFileOp = taosArrayReserve(pCommitter->aFileOp, 1);
  if (pFileOp == NULL) {
    code = TSDB_CODE_OUT_OF_MEMORY;
    TSDB_CHECK_CODE(code, lino, _exit);
  }

H
Hongze Cheng 已提交
252 253 254 255 256 257 258
  TSDB_CHECK_CODE(                 //
      code = tsdbSttFWriterClose(  //
          &pCommitter->pWriter,    //
          0,                       //
          pFileOp),                //
      lino,                        //
      _exit);
H
Hongze Cheng 已提交
259 260 261

_exit:
  if (code) {
H
Hongze Cheng 已提交
262 263 264 265 266
    tsdbError(                                 //
        "vgId:%d failed at line %d since %s",  //
        TD_VID(pCommitter->pTsdb->pVnode),     //
        lino,                                  //
        tstrerror(code));
H
Hongze Cheng 已提交
267
  } else {
H
Hongze Cheng 已提交
268 269 270 271 272
    tsdbDebug(                              //
        "vgId:%d %s done, fid:%d",          //
        TD_VID(pCommitter->pTsdb->pVnode),  //
        __func__,                           //
        pCommitter->fid);
H
Hongze Cheng 已提交
273 274 275 276
  }
  return code;
}

H
Hongze Cheng 已提交
277
static int32_t commit_next_file_set(SCommitter *pCommitter) {
H
Hongze Cheng 已提交
278 279 280
  int32_t code = 0;
  int32_t lino = 0;

H
Hongze Cheng 已提交
281
  // fset commit start
H
Hongze Cheng 已提交
282
  code = start_commit_file_set(pCommitter);
H
Hongze Cheng 已提交
283
  TSDB_CHECK_CODE(code, lino, _exit);
H
Hongze Cheng 已提交
284

H
Hongze Cheng 已提交
285
  // commit fset
H
Hongze Cheng 已提交
286
  code = commit_timeseries_data(pCommitter);
H
Hongze Cheng 已提交
287 288
  TSDB_CHECK_CODE(code, lino, _exit);

H
Hongze Cheng 已提交
289
  /* TODO
H
Hongze Cheng 已提交
290
  code = commit_delete_data(pCommitter);
H
Hongze Cheng 已提交
291
  TSDB_CHECK_CODE(code, lino, _exit);
H
Hongze Cheng 已提交
292
  */
H
Hongze Cheng 已提交
293 294

  // fset commit end
H
Hongze Cheng 已提交
295
  code = end_commit_file_set(pCommitter);
H
Hongze Cheng 已提交
296
  TSDB_CHECK_CODE(code, lino, _exit);
H
Hongze Cheng 已提交
297 298 299

_exit:
  if (code) {
H
Hongze Cheng 已提交
300 301 302 303 304 305
    tsdbError(                                    //
        "vgId:%d %s failed at line %d since %s",  //
        TD_VID(pCommitter->pTsdb->pVnode),        //
        __func__,                                 //
        lino,                                     //
        tstrerror(code));
H
Hongze Cheng 已提交
306 307 308 309
  }
  return code;
}

H
Hongze Cheng 已提交
310
static int32_t open_committer(STsdb *pTsdb, SCommitInfo *pInfo, SCommitter *pCommitter) {
H
Hongze Cheng 已提交
311
  int32_t code = 0;
H
Hongze Cheng 已提交
312
  int32_t lino;
H
Hongze Cheng 已提交
313

H
Hongze Cheng 已提交
314
  // set config
H
Hongze Cheng 已提交
315 316
  memset(pCommitter, 0, sizeof(SCommitter));
  pCommitter->pTsdb = pTsdb;
H
Hongze Cheng 已提交
317 318 319 320 321
  pCommitter->minutes = pTsdb->keepCfg.days;
  pCommitter->precision = pTsdb->keepCfg.precision;
  pCommitter->minRow = pInfo->info.config.tsdbCfg.minRows;
  pCommitter->maxRow = pInfo->info.config.tsdbCfg.maxRows;
  pCommitter->cmprAlg = pInfo->info.config.tsdbCfg.compression;
H
Hongze Cheng 已提交
322
  pCommitter->sttTrigger = 7;  // TODO
H
Hongze Cheng 已提交
323 324 325 326 327 328

  pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem);
  if (pCommitter->aTbDataP == NULL) {
    code = TSDB_CODE_OUT_OF_MEMORY;
    TSDB_CHECK_CODE(code, lino, _exit);
  }
H
Hongze Cheng 已提交
329
  pCommitter->aFileOp = taosArrayInit(16, sizeof(struct SFileOp));
H
Hongze Cheng 已提交
330 331 332 333
  if (pCommitter->aFileOp == NULL) {
    code = TSDB_CODE_OUT_OF_MEMORY;
    TSDB_CHECK_CODE(code, lino, _exit);
  }
H
Hongze Cheng 已提交
334

H
Hongze Cheng 已提交
335 336
  // start loop
  pCommitter->nextKey = pTsdb->imem->minKey;  // TODO
H
Hongze Cheng 已提交
337 338 339

_exit:
  if (code) {
H
Hongze Cheng 已提交
340 341 342 343 344 345
    tsdbError(                                    //
        "vgId:%d %s failed at line %d since %s",  //
        TD_VID(pTsdb->pVnode),                    //
        __func__,                                 //
        lino,                                     //
        tstrerror(code));
H
Hongze Cheng 已提交
346
  } else {
H
Hongze Cheng 已提交
347 348 349 350
    tsdbDebug(                  //
        "vgId:%d %s done",      //
        TD_VID(pTsdb->pVnode),  //
        __func__);
H
Hongze Cheng 已提交
351 352 353 354
  }
  return code;
}

H
Hongze Cheng 已提交
355
static int32_t close_committer(SCommitter *pCommiter, int32_t eno) {
H
Hongze Cheng 已提交
356
  int32_t code = 0;
H
Hongze Cheng 已提交
357 358
  int32_t lino;

H
Hongze Cheng 已提交
359
  if (eno == 0) {
H
Hongze Cheng 已提交
360 361 362 363 364
    TSDB_CHECK_CODE(                //
        code = tsdbFSEditBegin(     //
            pCommiter->pTsdb->pFS,  //
            pCommiter->aFileOp,     //
            TSDB_FEDIT_COMMIT),
H
Hongze Cheng 已提交
365 366 367 368 369
        lino,  //
        _exit);
  } else {
    ASSERTS(0, "TODO: Not implemented yet");
  }
H
Hongze Cheng 已提交
370

H
Hongze Cheng 已提交
371 372
  // TODO: clear the committer

H
Hongze Cheng 已提交
373
_exit:
H
Hongze Cheng 已提交
374 375 376 377 378 379 380 381 382 383 384 385 386
  if (code) {
    tsdbError(                                    //
        "vgId:%d %s failed at line %d since %s",  //
        TD_VID(pCommiter->pTsdb->pVnode),         //
        __func__,                                 //
        lino,                                     //
        tstrerror(code));
  } else {
    tsdbDebug(                             //
        "vgId:%d %s done",                 //
        TD_VID(pCommiter->pTsdb->pVnode),  //
        __func__);
  }
H
Hongze Cheng 已提交
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
  return code;
}

int32_t tsdbPreCommit(STsdb *pTsdb) {
  taosThreadRwlockWrlock(&pTsdb->rwLock);
  ASSERT(pTsdb->imem == NULL);
  pTsdb->imem = pTsdb->mem;
  pTsdb->mem = NULL;
  taosThreadRwlockUnlock(&pTsdb->rwLock);
  return 0;
}

int32_t tsdbCommitBegin(STsdb *pTsdb, SCommitInfo *pInfo) {
  if (!pTsdb) return 0;

  int32_t    code = 0;
  int32_t    lino = 0;
H
Hongze Cheng 已提交
404
  SMemTable *pMem = pTsdb->imem;
H
Hongze Cheng 已提交
405

H
Hongze Cheng 已提交
406
  if (pMem->nRow == 0 && pMem->nDel == 0) {
H
Hongze Cheng 已提交
407 408 409
    taosThreadRwlockWrlock(&pTsdb->rwLock);
    pTsdb->imem = NULL;
    taosThreadRwlockUnlock(&pTsdb->rwLock);
H
Hongze Cheng 已提交
410 411 412
    tsdbUnrefMemTable(pMem, NULL, true);
  } else {
    SCommitter committer;
H
Hongze Cheng 已提交
413

H
Hongze Cheng 已提交
414
    code = open_committer(pTsdb, pInfo, &committer);
H
Hongze Cheng 已提交
415
    TSDB_CHECK_CODE(code, lino, _exit);
H
Hongze Cheng 已提交
416

H
Hongze Cheng 已提交
417
    while (committer.nextKey != TSKEY_MAX) {
H
Hongze Cheng 已提交
418
      code = commit_next_file_set(&committer);
H
Hongze Cheng 已提交
419
      if (code) break;
H
Hongze Cheng 已提交
420
    }
H
Hongze Cheng 已提交
421

H
Hongze Cheng 已提交
422
    code = close_committer(&committer, code);
H
Hongze Cheng 已提交
423 424
    TSDB_CHECK_CODE(code, lino, _exit);
  }
H
Hongze Cheng 已提交
425 426 427

_exit:
  if (code) {
H
Hongze Cheng 已提交
428 429 430 431 432
    tsdbError("vgId:%d %s failed at line %d since %s",  //
              TD_VID(pTsdb->pVnode),                    //
              __func__,                                 //
              lino,                                     //
              tstrerror(code));
H
Hongze Cheng 已提交
433
  } else {
H
Hongze Cheng 已提交
434 435 436 437
    tsdbInfo("vgId:%d %s done, nRow:%" PRId64 " nDel:%" PRId64,  //
             TD_VID(pTsdb->pVnode),                              //
             __func__,                                           //
             pMem->nRow,                                         //
H
Hongze Cheng 已提交
438
             pMem->nDel);
H
Hongze Cheng 已提交
439 440 441 442
  }
  return code;
}

H
Hongze Cheng 已提交
443 444 445 446 447 448 449 450
int32_t tsdbCommitCommit(STsdb *pTsdb) {
  int32_t    code = 0;
  int32_t    lino = 0;
  SMemTable *pMemTable = pTsdb->imem;

  // lock
  taosThreadRwlockWrlock(&pTsdb->rwLock);

H
Hongze Cheng 已提交
451
  code = tsdbFSEditCommit(pTsdb->pFS);
H
Hongze Cheng 已提交
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
  if (code) {
    taosThreadRwlockUnlock(&pTsdb->rwLock);
    TSDB_CHECK_CODE(code, lino, _exit);
  }

  pTsdb->imem = NULL;

  // unlock
  taosThreadRwlockUnlock(&pTsdb->rwLock);
  if (pMemTable) {
    tsdbUnrefMemTable(pMemTable, NULL, true);
  }

_exit:
  if (code) {
    tsdbError("vgId:%d, %s failed at line %d since %s",  //
              TD_VID(pTsdb->pVnode),                     //
              __func__,                                  //
              lino,                                      //
              tstrerror(code));
  } else {
    tsdbInfo("vgId:%d %s done",  //
             TD_VID(pTsdb->pVnode), __func__);
  }
  return code;
}

int32_t tsdbCommitAbort(STsdb *pTsdb) {
  int32_t code = 0;
  int32_t lino = 0;

H
Hongze Cheng 已提交
483
  code = tsdbFSEditAbort(pTsdb->pFS);
H
Hongze Cheng 已提交
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
  TSDB_CHECK_CODE(code, lino, _exit);

_exit:
  if (code) {
    tsdbError("vgId:%d, %s failed at line %d since %s",  //
              TD_VID(pTsdb->pVnode),                     //
              __func__,                                  //
              lino,                                      //
              tstrerror(code));
  } else {
    tsdbInfo("vgId:%d %s done",      //
             TD_VID(pTsdb->pVnode),  //
             __func__);
  }
  return code;
}