Skip to content

Fix knowledge compiler Go port regressions (MySQL 1101 + Start deadlock) - #17599

Merged
yuzhichang merged 3 commits into
infiniflow:mainfrom
yuzhichang:fix/kc-docs-mysql-default
Jul 31, 2026
Merged

yuzhichang merged 3 commits into
infiniflow:mainfrom
yuzhichang:fix/kc-docs-mysql-default

Conversation

@yuzhichang

@yuzhichang yuzhichang commented Jul 31, 2026 •

Copy link
Copy Markdown
Member

Two regressions from #17536: (1) MySQL 8.0 AutoMigrate crash on knowledge_compile_docs (Error 1101) from a TEXT default; (2) ingestor Start() sync.Once re-entrant deadlock. Both fixed with regression tests.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 31, 2026
@coderabbitai

coderabbitai Bot commented Jul 31, 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: a87abf80-bc4c-4798-b247-f1dfe7522ba7

📥 Commits

Reviewing files that changed from the base of the PR and between bee7423 and 76e193e.

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

📝 Walkthrough

Walkthrough

The change separates worker-pool startup synchronization from overall ingestor startup, adds a full-path lifecycle regression test, exposes message-queue engine setup, and removes MySQL-incompatible defaults from two JSON TEXT columns.

Changes

Ingestion startup and document persistence

Layer / File(s) Summary
Remove incompatible TEXT defaults
internal/entity/knowledge_compile_doc.go
The BacklogDocIDs and InflightDocIDs GORM tags no longer define literal database defaults. Comments document explicit application initialization.
Separate worker startup synchronization
internal/ingestion/service/ingestion_service.go, internal/engine/global.go, internal/ingestion/service/ingestor_lifecycle_test.go
startWorkerPool uses workerOnce instead of startOnce. SetMessageQueueEngine configures the global message-queue engine. The lifecycle test starts an ingestor with embedded NATS and verifies that workers become active.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Poem

A rabbit starts the worker train,
sync.Once no longer blocks the lane.
NATS helps the test run bright,
TEXT defaults leave the site.
Empty arrays arrive by code.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies both primary regressions and the corresponding fixes.
Description check ✅ Passed The description briefly explains both regressions, their fixes, and the added regression tests.
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.

Drop the literal DEFAULT '[]' on the TEXT columns backlog_doc_ids / inflight_doc_ids. MySQL 8.0.13+ rejects a literal default on TEXT/BLOB columns, so GORM's AutoMigrate failed with Error 1101 and the API server could not start. The scheduler already writes '[]' explicitly on insert (FirstOrCreate) and on release, so the DDL default was redundant.
Start() wraps start() in e.startOnce.Do, but start() called
startWorkerPool() which nested the same startOnce. sync.Once.Do
blocks forever when re-entered from inside its own callback, so
Start() hung after InitConsumer succeeded: no worker pool, no
consumeLoop, and ingestion tasks were never consumed (stuck in
CREATED). Give startWorkerPool its own workerOnce.

Add TestStart_FullPathReturnsAndStartsWorkers which drives the real
Start() path against an embedded NATS server and asserts Start()
returns within a deadline with workers up; it fails (10s timeout)
without the fix.
@yuzhichang
yuzhichang force-pushed the fix/kc-docs-mysql-default branch from c66aad3 to bee7423 Compare July 31, 2026 03:09
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jul 31, 2026
@yuzhichang yuzhichang changed the title Fix MySQL 8.0 AutoMigrate crash on knowledge_compile_docs table Fix knowledge compiler Go port regressions (MySQL 1101 + Start deadlock) Jul 31, 2026
@yuzhichang yuzhichang added the ci Continue Integration label Jul 31, 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

🤖 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/service/ingestor_lifecycle_test.go`:
- Around line 236-238: Update the activeWorkers assertion in the Start()
lifecycle test to poll until at least one worker is active or a deadline
expires, matching the established approach in
TestStartWorkerPool_StartOnceIdempotent. Keep the existing failure message and
assert only after the wait completes.
- Around line 216-220: Update the test setup around SetMessageQueueEngine to
capture the existing message-queue engine before calling SetupNatsEngine(t),
then register cleanup immediately afterward to restore that saved engine. Keep
the existing ing.Stop cleanup and ensure restoration occurs after the injected
test engine is no longer needed.
🪄 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: 901a5419-b4da-4074-93ea-d3f05bf15d15

📥 Commits

Reviewing files that changed from the base of the PR and between c66aad3 and bee7423.

📒 Files selected for processing (4)
  • internal/engine/global.go
  • internal/entity/knowledge_compile_doc.go
  • internal/ingestion/service/ingestion_service.go
  • internal/ingestion/service/ingestor_lifecycle_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/entity/knowledge_compile_doc.go

- Save and restore the previous message-queue engine around the new
  Start() full-path test so later tests don't inherit a closed embedded
  NATS server (SetMessageQueueEngine is process-global).
- Poll briefly for activeWorkers instead of asserting immediately, since
  Start() launches workers asynchronously (avoids a flaky assertion).
@yuzhichang
yuzhichang merged commit 650387b into infiniflow:main Jul 31, 2026
3 checks passed
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: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