8000 Learners on a shared course pay an extra uncached query on every request · Issue #295 · alexbeeken/skrongle-mini · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

  • Learners on a shared course pay an extra uncached query on every request #295

    Backlog

    Description

    @alexbeeken

    Impact: medium. This is the classroom case, and it runs on every page, every /api/* call and every /pictures/*.

    • src/auth.rs:597-600: for a learner on a course someone shared, the Project extractor runs share::can_open (src/share.rs:160-169), a 4-table join through conn.query_row, so the statement is compiled each time. It undoes the session cache for exactly these users.
    • src/proxy_auth.rs:321: with proxy sign-in, resolve runs two uncached queries on every request that carries the header.
    • src/auth/cache.rs:85-96: the triggers that empty the session cache fire on any column of sessions, users, courses, projects, settings. courses.updated_at is written by every autosave and every AI-written file, projects.last_opened_at by every course open, and a sessions insert by every sign-in. Each empties the cache for all users.

    Fix:

    • Add the answer to the session query as a column (EXISTS(SELECT 1 FROM course_shares WHERE course_id = u.active_course AND user_id = u.id)), carry it on CurrentUser, and add course_shares to the watched tables. At the least, use query_row_cached.
    • In the proxy middleware, look in the session cache first and compare the cached user's address.
    • Narrow the triggers: AFTER UPDATE OF title, owner_id ON courses, UPDATE OF start_unit ON projects, UPDATE OF the columns the session query reads on users, and no insert trigger on sessions.

    From the code review of 24 November 2026. Line numbers are as of 0.5.0 (2547b36).

    Activity

    1. added
      review
      on Nov 24, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      review

      Type

      No type

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

      • 0