예제 #1
0
    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++;
        }
    }
예제 #2
0
파일: verifylog.cpp 프로젝트: iMax3060/zero
void VerifyHandler::checkAlloc(logrec_t& r)
{
    auto lsn = r.lsn();
    PageID pid = *((PageID*) (r.data_ssx()));
    if (r.type() == logrec_t::t_alloc_page) {
        if (allocatedPages.find(pid) != allocatedPages.end()) {
            std::cout << "on " << lsn
                << " alloc_page of pid " << pid
                << " which is already allocated" << std::endl;
            w_assert0(false);
        }
        allocatedPages.insert(pid);
    }
    else if (r.type() == logrec_t::t_dealloc_page) {
        if (allocatedPages.find(pid) == allocatedPages.end()) {
            std::cout << "on " << lsn
                << " dealloc_page of pid " << pid
                << " which is not allocated" << std::endl;
            w_assert0(false);
        }
        allocatedPages.erase(pid);
    }
    else {
        std::cout << "on " << lsn
            << " update on alloc pid " << r.pid()
            << " but invalid logrec type " << r.type_str()
            << std::endl;
        w_assert0(false);
    }
}
예제 #3
0
파일: verifylog.cpp 프로젝트: iMax3060/zero
void VerifyHandler::invoke(logrec_t& r)
{
    w_assert0(r.valid_header());

    lsn_t lsn = r.lsn();
    PageID pid = r.pid();

    if (r.is_redo()) {
        checkRedo(r, pid, lsn, r.page_prev_lsn());

        if (r.is_multi_page()) {
            checkRedo(r, r.pid2(), lsn, r.page2_prev_lsn());
        }

        if (alloc_cache_t::is_alloc_pid(pid)) {
            // checkAlloc(r);
        }
    }

    if (merge) {
        w_assert0(pid >= lastPID);
        if (pid == lastPID) {
            w_assert0(lsn > lastLSN);
        }
        w_assert0(merge || lsn >= minLSN);
        w_assert0(merge || lsn <= maxLSN);
    }

    lastLSN = lsn;
    lastPID = pid;

    count++;
}
예제 #4
0
 virtual void invoke(logrec_t& r)
 {
     std::cout << r.lsn().hi()
         << '\t' << r.lsn().lo()
         << '\t' << r.pid() << std::endl;
 }