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

Refactor the __upd_alloc_tombstone() according to the new use in durable history

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT10.0.0, 4.4.0-rc0, 4.7.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • 3
    • Storage Engines 2020-02-24

      As part of rollback to stable operation, we create an update and appended it to the update list to abort the on-disk newer updates than the stable timestamp. There exists a function __upd_alloc_tombstone and it can be refactored as attached change to reduce the code duplication.

      *** ../include/txn.i    Wed Feb 12 00:35:45 2020
      --- -   Wed Feb 12 01:19:14 2020
      *************** 
      *** 756,776 ****
        } 
          
        /*
      !  * __upd_alloc_tombstone --
      !  *     Allocate a tombstone update at a given transaction id and timestamp.
         */    
        static inline int
      ! __upd_alloc_tombstone(
      !   WT_SESSION_IMPL *session, WT_UPDATE **updp, uint64_t txnid, wt_timestamp_t start_ts)
        { 
      !     size_t size;
      
      !     WT_RET(__wt_update_alloc(session, NULL, updp, &size, WT_UPDATE_TOMBSTONE));
      !     (*updp)->txnid = txnid;
      !     /* FIXME: Reevaluate this as part of PM-1524. */
      !     (*updp)->durable_ts = (*updp)->start_ts = start_ts;
      !     F_SET(*updp, WT_UPDATE_RESTORED_FROM_DISK);
      !     return (0);
        }   
            
        /*  
      --- 756,779 ----
        } 
          
        /*
      !  * __wt_upd_alloc_tombstone --
      !  *     Allocate a tombstone update with default values.
         */
        static inline int
      ! __wt_upd_alloc_tombstone(WT_SESSION_IMPL *session, WT_UPDATE **updp)
        {
      !     size_t notused;
      
      !     /*
      !      * The underlying allocation code clears memory, which is the equivalent of setting:
      !      *
      !      *    WT_UPDATE.txnid = WT_TXN_NONE;
      !      *    WT_UPDATE.durable_ts = WT_TS_NONE;
      !      *    WT_UPDATE.start_ts = WT_TS_NONE;
      !      *    WT_UPDATE.prepare_state = WT_PREPARE_INIT;
      !      *    WT_UPDATE.flags = 0;
      !      */
      !     return (__wt_update_alloc(session, NULL, updp, &notused, WT_UPDATE_TOMBSTONE));
        }
      
        /*
      ***************
      *** 825,834 ****
                return (0);
      
            /* If there is no ondisk value, there can't be anything in the history store either. */
      !     if (cbt->ref->page->dsk == NULL || cbt->slot == UINT32_MAX) {
      !         WT_RET(__upd_alloc_tombstone(session, updp, WT_TXN_NONE, WT_TS_NONE));
      !         return (0);
      !     }
      
            buf.data = NULL;
            buf.size = 0;
      --- 828,835 ----
                return (0);
      
            /* If there is no ondisk value, there can't be anything in the history store either. */
      !     if (cbt->ref->page->dsk == NULL || cbt->slot == UINT32_MAX)
      !         return (__wt_upd_alloc_tombstone(session, updp));
      
            buf.data = NULL;
            buf.size = 0;
      ***************
      *** 855,861 ****
             */
            if (stop.txnid != WT_TXN_MAX && stop.timestamp != WT_TS_MAX && !WT_IS_HS(S2BT(session)) &&
              __wt_txn_visible(session, stop.txnid, stop.timestamp)) {
      !         WT_RET(__upd_alloc_tombstone(session, updp, stop.txnid, stop.timestamp));
                return (0);
            }
      
      --- 856,867 ----
             */
            if (stop.txnid != WT_TXN_MAX && stop.timestamp != WT_TS_MAX && !WT_IS_HS(S2BT(session)) &&
              __wt_txn_visible(session, stop.txnid, stop.timestamp)) {
      !         WT_RET(__wt_upd_alloc_tombstone(session, updp));
      !
      !       (*updp)->txnid = stop.txnid;
      !       /* FIXME: Reevaluate this as part of PM-1524. */
      !       (*updp)->durable_ts = (*updp)->start_ts = stop.timestamp;
      !       F_SET(*updp, WT_UPDATE_RESTORED_FROM_DISK);
                return (0);
            }
      

            Assignee:
            haribabu.kommi@mongodb.com Haribabu Kommi
            Reporter:
            haribabu.kommi@mongodb.com Haribabu Kommi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: