Skip to content

[WIP] Optimize prow loader with COPY protocol, bulk operations, and GCS improvements#3745

Draft
mstaeble wants to merge 1 commit into
openshift:mainfrom
mstaeble:worktree-prow-job-run-tests-copy
Draft

[WIP] Optimize prow loader with COPY protocol, bulk operations, and GCS improvements#3745
mstaeble wants to merge 1 commit into
openshift:mainfrom
mstaeble:worktree-prow-job-run-tests-copy

Conversation

@mstaeble

@mstaeble mstaeble commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replaces per-row DB operations (findOrAddTest, CreateInBatches, per-row ProwJob upserts) with bulk PostgreSQL operations using COPY protocol, temp tables, and writable CTEs
  • Replaces 800k+ in-memory job run ID cache with a temp table COPY + LEFT JOIN anti-join to find new runs
  • Removes all shared mutable caches and their locks (prowJobRunTestCache, suiteCache, prowJobCacheLock, prowJobRunCacheLock)
  • Pre-filters candidates before the goroutine loop so workers only receive new runs
  • Optimizes GCS artifact fetching with server-side MatchGlob filtering, SetAttrSelection, and removal of unnecessary Attrs/Generation pinning
  • Increases worker concurrency from 10 to 50
  • Pre-compiles release config regexes at construction

Behavioral change

extractTestCases now attributes tests to their actual child suite name rather than inheriting the parent suite's ID. The old behavior assigned all nested JUnit tests to the top-level suite, which was incorrect for tests in child suites with different names.

Benchmarks (staging-2, all releases, 4h lookback)

Metric Baseline Optimized
Jobs imported ~1,100 ~830
Import time 5m11s 38s
Speedup 8x

Job count varies by run (different 4-hour windows). Per-job throughput is consistently much higher.

Test plan

  • gofmt, go vet, golangci-lint pass
  • make test passes
  • Benchmarked against staging-2 database with production-scale data
  • Verified row counts and test outputs match
  • Independent code review (two rounds) found and fixed critical MatchGlob bug, ctx-cancellation edge case, correlated subquery, and string-concat VALUES clause

🤖 Generated with Claude Code

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Improved bulk loading of job-run test results for higher throughput and faster processing.
  • Bug Fixes

    • Job loading now excludes Prow jobs in non-terminal states (pending/triggered).
    • Enhanced glob-based discovery for events, intervals/timelines, cluster-data, and JUnit artifacts, with more consistent behavior when files are missing.
  • Tests

    • Added unit coverage for test-case extraction and suite naming/status handling.
  • Documentation

    • Not included in this change.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR replaces regex-based GCS discovery with glob matching and updates consumers for flat match lists. Prow loading now preprocesses jobs, filters completed work, deduplicates job runs, and bulk-inserts extracted test data through temporary tables.

Changes

GCS discovery and consumers

Layer / File(s) Summary
Glob-based matching and object loading
pkg/dataloader/prowloader/gcs/gcs_jobrun.go
Replaces regex match sets with context-aware glob queries, updates JUnit path discovery, and reads objects directly.
Glob lookup consumers
pkg/api/jobrunevents/job_run_events.go, pkg/api/jobrunintervals/job_run_intervals.go, pkg/variantregistry/ocp.go
Uses glob patterns and flat match lists for events, interval, and cluster-data files.

Prow import pipeline

Layer / File(s) Summary
Preprocessing and scheduling
pkg/dataloader/prowloader/prow.go, pkg/dataloader/prowloader/bigqueryjobs.go
Adds release matching, terminal-state filtering, bulk ProwJob upserts, job-run deduplication, and preprocessing before worker execution.
Bulk JUnit persistence
pkg/db/pgx.go, pkg/dataloader/prowloader/prow.go, pkg/dataloader/prowloader/extract_test_cases_test.go
Extracts string-based test rows, handles flakes, and bulk-loads tests and outputs through a temporary table.
Suite importability
pkg/db/suites.go
Replaces GetSuiteID with exported IsSuiteImportable.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProwLoader
  participant Database
  participant GCSJobRun
  participant GCS
  ProwLoader->>Database: preprocess jobs and find new job-run IDs
  Database-->>ProwLoader: eligible jobs
  ProwLoader->>GCSJobRun: FindAllMatches(ctx, junit glob)
  GCSJobRun->>GCS: query matching objects
  GCS-->>GCSJobRun: matched JUnit paths
  GCSJobRun-->>ProwLoader: JUnit suites
  ProwLoader->>Database: bulk-load extracted test rows
