HKUDS/DeepTutor · error · PathLeaseConflictError

PathLeaseConflictError(existing)

Error message

PathLeaseConflictError(existing)

What it means

acquire_path_lease found an existing lease for the path held by another session/turn; PathLeaseConflictError wraps that existing lease so the caller can see who holds it. The path is already being mutated elsewhere.

Solutions

  1. Wait for the existing lease to expire or be released, then retry
  2. Inspect the conflicting lease in the exception to coordinate with the owning session
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at deeptutor/learning/storage.py:871 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/bc09a99e85cd5d94. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/learning/storage.py:871

        if not session_id or not turn_id:
            raise ValueError("session_id and turn_id are required for a path lease")
        if bind_session:
            self.bind_session(path_id, session_id, owns_path=False)
        else:
            # Administrative mutations need exclusion without creating a fake
            # conversation association.
            with self.transaction(path_id, create=True):
                pass
        now = time.time()
        with self._connect() as conn:
            conn.execute("BEGIN IMMEDIATE")
            try:
                row = conn.execute(
                    "SELECT * FROM mastery_path_leases WHERE path_id = ?", (path_id,)
                ).fetchone()
                existing = self._lease_from_row(row)
                if existing is not None and existing.turn_id != turn_id:
                    raise PathLeaseConflictError(existing)
                conn.execute(
                    """
                    INSERT INTO mastery_path_leases (path_id, session_id, turn_id, acquired_at)
                    VALUES (?, ?, ?, ?)
                    ON CONFLICT(path_id) DO UPDATE SET
                        session_id = excluded.session_id,
                        turn_id = excluded.turn_id,
                        acquired_at = excluded.acquired_at
                    """,
                    (path_id, session_id, turn_id, now),
                )
                conn.commit()
            except Exception:
                conn.rollback()
                raise
        return MasteryPathLease(
            path_id=path_id, session_id=session_id, turn_id=turn_id, acquired_at=now
        )

View on GitHub (pinned to 3e82f13042)