← Back to Pull requests

fix(packaging): index projects.name for the journals trigger #21020

Closed
unknown closed this pull request without merging on Nov 19, 2026 21:32 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 09:30 UTC
Author

  • Should hopefully close #19033, if not, it still fixes an issue with deletes timing out.

  • Verified locally by creating a db to prod's project count and used gunicorn --workers 1 --timeout 60. (numbers below)

  • - Before Index: gunicorn timed out after 60s, user was not deleted (prod shows 503).
    - After Index: user was deleted, and redirected to / (303 -> 200).

    Prior work


    #4958 - 2018 switch to UUID primary keys (among others)
    #19055 - one bulk UPDATE
    #19056 - indexed journals(name, id DESC), which doesn't help the projects lookup

    Problem


  • Accounts with more than ~1k-2k journal rows will hit the 60s worker timeout.

  • Deleting an account moves the user's journal rows to deleted-user (#19055)

  • The row level update_project_last_serial trigger runs UPDATE projects ... WHERE projects.name = ... once per row.

  • projects.name has had no index since #4958 - migration ee5b8f66a223.

  • Each journal row therefore scans all ~946k projects, about 47 ms per row in prod.

  • - A delete pays that for every journal row the user ever wrote
    - 4706 rows for girder-robot is about 220s

    Some numbers

    Measured on a local copy with 946k projects and journal rows shaped like the affected accounts. Each run timed the UPDATE.

    | Journal rows | Before | After |
    |---|---|---|
    | 4,706 (girder-robot) | 208.5s | 0.3s |
    | 2,198 (lcctoor) | 96.8s | 0.1s |

    These are from production

  • 4001 accounts have at least 1000 journal rows.

  • 1586 accounts have at least 2000 journal rows.

  • There are accounts with roughly 450k - 750k journal rows ("large accounts").
  • Follow up (mentioning in case we decide to pursue)


  • For "large accounts", the rewrite still takes 56s locally with this index.

  • journals_name_idx (457 MB) may be redundant, journals_name_id_idx from #19056 starts with the same column (yet to fully verify this).
  • Diff: 259 lines (+194 / -65) across 3 files Reviewer: JacobCoffee Review duration: 721m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 259 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.333
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #21020"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.2% (MEDIUM) · Higher = larger blast radius
    39.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.5% · Safe to merge
    15.5%
    Repository