Loading

Possibly related PRs

  • openshift/sippy#3740: Adds the related generic pgx temporary-table bulk-loading utility used by this import refactor.

Suggested reviewers: smg247, neisw, xueqzhan

🚥 Pre-merge checks | ✅ 18 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Go Error Handling ⚠️ Warning findOrAddPullRequests can dereference *mergedAt after GetPRSHAMerged errors, and loadProwJobCache ignores a DB query error. Guard mergedAt before dereferencing (or continue on lookup error), and have loadProwJobCache return/wrap the Find error instead of discarding it.
Test Coverage For New Features ⚠️ Warning Only extractTestCases gained a regression test; the new API/GCS/pgx/loader helpers (JobRunEvents, JobRunIntervals, CopyToTempTable, etc.) have no unit tests. Add unit tests for the new helpers or split pure logic from side effects; at minimum cover JobRunEvents, JobRunIntervals, CopyToTempTable, and GCS discovery paths.
✅ Passed checks (18 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Sql Injection Prevention ✅ Passed SQL interpolation is limited to static/whitelisted identifiers; user data flows through placeholders/COPY, so I found no new SQL injection vector.
Excessive Css In React Should Use Styles ✅ Passed The PR only changes Go backend files; no React components or inline style objects were added or modified.
Single Responsibility And Clear Naming ✅ Passed Touched code uses specific, action-oriented names and chunks the loader into focused helpers (preprocess/find/insert/extract) without generic Manager/Util types.
Feature Documentation ✅ Passed No docs/features update was needed: the only feature doc covers symptoms, while this PR changes loader internals and implementation details, not documented feature behavior.
Stable And Deterministic Test Names ✅ Passed No Ginkgo titles were added or changed; the new test uses static table-driven names like "passing test" and "child suite uses its own name".
Test Structure And Quality ✅ Passed No Ginkgo tests were added/changed; the new table-driven unit test is focused, has no cluster waits/setup issues, and matches existing testify patterns.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the only new test is a plain Go unit test, so MicroShift compatibility rules don’t apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PASS: The PR adds only a standard unit test; no new Ginkgo e2e specs or SNO-sensitive multi-node assumptions were introduced.
Topology-Aware Scheduling Compatibility ✅ Passed PASS — changes are limited to Go API/db/dataloader/variant code; no manifests or controllers were modified, and no pod scheduling constraints were introduced.
Ote Binary Stdout Contract ✅ Passed Changed files add no main/init/TestMain/BeforeSuite code and no fmt/klog stdout calls; only logrus logging in helpers, so no stdout contract violation.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the only new test is a plain unit test and shows no IPv4 or external-network assumptions.
No-Weak-Crypto ✅ Passed No touched file adds weak crypto, custom crypto, or secret/token comparisons; focused scans of all PR files found none.
Container-Privileges ✅ Passed HEAD changes are nine .go files only; no K8s/container manifests were modified, and repo config search found no flagged privilege settings.
No-Sensitive-Data-In-Logs ✅ Passed New/changed logs only report counts, job names, artifact paths, or temp-table names; secret/PII-bearing logging wasn't added, and the gcsweb URL log was pre-existing.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: prow loader optimization, bulk database operations, and GCS improvements.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 7, 2026
@openshift-ci

openshift-ci Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci Bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 7, 2026
@openshift-ci

openshift-ci Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mstaeble
Once this PR has been reviewed and has the lgtm label, please assign neisw for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mstaeble mstaeble changed the title [WIP] TRT-XXXX: Optimize prow loader with COPY protocol, bulk operations, and GCS improvements [WIP] Optimize prow loader with COPY protocol, bulk operations, and GCS improvements Jul 7, 2026
@mstaeble mstaeble force-pushed the worktree-prow-job-run-tests-copy branch from d17a12c to 88fc542 Compare July 7, 2026 21:30
@mstaeble

mstaeble commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mstaeble

mstaeble commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 16 minutes.

@mstaeble

mstaeble commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
pkg/dataloader/prowloader/gcs/gcs_jobrun.go (1)

155-180: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Accept context.Context in FindAllMatches for cancellation and timeout support.

FindAllMatches uses context.Background() at line 167, making GCS listing operations uncancellable by the caller. GetContent in the same struct already accepts ctx context.Context, so this creates an inconsistency. The ocp.go caller has a context available, and the API handler callers already use context.TODO() for GetContent. For buckets with many objects, listing can be long-running and should respect cancellation.

As per path instructions, Go code should use context.Context for cancellation and timeouts. As per coding guidelines, follow idiomatic Go practices.

♻️ Proposed refactor
-func (j *GCSJobRun) FindAllMatches(glob string) ([]string, error) {
+func (j *GCSJobRun) FindAllMatches(ctx context.Context, glob string) ([]string, error) {
 	q := &storage.Query{
 		Prefix:    j.gcsProwJobPath,
 		MatchGlob: glob,
 	}
 	if err := q.SetAttrSelection([]string{"Name"}); err != nil {
 		return nil, errors.Wrap(err, "error setting attribute selection")
 	}

 	var matches []string
-	it := j.bkt.Objects(context.Background(), q)
+	it := j.bkt.Objects(ctx, q)

Callers would then pass their available context:

 // gcs_jobrun.go:52
-matches, err := j.FindAllMatches(j.gcsProwJobPath + "/**junit*xml")
+matches, err := j.FindAllMatches(ctx, j.gcsProwJobPath + "/**junit*xml")
 // job_run_events.go:75
-matches, err := gcsJobRun.FindAllMatches("**/gather-extra/artifacts/events.json")
+matches, err := gcsJobRun.FindAllMatches(context.TODO(), "**/gather-extra/artifacts/events.json")
 // job_run_intervals.go:47,51
-intervalFiles, err := gcsJobRun.FindAllMatches("**e2e-events*json")
+intervalFiles, err := gcsJobRun.FindAllMatches(context.TODO(), "**e2e-events*json")
-timelineFiles, err := gcsJobRun.FindAllMatches("**e2e-timelines*json")
+timelineFiles, err := gcsJobRun.FindAllMatches(context.TODO(), "**e2e-timelines*json")
 // ocp.go:218
-clusterMatches, err := gcsJobRun.FindAllMatches("**/cluster-data_*json")
+clusterMatches, err := gcsJobRun.FindAllMatches(ctx, "**/cluster-data_*json")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/dataloader/prowloader/gcs/gcs_jobrun.go` around lines 155 - 180,
FindAllMatches currently hardcodes context.Background(), so the GCS listing
cannot be canceled or timed out by callers. Update the GCSJobRun.FindAllMatches
method to accept a context.Context parameter, pass that context into
j.bkt.Objects, and adjust callers such as the ocp.go path and any API handler
usage to forward their existing context instead of relying on an uncancellable
background context.

Sources: Coding guidelines, Path instructions

pkg/dataloader/prowloader/prow.go (2)

1516-1554: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider unit tests for the reworked suite-attribution and flake logic.

extractTestCases is pure logic (child-suite name attribution, failure/success→flake promotion, output retention) and this PR changes its behavior; a small table-driven test over a synthetic junit.TestSuite tree would lock in the new attribution and flake rules without needing any storage clients.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/dataloader/prowloader/prow.go` around lines 1516 - 1554, Add table-driven
unit tests for extractTestCases to lock in the new pure logic around suite
attribution, recursive child-suite traversal, and failure/success-to-flake
promotion. Cover synthetic junit.TestSuite trees with parent/child suites,
ignored and skipped cases, and mixed duplicate results so you verify the
testCaseEntry status/output behavior stays correct without depending on any
storage clients.

Source: Coding guidelines


1120-1137: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Connection-pool sizing with 50 concurrent workers.

Each worker acquires a dedicated pgx connection via stdlib.AcquireConn for the temp-table + COPY path, on top of the GORM transaction in processGCSBucketJobRun. With maxConcurrency raised to 50, confirm the underlying sql.DB pool (SetMaxOpenConns) can supply at least that many, otherwise workers will serialize on connection acquisition and erode the bulk-insert speedup.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/dataloader/prowloader/prow.go` around lines 1120 - 1137, The bulk insert
path in ProwLoader’s bulkInsertJobRunTests currently acquires a dedicated pgx
connection per worker on top of the GORM transaction, so the sql.DB pool must be
sized to support the raised maxConcurrency of 50. Update the connection-pool
configuration used by processGCSBucketJobRun and/or the DB initialization so
SetMaxOpenConns is at least 50 (and consistent with any related idle limits),
ensuring stdlib.AcquireConn in bulkInsertJobRunTests does not serialize workers
and negate the COPY/temp-table throughput gain.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/dataloader/prowloader/prow.go`:
- Around line 1485-1488: The synthetic suite importability check in
prowJobRunTestsFromGCS currently panics, which can crash the worker pool instead
of failing just that job run. Replace the panic after
db.IsSuiteImportable(syntheticSuite.Name) with an error return from
prowJobRunTestsFromGCS, and make the caller handle that error path cleanly
before extractTestCases runs. Use the existing prowJobRunTestsFromGCS and
db.IsSuiteImportable symbols to locate the guard and propagate a descriptive
error rather than terminating the goroutine.
- Around line 736-753: The row processing in the query path for new job run IDs
is ignoring scan/iteration failures, so fix the logic in the function that
builds newIDs from rows to handle errors from rows.Scan and to check rows.Err()
after the loop. If either Scan or iteration fails, return a wrapped error with
context using fmt.Errorf and %w instead of silently continuing, and only build
the set from fully validated IDs.

---

Nitpick comments:
In `@pkg/dataloader/prowloader/gcs/gcs_jobrun.go`:
- Around line 155-180: FindAllMatches currently hardcodes context.Background(),
so the GCS listing cannot be canceled or timed out by callers. Update the
GCSJobRun.FindAllMatches method to accept a context.Context parameter, pass that
context into j.bkt.Objects, and adjust callers such as the ocp.go path and any
API handler usage to forward their existing context instead of relying on an
uncancellable background context.

In `@pkg/dataloader/prowloader/prow.go`:
- Around line 1516-1554: Add table-driven unit tests for extractTestCases to
lock in the new pure logic around suite attribution, recursive child-suite
traversal, and failure/success-to-flake promotion. Cover synthetic
junit.TestSuite trees with parent/child suites, ignored and skipped cases, and
mixed duplicate results so you verify the testCaseEntry status/output behavior
stays correct without depending on any storage clients.
- Around line 1120-1137: The bulk insert path in ProwLoader’s
bulkInsertJobRunTests currently acquires a dedicated pgx connection per worker
on top of the GORM transaction, so the sql.DB pool must be sized to support the
raised maxConcurrency of 50. Update the connection-pool configuration used by
processGCSBucketJobRun and/or the DB initialization so SetMaxOpenConns is at
least 50 (and consistent with any related idle limits), ensuring
stdlib.AcquireConn in bulkInsertJobRunTests does not serialize workers and
negate the COPY/temp-table throughput gain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 80558e1e-95c0-49f7-baa3-4a682b5326e6

📥 Commits

Reviewing files that changed from the base of the PR and between 801c5d3 and 88fc542.

📒 Files selected for processing (7)
  • pkg/api/jobrunevents/job_run_events.go
  • pkg/api/jobrunintervals/job_run_intervals.go
  • pkg/dataloader/prowloader/bigqueryjobs.go
  • pkg/dataloader/prowloader/gcs/gcs_jobrun.go
  • pkg/dataloader/prowloader/prow.go
  • pkg/db/suites.go
  • pkg/variantregistry/ocp.go

Comment thread pkg/dataloader/prowloader/prow.go
Comment thread pkg/dataloader/prowloader/prow.go
@mstaeble mstaeble force-pushed the worktree-prow-job-run-tests-copy branch from 88fc542 to d5a8bf1 Compare July 8, 2026 02:17
@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jul 8, 2026
@mstaeble mstaeble force-pushed the worktree-prow-job-run-tests-copy branch from d5a8bf1 to 33c0771 Compare July 8, 2026 02:24
@mstaeble mstaeble marked this pull request as ready for review July 8, 2026 02:26
@mstaeble mstaeble changed the title [WIP] Optimize prow loader with COPY protocol, bulk operations, and GCS improvements Optimize prow loader with COPY protocol, bulk operations, and GCS improvements Jul 8, 2026
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 8, 2026
@openshift-ci openshift-ci Bot requested review from petr-muller and stbenjam July 8, 2026 02:26
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

…nd GCS improvements

Replace per-row database operations and in-memory caches with bulk
PostgreSQL operations, and optimize GCS artifact fetching.

Database changes:
- Replace per-row findOrAddTest (SELECT+INSERT per test name) and
  CreateInBatches with COPY into a temp table + a writable CTE that
  resolves test/suite IDs via JOINs and inserts test outputs in one
  statement
- Replace 800k+ in-memory job run ID cache with a temp table COPY +
  LEFT JOIN anti-pattern to find new runs
- Bulk-upsert ProwJob definitions in batches of 100 instead of
  per-row inserts
- Remove all shared mutable caches and their locks
  (prowJobRunTestCache, suiteCache, prowJobCacheLock,
  prowJobRunCacheLock)
- Pre-filter candidates by release matching and PG existence check
  before the goroutine loop, so workers receive only new runs

GCS changes:
- Use MatchGlob for server-side filtering in FindAllMatches,
  replacing client-side regex matching
- Use SetAttrSelection(["Name"]) to reduce GCS response payload
- Remove unnecessary Attrs/Generation pinning in GetContent (CI
  artifacts are immutable)
- Increase worker concurrency from 10 to 50
- Pre-compile release config regexes at construction instead of
  per-job

Behavioral change: extractTestCases now attributes tests to their
actual child suite name rather than inheriting the parent suite's ID.
The old behavior assigned all nested JUnit tests to the top-level
suite, which was incorrect for tests in child suites.

Benchmarked against staging-2 (all releases, 4h lookback):
- Baseline: 5m11s for ~1,100 jobs
- Optimized: 38s for ~830 jobs (8x speedup)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mstaeble mstaeble force-pushed the worktree-prow-job-run-tests-copy branch from 33c0771 to 71baed9 Compare July 10, 2026 22:58
@mstaeble mstaeble changed the title Optimize prow loader with COPY protocol, bulk operations, and GCS improvements [WIP] Optimize prow loader with COPY protocol, bulk operations, and GCS improvements Jul 10, 2026
@mstaeble mstaeble marked this pull request as draft July 10, 2026 22:59
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/dataloader/prowloader/prow.go (1)

1063-1101: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Make the run and test inserts atomic. bulkInsertJobRunTests happens after the prow_jobs_run transaction on a separate connection, so a failure here can leave a committed run with no prow_job_run_tests. findNewJobRunIDs only checks prow_job_runs, so that run will be skipped on the next load and never backfilled. Move the test insert into the same transaction or add a repair path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/dataloader/prowloader/prow.go` around lines 1063 - 1101, Make creation of
the Prow job run, pull-request associations, and test rows atomic by moving the
bulk test insertion performed by bulkInsertJobRunTests into the existing
transaction in the surrounding loader method. Update the helper as needed to
accept and use the transaction’s *gorm.DB connection, and return any test-insert
error from the transaction before committing; remove the separate
post-transaction call so a failure rolls back all related records.
🧹 Nitpick comments (2)
pkg/db/pgx.go (1)

37-52: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low value

Static-analysis SQL-injection hint here is a false positive, but consider validating the identifier.

tempTable is interpolated into CREATE TEMP TABLE/DROP TABLE because SQL identifiers cannot use bind placeholders. All current callers pass hard-coded constants, so there is no user-controlled input and the ast-grep finding is a false positive. Since this is a reusable pkg/db helper, a cheap defense-in-depth guard (reject names not matching ^[a-zA-Z_][a-zA-Z0-9_]*$) would keep it safe against future callers.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/db/pgx.go` around lines 37 - 52, Validate tempTable before interpolating
it into SQL in the helper containing the drop closure and createSQL
construction, allowing only identifiers matching ^[a-zA-Z_][a-zA-Z0-9_]*$;
return a descriptive error for invalid names so both CREATE and DROP statements
remain protected.

Source: Linters/SAST tools

pkg/dataloader/prowloader/prow.go (1)

269-303: 🚀 Performance & Scalability | 🔵 Trivial

Connection-pool sizing with 50 concurrent workers.

maxConcurrency is now 50, and each worker's bulkInsertJobRunTests hijacks a dedicated connection via stdlib.AcquireConn, holding it for the temp-table COPY plus multiple Exec statements. If the underlying database/sql pool MaxOpenConns is below ~50 (plus headroom for the gorm transaction that also runs per job), workers will serialize or stall on connection acquisition, negating the concurrency increase. Worth verifying the pool is sized accordingly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/dataloader/prowloader/prow.go` around lines 269 - 303, Verify the
database connection pool configuration used by the workers launched in the
`prowJobToJobRun` processing loop and ensure `MaxOpenConns` provides at least 50
connections plus headroom for each job’s GORM transaction and other database
operations. Update the pool sizing configuration or reduce `maxConcurrency` as
appropriate, and confirm `bulkInsertJobRunTests` and related transaction paths
do not stall on `stdlib.AcquireConn`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@pkg/dataloader/prowloader/prow.go`:
- Around line 1063-1101: Make creation of the Prow job run, pull-request
associations, and test rows atomic by moving the bulk test insertion performed
by bulkInsertJobRunTests into the existing transaction in the surrounding loader
method. Update the helper as needed to accept and use the transaction’s *gorm.DB
connection, and return any test-insert error from the transaction before
committing; remove the separate post-transaction call so a failure rolls back
all related records.

---

Nitpick comments:
In `@pkg/dataloader/prowloader/prow.go`:
- Around line 269-303: Verify the database connection pool configuration used by
the workers launched in the `prowJobToJobRun` processing loop and ensure
`MaxOpenConns` provides at least 50 connections plus headroom for each job’s
GORM transaction and other database operations. Update the pool sizing
configuration or reduce `maxConcurrency` as appropriate, and confirm
`bulkInsertJobRunTests` and related transaction paths do not stall on
`stdlib.AcquireConn`.

In `@pkg/db/pgx.go`:
- Around line 37-52: Validate tempTable before interpolating it into SQL in the
helper containing the drop closure and createSQL construction, allowing only
identifiers matching ^[a-zA-Z_][a-zA-Z0-9_]*$; return a descriptive error for
invalid names so both CREATE and DROP statements remain protected.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 3d561a5d-8280-4ab9-800d-de3f60d11e06

📥 Commits

Reviewing files that changed from the base of the PR and between b5b1009 and 71baed9.

📒 Files selected for processing (9)
  • pkg/api/jobrunevents/job_run_events.go
  • pkg/api/jobrunintervals/job_run_intervals.go
  • pkg/dataloader/prowloader/bigqueryjobs.go
  • pkg/dataloader/prowloader/extract_test_cases_test.go
  • pkg/dataloader/prowloader/gcs/gcs_jobrun.go
  • pkg/dataloader/prowloader/prow.go
  • pkg/db/pgx.go
  • pkg/db/suites.go
  • pkg/variantregistry/ocp.go

@mstaeble

Copy link
Copy Markdown
Contributor Author

@coderabbitai pause

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant