← Back to Pull requests

TRT-3009: Prevent daemon new-test analysis from blocking fetchdata partition creation #4099

Closed
unknown closed this pull request without merging on Oct 13, 2026 20:05 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 13:35 UTC
Author

Summary

Fixes TRT-3009: the sippy daemon's new-test analysis held relation locks on partitioned test-result tables long enough to block fetchdata partition creation.

  • Bound merged-PR existence check to 90 days: The FetchJobRun(onlyNewTests=true) correlated NOT EXISTS subquery was constrained by release but not by timestamp, scanning every daily range sub-partition within the release. Added t2.prow_job_run_timestamp >= ? with a 90-day lookback from the job run's timestamp so PostgreSQL can prune to only recent sub-partitions. This prevents the shared locks from blocking CREATE TABLE ... PARTITION OF DDL during fetchdata.

  • Short-circuit empty job ID lists: PrintJobAnalysisJSONFromDB now returns early when ListFilteredJobIDs yields no results, avoiding prow_job_id IN (NULL) queries that would plan across all partitions and acquire locks.
  • Changes

    | File | Change |
    |------|--------|
    | pkg/api/job_runs.go | Added mergedPRLookbackDays constant (90 days) and timestamp bound to the NOT EXISTS subquery in FetchJobRun |
    | pkg/api/job_analysis.go | Early return with initialized empty map when no jobs match the filter |
    | test/integration/new_test_analysis_test.go | Integration tests validating bounded partition access and empty-jobs guard |

    Test plan

  • go vet ./pkg/api/... passes

  • go test ./pkg/... passes (all unit tests)

  • make lint passes

  • Integration tests compile (go test -c ./test/integration/)

  • make integration validates bounded partition access (requires container runtime)

  • - TestFetchJobRunOnlyNewTests/only_returns_tests_not_seen_in_merged_PRs_or_ownership_registry
    - TestFetchJobRunOnlyNewTests/old_merged_PR_beyond_lookback_does_not_exclude_test (regression test)
    - TestFetchJobRunOnlyNewTests/failed_tests_returned_when_onlyNewTests_is_false
    - TestPrintJobAnalysisEmptyJobs

    🤖 Generated with Claude Code

    ---
    Generated with Claude Code

    <!-- coderabbit-review -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Bug Fixes
    New-test filtering now checks merged pull request runs from the 90 days ending at the job run’s timestamp, inclusive. Tests found only in older runs no longer prevent a test from being treated as new.
    * Job analysis with filters that match no jobs now returns an empty result without an error, including an empty period breakdown.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 328 lines (+246 / -82) across 4 files Reviewer: sosiouxme Review duration: 390m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 328 lines diff across 4 files
    0.42
    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.347
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4099"
    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: 42.1% (MEDIUM) · Higher = larger blast radius
    42.1%
    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: 16.6% · Safe to merge
    16.6%