Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-1872

log truncation code

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • WT2.6.0
    • Affects Version/s: None
    • Component/s: None

      @sueloverso, I'm confused by this code in __log_truncate:

      /*
       * Truncate the log file to the given LSN.
       */
      WT_ERR(__log_openfile(session, 0, &log_fh, file_prefix, lsn->file));
      WT_ERR(__wt_ftruncate(session, log_fh, lsn->offset));
      tmp_fh = log_fh;
      log_fh = NULL;
      WT_ERR(__wt_fsync(session, tmp_fh));
      WT_ERR(__wt_close(session, &tmp_fh));
      

      Why are we copying log_fh to tmp_fh, then closing tmp_fh?

      If it's got something to do with the error path, I think it's not right, because if the *wt_fsync fails, then we won't close the file in the error path. I think it's safe to call *wt_close multiple times:

      567c567
      <       WT_FH *log_fh, *tmp_fh;
      ---
      >       WT_FH *log_fh;
      584,587c584,585
      <       tmp_fh = log_fh;
      <       log_fh = NULL;
      <       WT_ERR(__wt_fsync(session, tmp_fh));
      <       WT_ERR(__wt_close(session, &tmp_fh));
      ---
      >       WT_ERR__wt_fsync(session, log_fh);
      >       WT_ERR(__wt_close(session, &log_fh));
      608,611c606,607
      <                       tmp_fh = log_fh;
      <                       log_fh = NULL;
      <                       WT_ERR(__wt_fsync(session, tmp_fh));
      <                       WT_ERR(__wt_close(session, &tmp_fh));
      ---
      >                       WT_ERR(__wt_fsync(session, log_fh);
      >                       WT_ERR(__wt_close(session, &log_fh));
      

            Assignee:
            sue.loverso@mongodb.com Susan LoVerso
            Reporter:
            keith.bostic@mongodb.com Keith Bostic (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: