Skip to content

Revert "fix: duplicate document ingest guard" - #15707

Merged
wangq8 merged 1 commit into
mainfrom
revert-15638-b063
Jun 5, 2026
Merged

wangq8 merged 1 commit into
mainfrom
revert-15638-b063

Conversation

@wangq8

@wangq8 wangq8 commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Reverts #15638

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: abeab756-5a09-46c5-88c4-bd007d30bb69

📥 Commits

Reviewing files that changed from the base of the PR and between 214ee31 and c79d005.

📒 Files selected for processing (2)
  • api/apps/restful_apis/document_api.py
  • api/db/services/common_service.py

📝 Walkthrough

Walkthrough

This PR removes the optimistic-locking pattern (update_by_id_if_update_time) from the document service and refactors the ingest cancellation flow to use direct task queries and unconditional updates instead of conditional update-on-match logic.

Changes

Document cancel flow simplification

Layer / File(s) Summary
Remove optimistic-locking method
api/db/services/common_service.py
CommonService.update_by_id_if_update_time (conditional update when update_time matches) is removed; update_by_id remains unchanged, setting update_time/update_date and returning the updated-row count.
Refactor cancel flow to direct updates
api/apps/restful_apis/document_api.py
Task-service imports drop has_canceled. The _run_sync cancellation branch now checks document run state and unfinished tasks directly, calls cancel_all_task_of(doc_id) when allowed, and uses an unconditional DocumentService.update_by_id(doc_id, info) instead of conditional update-on-affected-rows logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • infiniflow/ragflow#15638: Both PRs touch document_api._run_sync's ingest/TaskStatus.RUNNING concurrency logic and the supporting optimistic-locking mechanism in CommonService/DocumentService (one adds update_by_id_if_update_time + guarded duplicate ingest/cancellation, the other removes update_by_id_if_update_time and refactors the TaskStatus.CANCEL handling accordingly).
  • infiniflow/ragflow#14351: Both PRs modify api/apps/restful_apis/document_api.py's _run_sync flow for the ingest/run endpoint—especially the TaskStatus.CANCEL handling and its task-query/cancellation logic—so the main PR is directly related to the retrieved PR's endpoint migration changes.

Suggested labels

size:XS

Poem

🐰 Away goes the lock that once would match,
Replaced with queries swift and direct catch.
Simpler paths for cancels to take,
No conditional waits for updates to make!


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.

@wangq8
wangq8 marked this pull request as ready for review June 5, 2026 09:45
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 5, 2026
@wangq8
wangq8 merged commit aa9545e into main Jun 5, 2026
6 checks passed
@yingfeng
yingfeng deleted the revert-15638-b063 branch June 11, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant