Repository navigation
Fixes #37454: Leave memory extraction interrupted by a server stop for recovery - #37455
Conversation
A normal stop interrupts the background-job threads, and the LLM clients turn the interrupt into an LLMCompletionException. Every file and article being extracted was marked Failed and its job FAILED, so nothing retried them, while a crash left both in progress and recovered. A stop now leaves them as a crash would: - the file and article engines skip the Failed stamp when the run was interrupted (the thread flag, or an InterruptedException in the cause chain) and rethrow, so the job does not complete; - the text stage abandons an interrupted run, leaving the file Analyzing for the startup scan; - the worker leaves a memory extraction job that ends during stop() RUNNING, for the stale-job reaper to requeue. Other job types still fail on stop: nothing requeues them, and a RUNNING Collate admin-ops job blocks new jobs of its type. A real LLM failure still marks the document Failed and the job FAILED.
Text extraction runs on a pool a stop never interrupts, but the asset service's own shutdown hook closes object storage under it, so a stop still stamped files Failed. The engines and the worker now share one rule, Interruptions.isStopInterruption: ServerStopping is set, the thread was interrupted, or an InterruptedException caused the failure. The worker leaves a memory extraction job RUNNING under the same rule, so a document and its job can no longer disagree. The ServerStopping hook is now registered at startup, before any resource starts work. The decision is recorded in docs/decisions/ 2026-11-09-a-server-stop-leaves-memory-extraction-for-recovery.md.
The asset-service shutdown hook and the ServerStopping hook start together with nothing ordering them, so a text read failing on the just-closed client could still see the flag unset and stamp the file Failed. The asset hook now raises ServerStopping itself before it closes, and the decision record states the ordering.
In a surge-first rollout the new server runs its startup scan before the old one stops, so files that stop leaves Uploaded or Analyzing have no job and nothing resubmits them. Every server now sweeps every five minutes and resubmits such files once they have been idle for 30 minutes. ExtractingContext stays with the stale-job reaper. Also: - the asset-service shutdown hook registers a task the tests run; - the stop-path logs name the failure; - timeouts are pinned as real failures; - the decision record and Javadocs describe each stage's actual recovery.
ContextFileStaleTextStageQueryIT inserts context files years back and asserts exactly which ones the sweep's query returns: stranded Uploaded and Analyzing files with a snapshot, inside the one-day look-back, oldest first, at most 50. It also pins the window and look-back edges.
The stale text-stage sweep resubmitted files unclaimed and uncapped, every five minutes, from every server, for a day. That re-ran the AI step automatically. A text stage that a normal stop cuts short is now stamped Failed with "Interrupted by a server stop", and its owner or an admin recovers it with Retry. A crash still leaves no stamp, so the startup scan resumes it. The memory stage is unchanged: it stays in progress, with its job RUNNING for the stale-job reaper. Also: the stop logs name the root cause, and the worker shares one helper for a job left for recovery.
…ason for a parse failure
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
Code Review ✅ Approved 🟡 Medium risk 2 closed / 2 findingsChanges shutdown recovery for memory and text extraction; misclassified interruptions could strand work or cause failed extraction jobs to be retried. Preserves memory extraction runs interrupted by a server stop so they resume after restart, and marks interrupted text-stage runs as Failed with ✅ 2 closed✅ Bug: Resubmitted Analyzing file keeps stale updatedAt, so it's swept every pass
✅ Edge Case: Stop stamp can overwrite a peer run's finished text result
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
Local Java test run: PASSED — details
Tests run locally
Broader coverage not executed by this focused run
Impacted, not run locally (4)
Commandsmvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AssetServiceFactoryTest,ContextFileProcessingServiceTest,GenericBackgroundWorkerTest,InterruptionsTest,OpenMetadataApplicationTest,PageContextProcessingEngineTest -Dsurefire.failIfNoSpecifiedTests=false |
Resolve conflicts with the squashed #37581 (identical content) and with #37455, which added a CONTEXT_MEMORY_EXTRACTION check and recovery tests written against the removed BackgroundJob.JobType enum. Both now compare against BackgroundJobTypes; the "every type but memory extraction" case lists the same values as strings.
Describe your changes:
Fixes #37454
A normal server stop no longer fails a document's memory extraction silently, and it never retries anything without a person.
Interrupted by a server stop, and its owner or an admin recovers it with Retry (Fixes #37478: Let a document's owners or an admin extract or retry its memories #37479).Type of change:
High-level design:
One stop rule.
Interruptions.isStopInterruption(failure)(injobs) treats a failure as a stop when any of these holds:ServerStopping);InterruptedExceptionis in the cause chain.The text stage, both memory stages (files and articles) and the worker use it, so a document and its job reach the same verdict.
Memory stage. A
CONTEXT_MEMORY_EXTRACTIONjob that ends in a stop interruption stays RUNNING, and the stale-job reaper requeues it. The file keeps ExtractingContext, and the article keeps its status.Text stage. A stop interruption stamps the file Failed with
Interrupted by a server stop, through the existing conditional write.Shutdown order.
ServerStopping's hook is registered early inOpenMetadataApplication.run().Logs. Stop paths log the root cause.
Record: new
docs/decisions/2026-11-09-a-server-stop-leaves-memory-extraction-for-recovery.md.Tests:
Use cases covered
Interrupted by a server stop, and queues no memory job. This holds both for an interrupt in the cause chain and when the asset service has already closed.SocketTimeoutException,HttpTimeoutException) are not stop interruptions.Unit tests
512c15e1e1330d5e8500e9bfa48bc04ffdf16505found no unanswered Important findings.Backend integration tests
Local Java test run: PASSED
512c15e1e133(baseorigin/main)--scope full).The focused run passed on the refreshed head. Earlier verification ran
ContextMemoryExtractionITwith 7 passing tests before the main update. A manual stop/restart with multi-chunk extraction and full affected coverage remain pending.Focused Java test details
Local Java test run: PASSED — details
512c15e1e133(baseorigin/main)Tests run locally
AssetServiceFactoryTest(2 passed),ContextFileProcessingServiceTest(30 passed),GenericBackgroundWorkerTest(19 passed),InterruptionsTest(5 passed),OpenMetadataApplicationTest(1 passed),PageContextProcessingEngineTest(14 passed)Broader coverage not executed by this focused run
mvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AlertingArchitectureTest,AssetServiceFactoryTest,BackgroundJobCleanupSchedulerTest,ContextFileProcessingServiceTest,ContextMemoryExtractionJobHandlerTest,ContextProcessingUpdatesTest,GenericBackgroundWorkerTest,InterruptionsTest,OntologyPublicationStatusResolverTest,OpenMetadataApplicationAuthReloadTest,OpenMetadataApplicationPushFeedUpgradeTest,OpenMetadataApplicationTest,PageContextProcessingEngineTest,SearchSettingsMergeUtilRepositoryResolutionTest -Dsurefire.failIfNoSpecifiedTests=falsemvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<495 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=falsemvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state '-Dit.test=<34 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=falsemvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=rdf '-Dit.test=<37 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=falsemvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=parallel -Dit.test=AlertStateIT,BundleWarmupCertificationIT,ContainerCacheCorrectnessIT,EntityCacheWriteOrderIT,OneTransactionFlushAtomicityIT,RelationshipCacheInvalidationIT,TagRenameCacheIT,UncachedReadIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=falsemvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=global-state -Dit.test=CredentialRedisDownIT,CredentialRedisNoRoundTripIT,SessionRedisMultiNodeIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=falsemvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=parallel -Dit.test=FlattenedChildrenHighlightSearchIT,InheritedFieldPropagationRecoveryIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=falsemvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=global-state -Dit.test=PatchTableEmbeddingIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=falseImpacted, not run locally (4)
RdfCatalogScaleIT→ only with -DrdfCatalogScale=true, which no CI lane setsReindexBenchmarkIT→ nightly: openmetadata-nightly k8s-java-it (scale-it)EntityLoaderSmokeUIIT→ nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)SearchAvailableAllKindsDuringReindexUIIT→ nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)Commands
UI screen recording:
Not applicable: backend-only change.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.md: a task review, a whole-branch review, a re-review of its fix wave, and a re-review of the text-stage change. No Critical or Important finding remains.Interrupted by a server stop; Retry then shows the real error.🤖 Generated with Claude Code
Summary by Gitar
Interrupted by a server stopviarecordTextFailureContextFileRecoverySchedulerand its test, so no sweep resubmits text-stage filesThis will update automatically on new commits.