mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-12 06:35:44 +08:00
Fix: overlapping document parse race that can clear chunks (#13900)
### What problem does this PR solve? This PR fixes a race in batch document parsing where overlapping parse requests for the same document could clear/rewrite chunk state and make previously parsed content appear lost. It adds an atomic per-document parse guard so only one parse can run at a time for that document (Fixes #13864 ). ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -747,14 +747,14 @@ class TestDocRoutesUnit:
|
||||
monkeypatch.setattr(module.DocumentService, "query", lambda **_kwargs: [_DummyDoc(run=module.TaskStatus.RUNNING.value)])
|
||||
monkeypatch.setattr(
|
||||
module.DocumentService,
|
||||
"update_by_id",
|
||||
lambda *_args, **_kwargs: (_ for _ in ()).throw(AssertionError("update_by_id must not be called for running docs")),
|
||||
"filter_update",
|
||||
lambda *_args, **_kwargs: 0,
|
||||
)
|
||||
res = _run(module.parse.__wrapped__("tenant-1", "ds-1"))
|
||||
assert "currently being processed" in res["message"]
|
||||
|
||||
monkeypatch.setattr(module.DocumentService, "query", lambda **_kwargs: [_DummyDoc(progress=0)])
|
||||
monkeypatch.setattr(module.DocumentService, "update_by_id", lambda *_args, **_kwargs: True)
|
||||
monkeypatch.setattr(module.DocumentService, "filter_update", lambda *_args, **_kwargs: 1)
|
||||
monkeypatch.setattr(module.DocumentService, "get_by_id", lambda _id: (True, _DummyDoc()))
|
||||
monkeypatch.setattr(module.File2DocumentService, "get_storage_address", lambda **_kwargs: ("b", "n"))
|
||||
_patch_docstore(monkeypatch, module, delete=lambda *_args, **_kwargs: None)
|
||||
|
||||
Reference in New Issue
Block a user