fix(userReports): prevent infinite loop in MV background job#6878
fix(userReports): prevent infinite loop in MV background job#6878noliveleger merged 1 commit intorelease/2.026.07from
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
| Filename | Overview |
|---|---|
| kobo/apps/long_running_migrations/jobs/0019_recreate_user_reports_mv.py | Docstring updated to remove outdated reference to CONCURRENTLY; functional code unchanged. |
| kobo/apps/user_reports/management/commands/manage_user_reports_mv.py | Removed force-conditional CONCURRENTLY string replacement; CREATE_INDEXES_SQL now used directly. --force help text updated accordingly. |
Sequence Diagram
sequenceDiagram
participant Scheduler
participant Job as 0019_recreate_user_reports_mv
participant Command as manage_user_reports_mv
participant DB as Database
Note over Scheduler,DB: Before fix — SKIP_HEAVY_MIGRATIONS=True, no --force
Scheduler->>Job: run()
Job->>Command: call_command('manage_user_reports_mv', create=True)
Command->>Command: SKIP_HEAVY_MIGRATIONS=True AND force=False → reschedule
Command->>DB: UPDATE status='created'
DB-->>Command: OK
Note over Scheduler: Status reset to 'created' triggers re-queue
Scheduler->>Job: run() again ♻️ (infinite loop)
Note over Scheduler,DB: After fix — --force=True bypasses the guard
Scheduler->>Job: run()
Job->>Command: call_command('manage_user_reports_mv', create=True, force=True)
Command->>Command: force=True → skip reschedule branch
Command->>DB: CREATE MATERIALIZED VIEW
DB-->>Command: OK
Command->>DB: CREATE INDEXES (non-concurrent)
DB-->>Command: OK
Command-->>Job: success
Job-->>Scheduler: done ✅
Reviews (2): Last reviewed commit: "refactor(user_reports): remove CONCURREN..." | Re-trigger Greptile
… as the view is newly created and has no concurrent readers
3b9fcb9 to
e59ad4f
Compare
💭 Notes
SKIP_HEAVY_MIGRATIONS=True,manage_user_reports_mv --createresetsLongRunningMigration.statusback to'created', which re-triggers0019_recreate_user_reports_mvindefinitely.--forceflag bypassesSKIP_HEAVY_MIGRATIONSand runs the migration immediately. The background job always passes--force.CREATE INDEX CONCURRENTLYapproach introduced in fix(userReports): prevent infinite loop in MV background job #6876: the view is freshly created at index time so there are no concurrent readers —CONCURRENTLYwould have required autocommit mode for no benefit.--forceis not passed.