Skip to content

Preserve Context Center metadata during processing - #36668

Merged
pmbrull merged 4 commits into
mainfrom
pmbrull/context-file-processing-updates
Nov 3, 2026
Merged

pmbrull merged 4 commits into
mainfrom
pmbrull/context-file-processing-updates

Conversation

@pmbrull

@pmbrull pmbrull commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Retain document sharing and other metadata when background processing records extraction results. File and page processing writes check the stored version and timestamp, refresh the snapshot for each retry, and queue another attempt if contention continues.

Type of change:

  • Bug fix

High-level design:

Extend the existing file/page conditional-write hooks and advance timestamps for consolidated edits. File and content status writes use a fresh read scope for each conditional attempt. File/page statistics and page status stamps use the shared retry helper. Exhaustion uses the existing text-executor resubmission and persistent derivation queues. No schema or migration changes.

Decision record: Context Center processing writes use current snapshots.

Tests:

Use cases covered

  • Sharing and descriptions survive edits during text extraction and document derivation.
  • Page body edits survive the final statistics update.
  • Conditional writes detect consolidated edits on MySQL and PostgreSQL, including same-millisecond timestamp changes.
  • File/content retries preserve current metadata and stop on changed heads or removed content.
  • Transient conflicts retry computed results; sustained conflicts queue replacement work.
  • Read and download checks continue returning 403 to another user after processing.

Unit tests

The final affected unit run executed 89 tests: 88 passed, one existing skip. The new content-cache case failed before the follow-up change; its two variants check immediate completion and retry after a concurrent edit. Additional cases independently exercise stale-head and removed-content handoffs. Timestamp/cache and both database SQL regressions were also confirmed failing before their implementation.

Measured JaCoCo coverage on added executable lines: 98.9% (94/95).

Coverage by source file
Source file Added lines Whole file
ContextFileProcessingService.java 100.0% 86.3%
ContextProcessingEngine.java 90.0% 98.0%
FileContextProcessingEngine.java 100.0% 92.3%
PageContextProcessingEngine.java 100.0% 96.6%
ContextFileRepository.java 100.0% 74.7%
KnowledgeAssetDAOs.java N/A 46.5%
KnowledgePageRepository.java 100.0% 70.2%

The DAO additions are SQL annotations, exercised against both database engines. The only uncovered added line is the unreachable exit of the bounded retry loop.

Generated with mvn -B org.jacoco:jacoco-maven-plugin:0.8.13:report -pl openmetadata-service -Djacoco.dataFile=/tmp/context-processing-reviewed-coverage.exec.

Backend integration tests

Runtime changes were validated at 03c94aa97eb1 against d02fec8480c7: 2,013 integration tests passed, 147 skipped, zero failures or errors. This includes the API regressions in ContextFileIT and ContextMemoryExtractionIT, plus derivation and RDF suites. Production code is unchanged in the final test-only commit.

Local Java test run: PASSED

  • Commit: b1a81d046353 (base 03c94aa97e)
  • Finished: 2026-10-30 10:22 UTC · 1.6 min
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-service (14 classes) 14 89 0 1 1.6 passed

All executed tests in the runtime verification below passed. Its planner status remains FAILED solely because it expects a report from the comment-only McpServiceResourceIT placeholder, tracked in #36553.

Runtime verification at 03c94aa

Local Java test run: FAILED

  • Commit: 03c94aa97eb1 (base d02fec8480)
  • Finished: 2026-10-30 10:09 UTC · 12.7 min
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-service (14 classes) 14 86 0 1 1.6 passed
integration mysql-elasticsearch · parallel 45 2103 0 147 4.2 FAILED
integration mysql-elasticsearch · isolated 3 14 0 0 3.2 passed
integration mysql-elasticsearch · rdf 2 43 0 0 3.7 passed

Selected but produced no report: McpServiceResourceIT (mysql-elasticsearch · parallel)

Tests run locally

  • unit · openmetadata-service (14 classes): ContextFileIndexTest (3 passed), ContextFileProcessingServiceTest (18 passed), ContextMemoryExtractionJobHandlerTest (4 passed), ContextProcessingConditionalWriteSqlTest (2 passed), ContextProcessingRepositoryTest (9 passed), ContextProcessingUpdatesTest (5 passed), DefaultContextEntityPromptLoaderTest (1 passed, 1 skipped), EntityRepositoryBulkFieldsTest (6 passed), FileContextProcessingEngineTest (2 passed), KnowledgePageParentResolutionTest (3 passed), KnowledgePageStorageJsonTest (3 passed), PageBodyTextContributorTest (10 passed), PageContextProcessingEngineTest (11 passed), PageIndexTest (8 passed)
  • integration · mysql-elasticsearch · parallel: 45 classes, 1956 tests executed (listed below)
  • integration · mysql-elasticsearch · isolated: ContextMemoryDerivationIT (5 passed), ContextMemoryExtractionIT (7 passed), ConversationSchemaMigrationIT (2 passed)
  • integration · mysql-elasticsearch · rdf: AgentSparqlResourceIT (22 passed), RdfMcpKnowledgeGraphIT (21 passed)

Per-class counts come from the test reports, which can credit a test to the wrong class when classes run concurrently, and keep only the last run of a nested class that several test classes inherit. The summary's step totals are Maven's own counts.

integration · mysql-elasticsearch · parallel: 46 classes

AIApplicationResourceIT (30 passed, 1 skipped), AIContextKnowledgeAuthorizationIT (21 passed, 1 skipped), AIContextMcpIT (35 passed, 2 skipped), AIContextRestIT (126 passed, 11 skipped), AIFrameworkControlResourceIT (6 passed), AIGovernancePolicyResourceIT (6 passed), AgentExecutionResourceIT (29 passed, 3 skipped), BaseEntityIT$ListEntityHistoryByTimestampPaginationTest (87 passed, 6 skipped), ConceptContextIT (64 passed, 9 skipped), ConfigResourceIT (24 passed, 1 skipped), ContextFileIT (7 passed), ContextMemoryAnchorIT (56 passed, 5 skipped), ContextMemoryConflictReviewIT (31 passed, 4 skipped), ContextMemoryCreateGrantIT (4 passed), ContextMemoryIT (92 passed, 8 skipped), ContextMemoryLifecycleIT (19 passed, 2 skipped), ContextMemoryQueryEvidenceIT (13 passed), ContextMemoryRelatedEntitiesReconcileIT (10 passed), ContextMemorySearchMatrixIT (3 passed), ContextMemorySourceEntityTiebreakIT (6 passed), ContextMemoryStatusMigrationIT (1 passed), ContextMemoryWriteAccessIT (13 passed, 1 skipped), ConversationResourceIT (7 passed), CredentialMcpRevocationIT (18 passed, 3 skipped), DatabaseSmokeIT (7 passed), GlossaryTermResourceIT (144 passed, 1 skipped), IngestionPipelineAgentTypeIT (23 passed), LLMModelResourceIT (188 passed, 21 skipped), LLMServiceResourceIT (5 passed), McpContextMemoryVisibilityIT (5 passed, 1 skipped), McpExecutionResourceIT (13 passed), McpIntegrationIT (18 passed, 2 skipped), McpOAuthIT (87 passed, 9 skipped), McpPermissionIT (25 passed, 2 skipped), McpRdfNotEnabledIT (37 passed, 3 skipped), McpSearchIT (22 passed), McpServerResourceIT (1 passed), McpToolsValidationIT (23 passed, 6 skipped), McpUserContextIT (8 passed), MetricAssetsIT (30 passed, 2 skipped), OntologyAiResourceIT (1 passed), PersonaAIContextIT (47 passed, 4 skipped), PromptTemplateResourceIT (91 passed, 13 skipped), SeedDataPresenceIT (9 passed), TableResourceIT (35 passed), UserResourceIT (291 passed, 12 skipped)

Final unit test classes and counts

Tests run locally

  • unit · openmetadata-service (14 classes): ContextFileIndexTest (3 passed), ContextFileProcessingServiceTest (21 passed), ContextMemoryExtractionJobHandlerTest (4 passed), ContextProcessingConditionalWriteSqlTest (2 passed), ContextProcessingRepositoryTest (9 passed), ContextProcessingUpdatesTest (5 passed), DefaultContextEntityPromptLoaderTest (1 passed, 1 skipped), EntityRepositoryBulkFieldsTest (6 passed), FileContextProcessingEngineTest (2 passed), KnowledgePageParentResolutionTest (3 passed), KnowledgePageStorageJsonTest (3 passed), PageBodyTextContributorTest (10 passed), PageContextProcessingEngineTest (11 passed), PageIndexTest (8 passed)
Earlier full branch verification at d02fec8, including PostgreSQL/OpenSearch

This run predates the fresh-scope follow-up. It records the original database and API coverage, including the glossary timeout and successful isolated rerun.

Local Java test run: FAILED

  • Commit: d02fec8480c7 (base origin/main)
  • Finished: 2026-10-30 09:28 UTC · 20.3 min
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-service (14 classes) 14 84 0 1 1.6 passed
integration mysql-elasticsearch · parallel 58 3695 1 326 4.9 FAILED
integration mysql-elasticsearch · isolated 3 14 0 0 3.2 passed
integration mysql-elasticsearch · rdf 2 43 0 0 3.7 passed
integration postgres-opensearch · parallel 11 1276 0 90 3.6 passed
integration postgres-opensearch · rdf 1 21 0 0 3.3 passed

Failed: GlossaryTermResourceIT#test_renameGlossaryTermPrefixExtension_keepsAssetGlossaryTagInSearch(TestNamespace)

Selected but produced no report: McpServiceResourceIT (mysql-elasticsearch · parallel)

The broad MySQL run timed out in the glossary search assertion named above. Rerunning GlossaryTermResourceIT alone with -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=GlossaryTermResourceIT passed: 305 passed, 23 skipped, zero failures or errors. The previously timed-out method passed on that rerun. The generated block retains the original broad-run result.

The planner also expects a report for the comment-only McpServiceResourceIT placeholder. That planner issue is tracked in #36553.

Tests run locally

  • unit · openmetadata-service (14 classes): ContextFileIndexTest (3 passed), ContextFileProcessingServiceTest (16 passed), ContextMemoryExtractionJobHandlerTest (4 passed), ContextProcessingConditionalWriteSqlTest (2 passed), ContextProcessingRepositoryTest (9 passed), ContextProcessingUpdatesTest (5 passed), DefaultContextEntityPromptLoaderTest (1 passed, 1 skipped), EntityRepositoryBulkFieldsTest (6 passed), FileContextProcessingEngineTest (2 passed), KnowledgePageParentResolutionTest (3 passed), KnowledgePageStorageJsonTest (3 passed), PageBodyTextContributorTest (10 passed), PageContextProcessingEngineTest (11 passed), PageIndexTest (8 passed)
  • integration · mysql-elasticsearch · parallel: 58 classes, 3369 tests executed (listed below)
  • integration · mysql-elasticsearch · isolated: ContextMemoryDerivationIT (5 passed), ContextMemoryExtractionIT (7 passed), ConversationSchemaMigrationIT (2 passed)
  • integration · mysql-elasticsearch · rdf: AgentSparqlResourceIT (22 passed), RdfMcpKnowledgeGraphIT (21 passed)
  • integration · postgres-opensearch · parallel: AIContextKnowledgeAuthorizationIT (27 passed, 5 skipped), BaseEntityIT$ListEntityHistoryByTimestampPaginationTest (94 passed, 3 skipped), ConfigResourceIT (13 passed), DatabaseSmokeIT (5 passed), DocStoreResourceIT (39 passed, 2 skipped), GlossaryTermResourceIT (85 passed, 4 skipped), KnowledgeCenterIT (149 passed, 17 skipped), KnowledgePageHierarchyIT (110 passed, 14 skipped), LearningResourceIT (32 passed, 6 skipped), SeedDataPresenceIT (1 passed, 1 skipped), TableResourceIT (99 passed), UserResourceIT (150 passed, 4 skipped)
  • integration · postgres-opensearch · rdf: RdfMcpKnowledgeGraphIT (21 passed)

Per-class counts come from the test reports, which can credit a test to the wrong class when classes run concurrently, and keep only the last run of a nested class that several test classes inherit. The summary's step totals are Maven's own counts.

integration · mysql-elasticsearch · parallel: 59 classes

AIApplicationResourceIT (16 passed), AIContextKnowledgeAuthorizationIT (21 passed, 1 skipped), AIContextMcpIT (68 passed, 7 skipped), AIContextRestIT (11 passed, 1 skipped), AIFrameworkControlResourceIT (1 passed), AIGovernancePolicyResourceIT (25 passed, 1 skipped), AgentExecutionResourceIT (89 passed, 10 skipped), AttachmentListIT (9 passed), BaseEntityIT$ListEntityHistoryByTimestampPaginationTest (16 passed, 1 skipped), ConceptContextIT (111 passed, 15 skipped), ConfigResourceIT (5 passed, 5 skipped), ContextFileIT (11 passed), ContextMemoryAnchorIT (86 passed, 10 skipped), ContextMemoryConflictReviewIT (11 passed, 2 skipped), ContextMemoryCreateGrantIT (4 passed), ContextMemoryIT (185 passed, 20 skipped), ContextMemoryLifecycleIT (23 passed, 2 skipped), ContextMemoryQueryEvidenceIT (193 passed, 27 skipped), ContextMemoryRelatedEntitiesReconcileIT (8 passed), ContextMemorySearchMatrixIT (0 passed), ContextMemorySourceEntityTiebreakIT (57 passed, 8 skipped), ContextMemoryStatusMigrationIT (1 passed), ContextMemoryWriteAccessIT (18 passed, 1 skipped), ConversationResourceIT (18 passed, 2 skipped), CredentialMcpRevocationIT (46 passed, 7 skipped), DatabaseSmokeIT (25 passed), DirectoryResourceIT (5 passed, 1 skipped), DocStoreResourceIT (104 passed, 7 skipped), DriveFileUploadIT (7 passed, 1 skipped), DriveServiceResourceIT (43 passed, 5 skipped), FileResourceIT (185 passed, 26 skipped), FolderIT (149 passed, 20 skipped), FolderResourceIT (83 passed, 9 skipped), GlossaryTermResourceIT (0 passed, 1 failed), IngestionPipelineAgentTypeIT (12 passed, 1 skipped), KnowledgeCenterIT (17 passed, 6 skipped), KnowledgePageHierarchyIT (64 passed, 6 skipped), LLMModelResourceIT (229 passed, 19 skipped), LLMServiceResourceIT (35 passed, 4 skipped), LearningResourceIT (95 passed, 11 skipped), McpContextMemoryVisibilityIT (41 passed, 1 skipped), McpExecutionResourceIT (39 passed, 3 skipped), McpIntegrationIT (6 passed), McpOAuthIT (10 passed), McpPermissionIT (28 passed, 3 skipped), McpRdfNotEnabledIT (42 passed, 4 skipped), McpSearchIT (75 passed, 10 skipped), McpServerResourceIT (33 passed, 1 skipped), McpToolsValidationIT (41 passed, 4 skipped), McpUserContextIT (34 passed, 3 skipped), MetricAssetsIT (31 passed, 6 skipped), OntologyAiResourceIT (1 passed, 1 skipped), PersonaAIContextIT (36 passed, 4 skipped), PromptTemplateResourceIT (114 passed, 14 skipped), SeedDataPresenceIT (22 passed, 3 skipped), SpreadsheetResourceIT (12 passed, 1 skipped), TableResourceIT (199 passed, 5 skipped), UserResourceIT (68 passed, 2 skipped), WorksheetResourceIT (293 passed, 12 skipped)

Ingestion integration tests

Not applicable: no ingestion changes.

Playwright (UI) tests

The full-branch planner selected 30 specs; the follow-up selected 21. No mapping gaps. Not run: no UI from this revision was running locally. This PR remains draft pending browser validation.

Manual testing performed

