HKUDS/DeepTutor · error · LearningConflictError

LearningConflictError(path_id, expected, actual)

Error message

LearningConflictError(path_id, expected, actual)

What it means

LearningConflictError raised in _connect when the stored revision for path_id no longer equals the expected revision — a concurrent writer committed a newer version between read and write. The exception includes path id, expected, and actual revision numbers.

Solutions

  1. Catch LearningConflictError, reload latest progress, and retry the operation
  2. Use transaction() with row locking or a path lease for multi-writer scenarios
Defensive patterns

Strategy: retry

When it happens

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

Appendix: source

Thrown at deeptutor/learning/storage.py:493

                        """
                        INSERT INTO mastery_paths (
                            path_id, state_json, revision, created_at, updated_at
                        ) VALUES (?, ?, ?, ?, ?)
                        """,
                        (
                            path_id,
                            self._progress_payload(progress, revision, now),
                            revision,
                            progress.created_at,
                            now,
                        ),
                    )
                    event_type = "path.created"
                else:
                    actual = int(row["revision"])
                    expected = int(progress.version)
                    if actual != expected:
                        raise LearningConflictError(path_id, expected, actual)
                    revision = actual + 1
                    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,)

View on GitHub (pinned to 3e82f13042)