Skip to content
This repository was archived by the owner on Feb 14, 2026. It is now read-only.
This repository was archived by the owner on Feb 14, 2026. It is now read-only.

Not latching cb when pinning in page_cleaner (a.k.a. finally figure out pin/unpin!) #30

Description

@llersch

I guess that in order to call pin()/unpin() in a control block, the latch must be held, otherwise there is no synchronization with other parts of the code that manually set the pin_cnt of a control block. I have tried to replace pin()/unpin() for latch_acquire()/latch_release() but I was getting some weird runtime error related with lock_elision, maybe this is an architecture issue.

Anyway, maybe a proper implementation of the buffer manager can ignore the pin()/unpin() protocol and rely only on shared latches (rwlock, for example).

void page_cleaner_base::flush_workspace(size_t from, size_t to)
{
    if (from - to == 0) {
        return;
    }

    // Flush log to guarantee WAL property
    W_COERCE(smlevel_0::log->flush(_clean_lsn));

    W_COERCE(smlevel_0::vol->write_many_pages(
                _workspace[from].pid, &(_workspace[from]), to - from));

    for (size_t i = from; i < to; ++i) {
        bf_idx idx = _workspace_cb_indexes[i];
        bf_tree_cb_t &cb = _bufferpool->get_cb(idx);

        // Assertion below may fail for decoupled cleaner, and it's OK
        // w_assert1(i == from || _workspace[i].pid == _workspace[i - 1].pid + 1);

        cb.pin();
        if (cb._pid == _workspace[i].pid && cb.get_clean_lsn() < _clean_lsn) {
            cb.set_clean_lsn(_clean_lsn);
        }
        cb.unpin();
    }
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions