HKUDS/DeepTutor · error · LearningConflictError

LearningConflictError(path_id, expected…

Error message

LearningConflictError(path_id, expected, int(current["revision"]) if current else 0)

What it means

Optimistic-lock failure during save()'s UPDATE: the WHERE revision = expected clause matched no row because the stored revision moved past the expected value (or the row disappeared). LearningConflictError reports the path id, the expected revision, and the actual current revision (0 when absent).

Solutions

  1. Retry after reloading the path's current revision
  2. Coordinate writers through acquire_path_lease so only one mutates at a time
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at deeptutor/learning/storage.py:513 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/06fd679c81741552. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/learning/storage.py:513

                    cursor = conn.execute(
                        """
                        UPDATE mastery_paths
                        SET state_json = ?, revision = ?, updated_at = ?
                        WHERE path_id = ? AND revision = ?
                        """,
                        (
                            self._progress_payload(progress, revision, now),
                            revision,
                            now,
                            path_id,
                            expected,
                        ),
                    )
                    if cursor.rowcount != 1:
                        current = conn.execute(
                            "SELECT revision FROM mastery_paths WHERE path_id = ?", (path_id,)
                        ).fetchone()
                        raise LearningConflictError(
                            path_id, expected, int(current["revision"]) if current else 0
                        )
                    event_type = "path.saved"
                conn.execute(
                    """
                    INSERT INTO mastery_events (
                        path_id, revision, event_type, payload_json, created_at
                    ) VALUES (?, ?, ?, '{}', ?)
                    """,
                    (path_id, revision, event_type, now),
                )
                conn.commit()
            except Exception:
                conn.rollback()
                raise
        progress.version = revision
        progress.updated_at = now

View on GitHub (pinned to 3e82f13042)