Skip to content

fix(longRunningMigrations): make 0020 batch size small to avoid OOM#6875

Merged
noliveleger merged 1 commit intorelease/2.026.07from
fix-version-hash-lrm-oom
Mar 26, 2026
Merged

fix(longRunningMigrations): make 0020 batch size small to avoid OOM#6875
noliveleger merged 1 commit intorelease/2.026.07from
fix-version-hash-lrm-oom

Conversation

@noliveleger
Copy link
Contributor

@noliveleger noliveleger commented Mar 26, 2026

💭 Notes

  • Comment-only change in 0020_backfill_asset_version_hash.py.
  • Replaces the previous comment with a clearer explanation of why CHUNK_SIZE is kept small: each version_content blob can be large, so a small batch size trades throughput for a lower memory footprint.
  • No behavior change.

@noliveleger noliveleger requested a review from jnm as a code owner March 26, 2026 19:11
@noliveleger noliveleger self-assigned this Mar 26, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 26, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • llm-ignore

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 318a8094-cf89-4581-b756-a71729746c4d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@noliveleger noliveleger changed the title docs(long_running_migrations): clarify CHUNK_SIZE comment in 0020 DEV-XXXX docs(longRunningMigrations): clarify CHUNK_SIZE comment in 0020 Mar 26, 2026
@noliveleger noliveleger changed the title docs(longRunningMigrations): clarify CHUNK_SIZE comment in 0020 chore(longRunningMigrations): clarify CHUNK_SIZE comment in 0020 Mar 26, 2026
@greptile-apps
Copy link

greptile-apps bot commented Mar 26, 2026

Greptile Summary

This PR updates the comment on CHUNK_SIZE in 0020_backfill_asset_version_hash.py to better explain the memory-vs-throughput trade-off, and removes the now-unused settings import. The new comment is clearer and more descriptive.\n\nKey observations:\n- The new comment is a genuine improvement: it names the specific field (version_content JSON blobs) and the explicit goal (lower memory footprint).\n- CHUNK_SIZE is changed from a dynamic min(settings.LONG_RUNNING_MIGRATION_SMALL_BATCH_SIZE, 50) to a hardcoded 5, and the django.conf.settings import is correctly removed as a result.\n- The only open style suggestion is to optionally mention the order-of-magnitude memory impact in the comment itself, to help future maintainers calibrate the value.\n- PR template / title note: The description does not include the ### 📣 Summary, ### 📖 Description, ### 👷 Description for instance maintainers, or ### 🗒️ Checklist sections from .github/PULL_REQUEST_TEMPLATE.md. For an internal-only change those top sections may legitimately be omitted, but the ### 👷 Description for instance maintainers section would be the natural place to describe the performance impact of this constant change on live instances. The PR title also omits the DEV-XXXX ticket number called for by the template checklist (item 4).

Confidence Score: 4/5

Safe to merge; the only open items are a style suggestion on the comment wording and a PR-template compliance note.

The code change itself is minimal and correct — the comment is clearer, the hardcoded CHUNK_SIZE = 5 is intentional, and the dead import is removed. No logic paths are altered. A prior review thread flagged the behavioral aspect of the CHUNK_SIZE reduction; that concern stands but doesn't block correctness. The small deduction from 5 is for the open PR-template compliance gaps (missing maintainer description section, no ticket number) and the style-level opportunity to quantify the memory impact in the comment.

No files require special attention; the single changed file is straightforward.

Important Files Changed

Filename Overview
kobo/apps/long_running_migrations/jobs/0020_backfill_asset_version_hash.py Comment updated to explain memory-vs-throughput trade-off; CHUNK_SIZE hardcoded to 5 and unused settings import removed. Logic is otherwise unchanged.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([run]) --> B{get_queryset\nreturns records?}
    B -- "No records left" --> Z([Done])
    B -- "Up to CHUNK_SIZE=5\nrecords" --> C[Iterate with\niterator chunk_size=5]
    C --> D[Compute content_hash\nfor each AssetVersion]
    D --> E[bulk_update\n_content_hash field]
    E --> F[sleep 2s\navoid DB flood]
    F --> B
Loading

Reviews (2): Last reviewed commit: "docs(long_running_migrations): improve C..." | Re-trigger Greptile

@noliveleger noliveleger force-pushed the fix-version-hash-lrm-oom branch from 4f79600 to 26a0cd4 Compare March 26, 2026 19:14
@noliveleger noliveleger changed the title chore(longRunningMigrations): clarify CHUNK_SIZE comment in 0020 docs(longRunningMigrations): clarify CHUNK_SIZE comment in 0020 Mar 26, 2026
@noliveleger noliveleger changed the title docs(longRunningMigrations): clarify CHUNK_SIZE comment in 0020 fix(longRunningMigrations): make 0020 batch size small to avoid OOM Mar 26, 2026
@noliveleger noliveleger merged commit f09c2ed into release/2.026.07 Mar 26, 2026
21 checks passed
@noliveleger noliveleger deleted the fix-version-hash-lrm-oom branch March 26, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant