Skip to content

Thread PageMut lifetime through access guards and builders#1119

Closed
cberner wants to merge 1 commit intomasterfrom
codex/add-lifetime-parameter-to-pagemut
Closed

Thread PageMut lifetime through access guards and builders#1119
cberner wants to merge 1 commit intomasterfrom
codex/add-lifetime-parameter-to-pagemut

Conversation

@cberner
Copy link
Copy Markdown
Owner

@cberner cberner commented Apr 1, 2026

Motivation

  • Ensure the logical lifetime of mutable pages is represented in types so AccessGuard/AccessGuardMut lifetimes correctly track the PageMut they reference.
  • Replace a standalone _lifetime: PhantomData<&'a ()> on guards with a PageMut<'a> so lifetimes are tied to the actual mutable page handle inside EitherPage.
  • Fix several related lifetime/borrowing issues by consistently threading the PageMut lifetime through functions that construct or return mutable pages.

Description

  • Added a lifetime parameter to PageMut and a PhantomData field to carry that lifetime in src/tree_store/page_store/base.rs.
  • Made EitherPage generic over the page lifetime and stored PageMut<'a> inside it, and updated AccessGuard<'a, V> to hold EitherPage<'a> in src/tree_store/btree_base.rs.
  • Propagated the PageMut<'a> lifetime into AccessGuardMut<'a, V> and AccessGuardMutInPlace<'a, V> and adjusted their constructors and fields accordingly in src/tree_store/btree_base.rs.
  • Kept mutable page allocation and retrieval APIs returning PageMut<'static> so mutable handles remain moveable without tying them to a borrow of TransactionalMemory, updating src/tree_store/page_store/page_manager.rs.
  • Updated B-tree helpers and mutation callbacks to use the new PageMut typing (notably dirty_leaf_visitor, get_mut_helper, and insert_inplace_helper) in src/tree_store/btree.rs and src/tree_store/btree_mutator.rs.
  • Aligned builder return types to PageMut<'static> for leaf/branch builders to match the new model in src/tree_store/btree_base.rs.
  • Files changed: src/tree_store/page_store/base.rs, src/tree_store/page_store/page_manager.rs, src/tree_store/btree_base.rs, src/tree_store/btree.rs, and src/tree_store/btree_mutator.rs.

Testing

  • Ran the full test suite with cargo test -q and all automated tests completed successfully.

Codex Task

@cberner cberner closed this Apr 1, 2026
@cberner cberner deleted the codex/add-lifetime-parameter-to-pagemut branch April 1, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant