Skip to content

Fork of a fork (nested fork) errors on read: LanceError(IO) Object not found #103

Description

@milliondreams

Summary

Building a fork from a fork session (a nested fork, fork.fork("y").build()) produces a fork
that cannot be read — querying it raises a LanceError(IO).

Environment

  • uni-db 2.2.5 (PyPI), Python 3.12, Linux
  • uni_db.Uni.in_memory()

Expected

A fork of a fork branches from the parent fork's visible state and can be read like any other fork —
the natural shape for tree-structured hypotheticals (MCTS rollouts, nested ABM ticks, nested
ASSUME).

Actual (2.2.5)

import uni_db

uni = uni_db.Uni.in_memory()
s = uni.session()
with s.tx() as tx:
    tx.execute("CREATE (:A {k: 1})-[:R {key: 11}]->(:B {k: 2})")
    tx.commit()

fork = s.fork("x").build()
print(fork.query("MATCH (a:A) RETURN count(a) AS c")[0]["c"])   # 1 — first-level fork is fine

nested = fork.fork("y").build()
print(nested.query("MATCH (a:A) RETURN count(a) AS c")[0]["c"])  # raises

Error:

uni_db.UniQueryError: Query error: Execution error: Failed to collect scan results:
Wrapped error: LanceError(IO): Generic N/A error: Cloned error: Cloned error:
LanceError(IO): Object [not found]

Standalone repro (only depends on uni-db)

"""Repro: a fork of a fork (nested fork) errors on read (uni-db 2.2.5). Depends only on uni-db.
    pytest test_fork_nested.py   # FAILS on 2.2.5
    python test_fork_nested.py   # PASS/FAIL summary; exit 1 if bug present
"""

import uni_db


def test_nested_fork_reads_inherited_data():
    uni = uni_db.Uni.in_memory()
    session = uni.session()
    with session.tx() as tx:
        tx.execute("CREATE (:A {k: 1})-[:R {key: 11}]->(:B {k: 2})")
        tx.commit()

    fork = session.fork("x").build()
    assert fork.query("MATCH (a:A) RETURN count(a) AS c")[0]["c"] == 1  # first-level fork is fine

    nested = fork.fork("y").build()
    try:
        count = nested.query("MATCH (a:A) RETURN count(a) AS c")[0]["c"]
    finally:
        del nested
        try:
            uni.drop_fork("y")
        except Exception:
            pass
        del fork
        try:
            uni.drop_fork("x")
        except Exception:
            pass

    assert count == 1, f"nested fork saw {count} nodes; expected 1"

Impact

Tree-structured fork usage is blocked — e.g. MCTS rollouts that fork per node down a path, or nested
hypothetical scenarios. Single-level forks work; only nesting fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions