virtual void invoke(logrec_t& r) { // Dump stats on each tick log record if (r.type() == logrec_t::t_tick_sec || r.type() == logrec_t::t_tick_msec) { dumpStats(r.lsn()); return; } // Code copied from chkpt_t::scan_log if (r.is_redo()) { // Ignore metadata pages if (r.pid() % alloc_cache_t::extent_size == 0 || r.pid() == stnode_page::stpid) { return; } lsn_t lsn = r.lsn(); w_assert0(r.is_redo()); chkpt.mark_page_dirty(r.pid(), lsn, lsn); if (r.is_multi_page()) { w_assert0(r.pid2() != 0); chkpt.mark_page_dirty(r.pid2(), lsn, lsn); } updates++; } else if (r.type() == logrec_t::t_page_write) { char* pos = r.data(); PageID pid = *((PageID*) pos); pos += sizeof(PageID); lsn_t clean_lsn = *((lsn_t*) pos); pos += sizeof(lsn_t); uint32_t count = *((uint32_t*) pos); PageID end = pid + count; while (pid < end) { chkpt.mark_page_clean(pid, clean_lsn); pid++; } page_writes += count; } else if (r.type() == logrec_t::t_xct_end) { commits++; } }
void chkpt_t::acquire_lock(logrec_t& r) { w_assert1(is_xct_active(r.tid())); w_assert1(!r.is_single_sys_xct()); w_assert1(!r.is_multi_page()); w_assert1(!r.is_cpsn()); w_assert1(r.is_page_update()); switch (r.type()) { case logrec_t::t_btree_insert: case logrec_t::t_btree_insert_nonghost: { btree_insert_t* dp = (btree_insert_t*) r.data(); w_keystr_t key; key.construct_from_keystr(dp->data, dp->klen); okvl_mode mode = btree_impl::create_part_okvl(okvl_mode::X, key); lockid_t lid (r.stid(), (const unsigned char*) key.buffer_as_keystr(), key.get_length_as_keystr()); add_lock(r.tid(), mode, lid.hash()); } break; case logrec_t::t_btree_update: { btree_update_t* dp = (btree_update_t*) r.data(); w_keystr_t key; key.construct_from_keystr(dp->_data, dp->_klen); okvl_mode mode = btree_impl::create_part_okvl(okvl_mode::X, key); lockid_t lid (r.stid(), (const unsigned char*) key.buffer_as_keystr(), key.get_length_as_keystr()); add_lock(r.tid(), mode, lid.hash()); } break; case logrec_t::t_btree_overwrite: { btree_overwrite_t* dp = (btree_overwrite_t*) r.data(); w_keystr_t key; key.construct_from_keystr(dp->_data, dp->_klen); okvl_mode mode = btree_impl::create_part_okvl(okvl_mode::X, key); lockid_t lid (r.stid(), (const unsigned char*) key.buffer_as_keystr(), key.get_length_as_keystr()); add_lock(r.tid(), mode, lid.hash()); } break; case logrec_t::t_btree_ghost_mark: { btree_ghost_t* dp = (btree_ghost_t*) r.data(); for (size_t i = 0; i < dp->cnt; ++i) { w_keystr_t key (dp->get_key(i)); okvl_mode mode = btree_impl::create_part_okvl(okvl_mode::X, key); lockid_t lid (r.stid(), (const unsigned char*) key.buffer_as_keystr(), key.get_length_as_keystr()); add_lock(r.tid(), mode, lid.hash()); } } break; case logrec_t::t_btree_ghost_reserve: { btree_ghost_reserve_t* dp = (btree_ghost_reserve_t*) r.data(); w_keystr_t key; key.construct_from_keystr(dp->data, dp->klen); okvl_mode mode = btree_impl::create_part_okvl(okvl_mode::X, key); lockid_t lid (r.stid(), (const unsigned char*) key.buffer_as_keystr(), key.get_length_as_keystr()); add_lock(r.tid(), mode, lid.hash()); } break; default: w_assert0(r.type() == logrec_t::t_page_img_format); break; } return; }