Skip to content

fix: clean rebuild, stateless run guard#40

Merged
dvdl16 merged 3 commits into
version-15from
fix/stale-records
Jul 6, 2026
Merged

fix: clean rebuild, stateless run guard#40
dvdl16 merged 3 commits into
version-15from
fix/stale-records

Conversation

@dvdl16

@dvdl16 dvdl16 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Description

fix: clean rebuild, stateless run guard

Fixes for internal refs:

  • TASK-2026-00417
  • TASK-2026-00418

Type of change

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Tests

  • Unit Tests have been updated or added, as required
  • UI Tests have been updated or added, as required

Checklist:

  • My code follows Naming Guidelines (DocType, Field and Variable naming)
  • No Form changes / My code follows the Form Design Guidelines
  • My code follows the Coding Standards of this project
  • My code follows the Code Security Guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas / No comments necessary
  • I have made corresponding additions/changes to the documentation
  • All business logic and validations are on the server-side / No business logic or validation changes
  • No patches are necessary / Migration Patches have been added to the correct subdirectory of /patches and patches.txt have been updated

User Experience:

N/A

dvdl16 added 3 commits July 6, 2026 16:04
1. Clean rebuild (create_mrp_item_entries) The full row set is now computed before the delete, then the table is deleted + committed before the bulk insert (also committed). The commit makes the clear durable so it can't be silently lost, turning the run back into a genuine rebuild instead of an ignore_duplicates append that left old generations (and headerless, invisible items) behind. Dropped ignore_duplicates so a dirty table fails loudly, and added a header/item-count invariant check. Commits are skipped under frappe.flags.in_test to preserve test isolation.

2. Stateless run guard (_finalise_in_progress) Replaced the un-filtered, silent _finalise_jobs_in_progress with a queue-derived check: only the most recent run's finalise batches count (age filter fixes the ancient-phantom deadlock), and jobs wedged past MRP_FINALISE_CEILING_MINUTES fail *open* (rebuild anyway + alert) rather than blocking forever. Skips are now visible. Uses now_datetime() for system-tz-consistent age math. trigger_mrp_run reuses the same helper.
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.86957% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
erpnext_mrp/mrp/tasks/mrp_run.py 62.22% 17 Missing ⚠️
erpnext_mrp/__init__.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@dvdl16 dvdl16 merged commit 8af1e79 into version-15 Jul 6, 2026
5 of 6 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.

1 participant