Skip to content

Make the FlushPage documentation more specific #755

Open
@connortsui20

Description

@connortsui20

Some students (both on Piazza and in OH) have misinterpreted the FlushPage documentation to mean that we want to evict the entire page from memory, rather than just sync to disk. Since it's not explicitly stated otherwise, we should probably add that documentation change in.

Additionally, the FlushPage API makes it possible for someone to implement it incorrectly with a race condition: If someone holds a WritePageGuard and is modifying the page, an incorrect FlushPage could flush inconsistent state out to disk.

Some thoughts: https://piazza.com/class/lzk4t7ue1bu5ph/post/208

I think the ideal solution is somewhere in between. We could have FlushPage methods on both ReadPageGuard and WritePageGuard that can safely flush to disk, as well as methods on the buffer pool manager that both “eagerly” flush to disk and safely flush to disk after taking the latch on the page we want to flush (and two methods on the BPM for flushing all pages).

What my implementation does is only flush in the case that the flushing thread is the only thread that has access to the page, delaying the flush to another time. Is this a good solution? No, but it is not unsafe. If I wanted to be more correct, I could also set a flag during FlushPage that notifies any current threads accessing the page that a flush request has occurred, and now it is their job to flush safely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions