Skip to content

A source's queued status and its sync job commit together, so a failed job insert no longer leaves the source stuck as queued - #1451

Merged
WaylandYang merged 2 commits into
deeplethe:devfrom
Floating-Y:fix/atomic-source-sync
Nov 10, 2026
Merged

WaylandYang merged 2 commits into
deeplethe:devfrom
Floating-Y:fix/atomic-source-sync

Conversation

@Floating-Y

@Floating-Y Floating-Y commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Why

A failed sync_source insert can leave a source committed as queued and prevent later scheduling.

What changes

Commit the queued-state update, task insertion and notification in one transaction for initial, manual and scheduled sync. Preserve Drive's additional sync request while queued/running and its independent configuration save.

Keep only two failure/rollback regressions: manual HTTP sync and Drive selection. Fault injection is limited to each fixture source. Each test drops its trigger and function before propagating failed checks; test comments are Chinese.

Existing orphan states need separate reviewed recovery. Checkpoints, completion states and retry budgets are unchanged.

How it was checked

Rebased onto dev at e964eb4f; commit 594c90bb. Windows, Rust 1.98.0, dedicated PostgreSQL 16/pgvector with 112 migrations; UTOPIA_TEST_REQUIRE_DB=1 and UTOPIA_TEST_REQUIRE_PDFTOTEXT=1 were set.

  • Both retained PostgreSQL regressions passed. Catalog checks found zero test_reject_source_sync% triggers and functions afterward.
  • Format, diff checks and cargo clippy --workspace --all-targets -- -D warnings passed.
  • cargo test --locked --workspace --no-fail-fast -- --test-threads=1: 1,823 harness OK, one failure, six pre-existing ignored tests. The sole failure was the upstream CLI restore test requiring missing local pg_dump. After supplying real PostgreSQL 16.11 clients, cargo test --locked -p utopia-cli --test restore -- --test-threads=1 passed all 13 tests, including real database backup/restore. Assertions were unchanged.
  • pnpm install --frozen-lockfile and pnpm build passed.

Optional external database/service probes and opt-in tests were not provisioned and are not claimed as real integration coverage. The workspace run used one harness thread, Poppler 26.09.0 with CJK data and process-only localhost proxy bypass.

Before review

  • Every commit is signed off.
  • Format and clippy pass; workspace results and the CLI rerun are recorded above.
  • SQL was exercised against a migrated dedicated PostgreSQL database with database tests required.

@WaylandYang WaylandYang 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.

Thanks, the fix is right. Please retitle to a sentence stating the behaviour, e.g. "A source's queued status and its sync job commit together, so a failed job insert no longer leaves the source stuck as queued". Please also keep only the failure/rollback regressions (the concurrent and Drive follow-up cases cover unchanged behaviour), drop the trigger and function when the test finishes instead of leaving them on jobs, and write the test comments in Chinese.

@WaylandYang

Copy link
Copy Markdown
Contributor

这个修复本身是对的,还是想合进去。但 10-26 提的四条到现在都没动,而且 #1474、#1455、#1427、#1359 已经改了 sources_routes.rs 和 sources.rs,分支现在有冲突。请:

  1. rebase 到 dev;
  2. 标题改成一句陈述行为的话;
  3. 测试只保留两个失败回滚的回归用例(并发和 Drive 后续的那两个测的是没变的行为);
  4. 测试结束时把 test_reject_source_sync 的 trigger 和 function 删掉,不要留在 jobs 表上;
  5. 测试注释用中文。

如果不想继续,说一声,我自己把 sources.rs 那四十行改动带一个测试重新提。一周没回复我就关掉。

Signed-off-by: Floating-Y <118035379+Floating-Y@users.noreply.github.com>
@Floating-Y
Floating-Y force-pushed the fix/atomic-source-sync branch from d9bb2c8 to 594c90b Compare November 9, 2026 03:36
@Floating-Y Floating-Y changed the title Commit source sync state and jobs atomically A source's queued status and its sync job commit together, so a failed job insert no longer leaves the source stuck as queued Nov 9, 2026
@Floating-Y

Copy link
Copy Markdown
Contributor Author

Sorry for the delay. I've addressed all five points and pushed commit 594c90b: rebased onto dev, updated the title, kept only the two failure/rollback regressions, added trigger/function cleanup, and changed the test comments to Chinese.

Both regressions pass, and I verified that no injection triggers or functions remain afterward. The PR description includes the updated validation results. Thanks for the feedback—it's ready for another review.

@WaylandYang
WaylandYang merged commit 4eb477e into deeplethe:dev Nov 10, 2026
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.

2 participants