Skip to content

fix(parity): resume continues from saved position instead of restarting - #2009

Merged
Eli Bosley (elibosley) merged 1 commit into
unraid:mainfrom
jandrop:fix/parity-resume-restart-1815
May 18, 2026
Merged

fix(parity): resume continues from saved position instead of restarting#2009
Eli Bosley (elibosley) merged 1 commit into
unraid:mainfrom
jandrop:fix/parity-resume-restart-1815

Conversation

@jandrop

@jandrop Jandrop (jandrop) commented May 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #1815.

Root cause

emhttpd identifies parity-check actions by the form field NAME, not the value. The current resolver posts cmdCheck=Resume, which falls through to the plain cmdCheck submit handler (start a fresh check) and discards mdResyncPos, so a resumed parity restarts from byte 0.

The Unraid web UI submits dynamic field names with empty values (see /usr/local/emhttp/plugins/dynamix/ArrayOperation.page:330-338):

<input type="hidden" name="cmdCheckResume" value="">

Fix

Realign ParityService.updateParityCheck to match the web UI's field names:

const states = {
    pause:  { cmdCheckPause:  '' },
    resume: { cmdCheckResume: '' },
    cancel: { cmdCheckCancel: '' },
    start:  { cmdCheck: 'Check' },   // unchanged
};

pause and cancel previously used cmdNoCheck=Pause/cmdNoCheck=Cancel, which seem to have worked via fallback handling in emhttpd — they're realigned here too so the API contract matches the web UI exactly.

Tests

Adds parity.service.spec.ts covering each state and a regression test that fails if cmdCheck=Resume is reintroduced. 8 tests pass.

Manual verification

Tested live on Unraid 7.3.0 by patching the running bundle and exercising start → pause → resume via GraphQL:

Stage mdResyncPos
Before pause 521 044
After pause 1 655 644 (saved)
After resume 2 395 484 (continued growing, not reset to 0)

Summary by CodeRabbit

  • Bug Fixes

    • Fixed parity check pause, resume, and cancel operations to align with system expectations
    • Resume operations now correctly preserve progress position
  • Tests

    • Added comprehensive unit test suite for parity check control functionality

Review Change Stack

emhttpd identifies parity-check actions by the form-field NAME, not
the value. Posting `cmdCheck=Resume` falls through to the plain
`cmdCheck` submit handler (start a fresh check), discarding the
saved mdResyncPos and restarting the parity from byte 0.

Realign the action map with the dynamic field names the Unraid web
UI actually submits (see /usr/local/emhttp/plugins/dynamix/
ArrayOperation.page:330-338):
  pause   -> cmdCheckPause:  ''
  resume  -> cmdCheckResume: ''
  cancel  -> cmdCheckCancel: ''
  start   -> cmdCheck:       'Check'   (unchanged)

Add a parity.service.spec.ts covering each state and a regression
test that fails if `cmdCheck=Resume` is reintroduced.

Closes unraid#1815
Copilot AI review requested due to automatic review settings May 18, 2026 21:49
@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fdfe6e37-9afe-49aa-bdcc-7eaf8b3f9989

📥 Commits

Reviewing files that changed from the base of the PR and between a2d4843 and 6316c8f.

📒 Files selected for processing (2)
  • api/src/unraid-api/graph/resolvers/array/parity.service.spec.ts
  • api/src/unraid-api/graph/resolvers/array/parity.service.ts

Walkthrough

This PR fixes parity check resume restarting from the beginning instead of continuing. The implementation switches updateParityCheck to use Unraid web UI–compatible action-detection field names with empty values, and adds comprehensive test coverage validating the corrected behavior across all control states.

Changes

Parity Resume Field Naming

Layer / File(s) Summary
Command field name alignment
api/src/unraid-api/graph/resolvers/array/parity.service.ts
updateParityCheck switches from value-based command fields (cmdNoCheck: 'Pause', cmdCheck: 'Resume') to action-detection field names with empty values (cmdCheckPause: '', cmdCheckResume: '', cmdCheckCancel: ''). Inline comments explain that Unraid identifies the action by field NAME rather than value, preventing resume from falling through as a start/resume mismatch.
Parity update behavior test suite
api/src/unraid-api/graph/resolvers/array/parity.service.spec.ts
Full unit test coverage for updateParityCheck validates correct emcmd payload construction for all states (resume, pause, cancel, start with optional correction), guard logic for already-running and invalid states, and GraphQLError wrapping of emcmd failures.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A pause, a resume, back to the start—
The UI fields guide us, playing their part!
Field names, not values, control the way,
Your parity check won't restart today! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main fix: changing parity resume behavior to continue from saved position instead of restarting.
Linked Issues check ✅ Passed The PR directly addresses issue #1815 by fixing the parity resume mechanism to preserve mdResyncPos position, matching Unraid web UI behavior via field-name-based action detection.
Out of Scope Changes check ✅ Passed All changes are scoped to parity service resume/pause/cancel/start functionality; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

Copilot AI 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.

Pull request overview

Fixes parity-check resume behavior so it continues from the saved mdResyncPos rather than restarting from byte 0, aligning the API’s emcmd payload with the Unraid web UI’s expected (name-based) form fields.

Changes:

  • Update ParityService.updateParityCheck to send cmdCheckPause, cmdCheckResume, and cmdCheckCancel (empty values) instead of value-driven fields.
  • Add Vitest coverage for each parity-check state plus a regression test to prevent reintroducing cmdCheck=Resume.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
api/src/unraid-api/graph/resolvers/array/parity.service.ts Switches parity pause/resume/cancel commands to the Unraid web UI’s field-name-based payloads so resume doesn’t restart.
api/src/unraid-api/graph/resolvers/array/parity.service.spec.ts Adds unit tests validating the exact emcmd payload for each parity action, including a regression for the resume bug.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@elibosley
Eli Bosley (elibosley) merged commit 329f66f into unraid:main May 18, 2026
13 of 15 checks passed
@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.68%. Comparing base (a2d4843) to head (6316c8f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2009      +/-   ##
==========================================
+ Coverage   52.59%   52.68%   +0.09%     
==========================================
  Files        1033     1033              
  Lines       71682    71688       +6     
  Branches     8181     8201      +20     
==========================================
+ Hits        37698    37769      +71     
+ Misses      33858    33793      -65     
  Partials      126      126              

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

SimonFair pushed a commit that referenced this pull request Jun 1, 2026
🤖 I have created a release *beep* *boop*
---


## [4.35.0](v4.34.0...v4.35.0)
(2026-05-29)


### Features

* Add read-only network metrics API
([#2003](#2003))
([a1d1eea](a1d1eea))


### Bug Fixes

* **cpu:** add legacy telemetry fallbacks
([#2011](#2011))
([97f5425](97f5425))
* forked plugin publish workflow
([#2014](#2014))
([eb60d4d](eb60d4d))
* **parity:** resume continues from saved position instead of restarting
([#2009](#2009))
([329f66f](329f66f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

Parity resume mutation restart the parity check

3 participants