No manual UI checks. Automated REST tests use the embedded server and scripted document provider. SQL tests use the production table definitions on MySQL and PostgreSQL.

UI screen recording:

Not applicable: backend processing behavior only.

Checklist:

  • Regression tests and local test evidence recorded.
  • mvn -B spotless:apply -pl openmetadata-service,openmetadata-integration-tests passed; follow-up formatting passed for openmetadata-service.
  • git diff --check, decision-record checks, and Java impact-map ownership checks passed.
  • Self-review of b1a81d046353: concurrent writes, scope lifetime, handoff exits, storage, and retry/requeue paths checked; no unanswered Important findings.
  • Decision recorded; no new schema or migration.
  • Browser validation remains pending.

@pmbrull pmbrull added the skip-pr-checks Bypass PR metadata validation check label Oct 30, 2026
@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Oct 30, 2026
@gitar-bot

gitar-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 closed / 2 findings

🔴 High risk · Conditional writes and retries for ContextFile/Page processing affect stored-data integrity; incorrect conflict handling could overwrite edits or leave processing results stale.

Preserves Context Center metadata such as document sharing and descriptions during background processing by using a fresh snapshot and version/timestamp check on each conditional write retry. Resolved the updateFile retry path that read through the L1 cache, and added the missing decision record for the updatedAt-guarded write rule. No open issues found.

✅ 2 closed
✅ Bug: updateFile retries read through the L1 cache, unlike updateSource

📄 openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextFileProcessingService.java:523-537 📄 openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextProcessingEngine.java:33-44
The retry loop in updateFile now clears only the per-request RequestEntityCache before it re-reads. repository.get still answers from the in-JVM L1 (CACHE_WITH_ID), because only FreshReadScope skips it (EntityRepository line ~2025). The new engine updateSource wraps each attempt in FreshReadScope.enter(). FreshReadScope's own docs describe the case this misses: on a multi-node deployment without Redis, a sharing or description edit made on another node never evicts this node's L1.

In that case all 10 attempts re-read the same stale version/updatedAt, the conditional write fails every time, and ConditionalUpdateExhaustedException is thrown. requeueAfterConditionalUpdateContention then resubmits to the executor right away, so the file spins through process until the L1 TTL expires. Fix: wrap each attempt in FreshReadScope, the same way updateSource does, and do the same in updateContent.

✅ Quality: No decision record for the updatedAt-guarded write rule

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextFileRepository.java:292-299 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/KnowledgePageRepository.java:718-725 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/KnowledgeAssetDAOs.java:84-98 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/KnowledgeAssetDAOs.java:317-331
This PR adds a rule that spans several files and is not written down in docs/decisions/. Processing writes to ContextFile and Page rows are now conditional on both version and updatedAt (DAO updateWithVersionAndTimestamp). For that check to work, every update must push updatedAt at least 1 ms past the stored value (Math.max(updated, original + 1) in both updaters), even if that puts it ahead of the wall clock. The rule comes from the description: "Same-version edits must be detected on MySQL and PostgreSQL, including timestamp changes within one millisecond."

The updater bump and the SQL guard sit in different files and depend on each other. If someone later removes the bump as redundant, consolidated edits will be silently overwritten again. A record should state roughly: "Context Center background writes are conditional on the stored version and updatedAt; ContextFile and Page updaters always advance updatedAt strictly past the stored value so a consolidated same-version edit is detectable; contention exhaustion requeues the work instead of failing it."

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@pmbrull
pmbrull marked this pull request as ready for review October 30, 2026 10:37
@pmbrull
pmbrull requested a review from a team as a code owner October 30, 2026 10:37
@pmbrull
pmbrull requested a review from IceS2 October 30, 2026 10:38
@pmbrull
pmbrull added this pull request to the merge queue Nov 3, 2026
@pmbrull pmbrull self-assigned this Nov 3, 2026
@pmbrull pmbrull added the 2.1 label Nov 3, 2026
@pmbrull
pmbrull merged commit ec023ee into main Nov 3, 2026
162 checks passed
@pmbrull
pmbrull deleted the pmbrull/context-file-processing-updates branch November 3, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.1 Ingestion safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants