Skip to content

RHINENG-30670: remove multi IN-list condition - #2336

Merged
MichaelMraka merged 1 commit into
RedHatInsights:masterfrom
MichaelMraka:pr1
Sep 14, 2026
Merged

RHINENG-30670: remove multi IN-list condition#2336
MichaelMraka merged 1 commit into
RedHatInsights:masterfrom
MichaelMraka:pr1

Conversation

@MichaelMraka

@MichaelMraka MichaelMraka commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

PostgreSQL 17 introduced optimizer changes, including how IN-lists are processed with btree indexes. This seems to cause OOMkill during BIND phase (query planning/parameter binding), a single connection's memory consumption increases to approximately 2.6 GB.

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Replace multi-NEVRA database queries with individual package lookups to avoid PostgreSQL 17 optimizer memory issues.

Bug Fixes:

  • Prevent PostgreSQL planning-time memory exhaustion by removing multi-value IN-list package lookups.

Enhancements:

  • Simplify NEVRA batch lookup handling while preserving invalid and missing package reporting.

PostgreSQL 17 introduced optimizer changes, including how IN-lists are processed with btree indexes.
This seems to cause OOMkill during BIND phase (query planning/parameter binding), a single connection's memory consumption increases to approximately 2.6 GB.
@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates bulk NEVRA package-cache reads to perform individual equality-based lookups instead of constructing a multi-column IN-list, mitigating PostgreSQL 17 OOM risk during query planning while preserving found and missing package tracking.

File-Level Changes

Change Details Files
Replace the single multi-column IN-list lookup with per-NEVRA database queries to avoid PostgreSQL 17 planning-time memory growth.
  • Parse each NEVRA and skip invalid inputs with a warning.
  • Query each valid name/EVRA pair using equality predicates.
  • Append found packages directly and record unfound valid NEVRAs as missing.
  • Remove aggregate result reconstruction and related formatting/logging imports.
evaluator/package_cache.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@MichaelMraka
MichaelMraka requested a review from a team as a code owner September 14, 2026 13:08

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="evaluator/package_cache.go" line_range="363-375" />
<code_context>
 	for _, nevraString := range nevraStrings {
</code_context>
<issue_to_address>
**issue (performance):** ReadByNevras now performs one database transaction and query for every valid NEVRA instead of one batch query, so a request containing a large list executes N sequential queries and incurs N query-planning/round-trip costs.

**Triggers:** When callers pass a large number of cache misses in one request.

**Suggested fix:** Use bounded batching or a temporary/table-valued input strategy that avoids PostgreSQL's pathological multi-column IN-list planning without issuing one transaction per NEVRA.
</issue_to_address>

### Comment 2
<location path="evaluator/package_cache.go" line_range="363-375" />
<code_context>
 	for _, nevraString := range nevraStrings {
</code_context>
<issue_to_address>
**issue (bug_risk):** ReadByNevras appends a result for every input occurrence, so duplicate valid NEVRA strings produce duplicate PackageCacheMetadata entries; the previous implementation deduplicated inputs through the parsed map before querying and returned each database package once.

**Triggers:** When the input slice contains duplicate valid NEVRA strings.

**Suggested fix:** Deduplicate parsed NEVRAs before querying, or track returned package identities and append each package only once.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: evaluator/package_cache.go:375, evaluator/package_cache.go:375


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread evaluator/package_cache.go
Comment thread evaluator/package_cache.go
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 58.99%. Comparing base (0c15032) to head (b92ff4e).

Files with missing lines Patch % Lines
evaluator/package_cache.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2336      +/-   ##
==========================================
- Coverage   59.06%   58.99%   -0.08%     
==========================================
  Files         150      150              
  Lines        9615     9603      -12     
==========================================
- Hits         5679     5665      -14     
- Misses       3342     3346       +4     
+ Partials      594      592       -2     
Flag Coverage Δ
unittests 58.99% <85.71%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MichaelMraka
MichaelMraka merged commit 6bff29e into RedHatInsights:master Sep 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants