Skip to content

fix(ingestion): discard stale checkpoint when the DSL is edited before resume - #17351

Merged
yuzhichang merged 4 commits into
infiniflow:mainfrom
xugangqiang:fix/dsl-resume-finger-print
Jul 24, 2026
Merged

yuzhichang merged 4 commits into
infiniflow:mainfrom
xugangqiang:fix/dsl-resume-finger-print

Conversation

@xugangqiang

Copy link
Copy Markdown
Contributor

Summary

  • Root cause: Pipeline.Run keys the eino checkpoint by taskID only. Resuming a failed run after the user edits the pipeline DSL recompiles a graph with different topology, but the old checkpoint (bound to the previous graph's node ids / wiring) is restored, causing eino to error.
  • Fix: fingerprint the DSL file (full canvas DSL) and the runtime override_params, persisted next to the eino checkpoint. On resume, if either fingerprint differs, discard the stale checkpoint + interrupt marker and re-run from scratch. The warning log distinguishes a DSL-file edit from a runtime-override edit.

Test plan

  • TestPipelineRunResumableDSLChanged: editing the DSL between runs discards the checkpoint and re-runs from scratch.
  • TestPipelineRunResumableOverrideChanged: editing only the runtime override does the same.
  • TestClassifyDSLChange: unit-tests the mismatch-reason classifier.
  • bash build.sh --test ./internal/ingestion/pipeline/... passes.

Notes

  • Component-code changes (e.g. a component's output contract) are not covered by the DSL fingerprint; that is a separate, smaller-blast-radius gap noted in code comments.

…e resume

Resuming a failed ingestion run with a modified pipeline DSL previously
errored: eino checkpoints are bound to the graph's node ids / wiring, so
restoring old state into a recompiled (different) graph fails.

Detect the change by fingerprinting the DSL file (full canvas DSL) and the
runtime override_params, persisted alongside the eino checkpoint. On resume,
if either fingerprint differs from the stored one, drop the stale checkpoint
and the interrupt marker and start a fresh run instead of erroring. The
warning log distinguishes a DSL-file edit from a runtime-override edit.

Add unit/integration tests covering both mismatch branches.

Signed-off-by: xugangqiang <[email protected]>
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1422f48e-fb9c-42d0-9964-2af3df09dac2

📥 Commits

Reviewing files that changed from the base of the PR and between 69f8f79 and 2baed46.

📒 Files selected for processing (1)
  • internal/ingestion/pipeline/pipeline.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/ingestion/pipeline/pipeline.go

📝 Walkthrough

Walkthrough

Resumable pipelines now fingerprint canonical DSL and runtime overrides before checkpoint resume. Mismatches discard stale checkpoints and interrupt markers, while completion or cancellation cleanup removes fingerprint entries. Tests cover DSL changes, override changes, classification, lookup errors, restart behavior, and cleanup.

Changes

Resumable pipeline guards

Layer / File(s) Summary
Fingerprint capture and computation
internal/ingestion/pipeline/pipeline.go
Pipelines store canonicalized DSL bytes and compute fingerprints for DSL and runtime override parameters.
Resume validation and cleanup
internal/ingestion/pipeline/pipeline.go
Resumable runs validate fingerprints before resume, discard stale checkpoint state on mismatch, persist current fingerprints, and remove them during completion or cancellation cleanup.
Resume guard test coverage
internal/ingestion/pipeline/pipeline_test.go
Tests verify DSL and override changes restart execution, classify mismatch reasons, handle checkpoint lookup errors, and delete checkpoints with associated fingerprints.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PipelineRun
  participant guardDSLChange
  participant CheckPointStore
  participant RunTracker
  PipelineRun->>guardDSLChange: validate DSL and override fingerprints
  guardDSLChange->>CheckPointStore: read stored fingerprints
  guardDSLChange->>CheckPointStore: delete stale checkpoint on mismatch
  guardDSLChange->>RunTracker: clear persisted interrupt ID
  guardDSLChange->>CheckPointStore: write current fingerprints
Loading

Poem

A rabbit hashes trails in the snow,
Checks old checkpoints before they go.
New DSL hops, overrides shine,
Stale paths vanish, runs realign.
“Fresh starts!” the bunny sings,
While cleanup clears old strings.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: discarding stale ingestion checkpoints when the DSL changes before resume.
Description check ✅ Passed The description provides the required summary context and includes helpful test plan and notes, so it is sufficiently complete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@xugangqiang xugangqiang added the ci Continue Integration label Jul 24, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
internal/ingestion/pipeline/pipeline.go (1)

553-557: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Align cancellation cleanup with success cleanup.

cleanupCheckpoint currently deletes only cpID, while the success path also deletes the DSL/override fingerprint keys. Add cpID:dsl and cpID:ovf deletes to cleanupCheckpoint so cancelled resumable runs do not leave orphaned fingerprint entries.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/pipeline/pipeline.go` around lines 553 - 557, Update
cleanupCheckpoint to delete the DSL and override fingerprint keys alongside
cpID, matching the success cleanup path by invoking store.Delete for
cpID+dslKeySuffix and cpID+ovfKeySuffix while preserving the existing BestEffort
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/ingestion/pipeline/pipeline.go`:
- Around line 245-261: Remove the duplicated first documentation paragraph
preceding dslFileFingerprint, preserving the newer paragraph that documents the
rawDSL error behavior and hashing contract.
- Around line 330-354: Update the checkpoint validation flow around store.Get
and fingerprint persistence to handle errors before writing new fingerprints. If
the cpID lookup fails, return or otherwise skip the dslKey/ovfKey updates;
likewise, if either stored fingerprint lookup fails, avoid overwriting
fingerprints and continue the existing error handling path. Preserve
stale-checkpoint deletion only for successful reads that identify a mismatch,
using the store.Get results in the surrounding checkpoint logic.

---

Nitpick comments:
In `@internal/ingestion/pipeline/pipeline.go`:
- Around line 553-557: Update cleanupCheckpoint to delete the DSL and override
fingerprint keys alongside cpID, matching the success cleanup path by invoking
store.Delete for cpID+dslKeySuffix and cpID+ovfKeySuffix while preserving the
existing BestEffort behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f47ac27-f115-4d6f-86ef-d4d523674508

📥 Commits

Reviewing files that changed from the base of the PR and between bdfc3ad and 610d9bc.

📒 Files selected for processing (2)
  • internal/ingestion/pipeline/pipeline.go
  • internal/ingestion/pipeline/pipeline_test.go

Comment thread internal/ingestion/pipeline/pipeline.go Resolved
Comment thread internal/ingestion/pipeline/pipeline.go Resolved
xugangqiang and others added 3 commits July 24, 2026 17:19
cleanupCheckpoint now deletes the cpID:dsl and cpID:ovf fingerprint
keys alongside the eino checkpoint, so they share one lifecycle on
cancellation instead of lingering up to TTL while the checkpoint is gone.

Update TestCleanupCheckpoint_DeletesStoreAndClearsTracker to assert all
three keys are removed.

Signed-off-by: xugangqiang <[email protected]>
Address CodeRabbit findings on PR infiniflow#17351:

1. Remove the duplicated doc-comment paragraph preceding
   dslFileFingerprint.

2. guardDSLChange now bails out entirely when store.Get(cpID) returns
   an error (or when the dslKey/ovfKey reads fail), instead of
   overwriting cpID:dsl / cpID:ovf with current fingerprints. Writing
   fingerprints after a failed lookup could mask a real stale-checkpoint
   mismatch on a later resume, defeating the DSL-change guard. A fresh
   run (cpID lookup succeeds with no checkpoint) still records both
   fingerprints so a later resume can detect edits.

Add TestGuardDSLChange_CheckpointLookupErrorSkipsOverwrite to lock in
the read-failure skip behavior.

Signed-off-by: xugangqiang <[email protected]>
@yuzhichang

Copy link
Copy Markdown
Member

LGTM

@yuzhichang
yuzhichang merged commit 75c9af3 into infiniflow:main Jul 24, 2026
3 checks passed
@xugangqiang

Copy link
Copy Markdown
Contributor Author

Discussion: is the DSL canonicalization round-trip necessary?

While reviewing this PR, a question came up about NewPipelineFromDSL doing json.Marshal(canvasDSL) to produce a "canonical" byte form before hashing it for the resume fingerprint.

Finding: the round-trip is redundant for the canvas path. The canvas DSL is loaded from the DB (user_canvas.dsl longtext) into entity.JSONMap (map[string]interface{}); on read it is json.Unmarshal-ed (order lost) and then json.Marshal-ed again in loadDSLFromCanvas (internal/ingestion/task/pipeline_executor.go). Go's json.Marshal sorts map keys, so the string reaching NewPipelineFromDSL is already deterministic — re-serializing it adds nothing.

For built-in templates (static .json files), a formatting-only change is a deliberate commit and the only cost of a false positive is a one-time fresh re-run, so the stakes are low.

Conclusion / next step: the current canonicalization can safely be dropped (store the incoming dsl bytes directly), but we are deferring that simplification and keeping the present behavior for now. The decision — including where to compute the fingerprint and whether to keep the rawDSL field — is tracked separately in #17365.

@xugangqiang
xugangqiang deleted the fix/dsl-resume-finger-print branch August 12, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants