Repository navigation
Fixes #36671: Live RDF entity writes send only the changed triples - #37069
Conversation
Every live entity write deleted and reinserted the entity's whole projection, so each wide-table write copied TDB2 index pages even when nothing changed. storeEntity now reads the triples a replacement would delete, compares them with the new projection, and sends one DELETE DATA / INSERT DATA request with only the difference, or nothing. Literals compare by datatype and value. - Unchanged writes no longer mark inference dirty or relist asserted graphs. - Writes fall back to a full replacement for blank nodes, for a difference larger than the projection, and for a queued write whose earlier attempt failed or was held by compaction (it may still apply in Fuseki). - RDF list cells get stable IRIs owned by the entity, so replaced lists no longer leak cells. - ADR, production docs, unit tests, a real-Fuseki IT and a disk benchmark.
…ry wiring - A successful read for an entity write records a success with the circuit breaker; an unchanged write sends no update, so occasional read timeouts otherwise add up across unchanged writes and trip it. - RdfUpdater.liveWriteApplication is extracted so a test can show a redelivered queue write reaches storage as REPLACE and a first attempt as DIFFERENCE; CompactionBlockedWriteTest checks the held write is pending. - Drop the unreachable guard in createTypeResource: getRdfType never returns null or empty.
…rden its test A changed write's success comes from its update, so its read no longer clears the breaker before the update counts its own failure. The test warms up first, allows 1 s per read and asserts each failure is a timeout.
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Local Java test run: PASSED — details
Every test skipped, so these exercised nothing (check their assumptions — usually the engine): Tests run locally
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. unit · openmetadata-mcp (7 classes), openmetadata-service (58 classes): 109 classes
integration · mysql-elasticsearch · parallel: 83 classes
integration · mysql-elasticsearch · rdf: 33 classes
Why these tests
Impacted, not run locally (4)
Commandsmvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AgentSparqlServiceTest,AssertedGraphTrackingRdfStorageTest,CentralityComputationTest,CommunityComputationTest,CompactionBlockedWriteTest,EntityNeighborhoodToolTest,EntityWriteCircuitBreakerTest,FindByTagToolTest,InferenceInvalidatingRdfStorageTest,JenaFusekiDatasetAdminTest,JenaFusekiStorageTest,JenaFusekiStreamingAppendTest,LineagePathFinderTest,MetricGroupRepositoryTest,OntologyActiveGraphStorageTest,OntologyDescribeToolTest,RdfAutoTuneTest,RdfBatchProcessorTest,RdfBlueGreenDatasetTest,RdfBulkSinkTest,RdfCustomPropertyProjectionTest,RdfEntityDeleteLineageTest,RdfEntityWritePlannerTest,RdfExtensionProjectionTest,RdfGlossaryRelationCleanupQueryTest,RdfGlossaryTermGraphFilterTest,RdfGlossaryTermRelationTest,RdfGraphHelpersTest,RdfGraphServiceTest,RdfIndexAppTest,RdfIndexingFieldsTest,RdfInferenceAppTest,RdfInferenceGuardrailTest,RdfInsightsServiceTest,RdfJenaBootstrapTest,RdfLineageBatchingTest,RdfLineageOntologyTest,RdfLiveWriteTest,RdfLiveWriterTest,RdfMutationUpdateShapeTest,RdfOwnedResourcesTest,RdfParserHelpersTest,RdfPredicatePartitionTest,RdfProjectionHealthTest,RdfPropertyMapperTest,RdfReindexLabelLookupTest,RdfRelationPredicateValidationTest,RdfRepositoryBulkChunkingTest,RdfRepositoryProjectionHealthTest,RdfResourceTest,RdfRuleInputProjectionTest,RdfSparqlServiceTest,RdfStorageIdempotencyTest,RdfStorageMaintenanceExceptionMapperTest,RdfStorageMaintenanceServiceTest,RdfToolGatingTest,RdfUpdaterTest,RdfValidationServiceTest,SerializedRdfPayloadTest,ShaclValidateToolTest,SparqlQueryToolAgentProfileTest,SparqlQueryToolTest,StorageFactsTest,StorageGuardRefusalTest,TestCaseRepositoryTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<82 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=EntityShapeIT,GlossaryOntologyExportIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=rdf '-Dit.test=<33 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=parallel -Dit.test=EntityCacheWriteOrderIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false |
Both PR reviews found that a write already queued in Fuseki (an abandoned request, a timed-out reindex chunk, a dead server's request) can commit between a difference's read and its update, leaving a mixed graph a full replacement would have avoided; the queue's lastError marker missed crashes, older servers and later rows. TDB2 admits writers in arrival order, so after the update returns every write queued ahead of it has committed: the write now reads the projection back and replaces it whole when it differs (outcome "corrected"). That covers every writer, so the queue redelivery machinery (failedBefore, requestPending, replacingEntityWrites) is removed and those files return to main. - Journal replay passes REPLACE explicitly, as before this change. - The IT and ADR no longer claim an unchanged write reaches Fuseki once. - ADR: rewritten limits, Turtle/RDF-XML list export shape.
…mitted A difference can commit before its read-back or reply fails; the queue's retry then finds the projection stored and reports UNCHANGED, so nothing refreshed inference. InferenceInvalidatingRdfStorage now marks rules dirty when storeEntity throws. Also: RdfEntityWriteStrategy Javadoc matches the read-back, and RdfMutationReplayTest pins journal replay to REPLACE.
|
Local Java test run: PASSED — details
Every test skipped, so these exercised nothing (check their assumptions — usually the engine): Tests run locally
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. unit · openmetadata-service (34 classes): 58 classes
integration · mysql-elasticsearch · parallel: 60 classes
integration · mysql-elasticsearch · rdf: 33 classes
Why these tests
Impacted, not run locally (2)
Commandsmvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AssertedGraphTrackingRdfStorageTest,CompactionBlockedWriteTest,EntityWriteCircuitBreakerTest,InferenceInvalidatingRdfStorageTest,JenaFusekiDatasetAdminTest,JenaFusekiStorageTest,JenaFusekiStreamingAppendTest,OntologyActiveGraphStorageTest,RdfBatchProcessorTest,RdfBlueGreenDatasetTest,RdfCustomPropertyProjectionTest,RdfEntityDeleteLineageTest,RdfEntityWritePlannerTest,RdfExtensionProjectionTest,RdfGlossaryTermGraphFilterTest,RdfGlossaryTermRelationTest,RdfIndexingFieldsTest,RdfInferenceGuardrailTest,RdfJenaBootstrapTest,RdfLineageBatchingTest,RdfLineageOntologyTest,RdfLiveWriteTest,RdfMutationReplayTest,RdfOwnedResourcesTest,RdfPredicatePartitionTest,RdfPropertyMapperTest,RdfReindexLabelLookupTest,RdfRepositoryBulkChunkingTest,RdfRepositoryProjectionHealthTest,RdfRuleInputProjectionTest,RdfStorageIdempotencyTest,SerializedRdfPayloadTest,StorageFactsTest,StorageGuardRefusalTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<59 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=GlossaryOntologyExportIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=rdf '-Dit.test=<33 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
Code Review ✅ Approved 2 closed / 2 findings🔴 High risk · Differential RDF entity writes and list-cell ownership change stored-graph maintenance; a missed difference or race could leave entity metadata stale or mixed. Live RDF entity writes now send only the triples that changed (or nothing when unchanged), cutting Fuseki disk growth from repeated full replacements, with a read-back guard against interfering writes. The one open-to-discussion item, marking all inference stale on a failed entity write, is closed without a fix as a deliberate conservative choice. The existence-check chunk size of 1,000 was resolved, and no open findings remain. ✅ 2 closed✅ Quality: Existence-check chunk size of 1000 is a judgment call with no record
Closed: Edge Case: Entity writes that never reached Fuseki still mark all inference stale
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 |
…ackport 2.0 #37069) (#37177) * Fixes #36671: Live RDF entity writes send only the changed triples (backport 2.0 #37069) Backport of #37069, adapted to 2.0: - 2.0 has no InferenceInvalidatingRdfStorage or AssertedGraphTrackingRdfStorage (main-only, from #28042 and #35201), so their changes and tests are left out. - 2.0 does not project table columns as resources, so RdfPropertyMapper keeps only the named list cells, and the two tests that relied on column triples use extension properties or the 2.0 counts instead. - The new tests use 2.0's JsonLdTranslator constructor and JenaFusekiStorage.isTimeoutError, now package-private for the circuit-breaker test. - The ADR and the production setup guide drop the inference statements that do not apply. (cherry picked from commit d811bd7) * Run RdfEntityDiffWriteIT on 2.0: add FusekiTestImage, wide table in custom properties 2.0 has no FusekiTestImage and does not project a table's columns, so the wide-table test changes a table tag on a table with 200 custom properties. * Benchmark 2.0 with tables wide in custom properties 2.0 does not project a table's columns, so the disk-growth harness builds tables with 300 custom properties and changes one per write instead of moving a column tag. The decision record gains the 2.0 measurement.
Describe your changes:
Fixes #36671
Every live entity write deleted the entity's whole projection and inserted it again, even when nothing had changed. TDB2 copies every index page a write touches, so a nightly ingestion of wide tables grew Fuseki's volume by tens of GB between compactions (#36437 added the compaction; this removes most of the growth it has to reclaim). RDF lists were blank nodes no write could name, so every rewrite also leaked the previous list's cells.
Live entity writes now read the triples a full replacement would delete, compare them with the new projection, and send one
DELETE DATA/INSERT DATArequest with only the difference, or nothing at all. Decision record:docs/decisions/2026-11-03-live-rdf-entity-writes-send-only-the-changed-triples.md.Type of change:
High-level design:
Write path.
RdfStorageInterface.storeEntity(type, id, model, strategy)returns anRdfEntityWriteResult(UNCHANGED,CHANGED_TRIPLES,REPLACED,CORRECTED). InJenaFusekiStorage,RdfEntityWritePlannerdecides what to send:CONSTRUCT.RdfEntityScopebuilds it from the same pattern the existing replacement deletes, so the two cannot drift. The scope is the entity's literals, the IRI values of translator-managed predicates, and its owned resources: custom properties, extensions, columns and nested columns, list cells.RdfEntityDifference: triples to delete = stored − projection; to insert = projection − stored − already present. Projection triples outside the scope (tag labels, referenced entities' types) are only inserted when missing, checked in bounded reads of 1,000. Literals with the same datatype, language and value count as equal, because TDB2 can return dates and decimals in another lexical form.RdfEntityWriteStrategy.REPLACE) when the projection or the store holds a blank node, or when the difference is larger than the projection (e.g. a rename).Unchanged writes cost nothing downstream.
InferenceInvalidatingRdfStorageandAssertedGraphTrackingRdfStorageonly invalidate whenresult.changesGraph().RebuildingRdfStoragepasses the result through; the rebuild journal still records the full projection.Lists.
RdfPropertyMappernames list cells<entity>/list/<URL-encoded predicate>/<index>(rdf:nilfor an empty list).RdfOwnedResourcesowns them, so entity deletes and bulk reconcile remove them too. A list still stored with blank cells is replaced once, cells included.Writes that interfere (the one real hazard of read-then-write). A difference is computed from a read. A write already queued for TDB2's writer when that read ran commits between the read and our update: a request OpenMetadata stopped waiting for after its 60 s deadline, a timed-out reconcile-reindex chunk, or the request of a server that died. A full replacement queued behind it would correct it; a bare difference would leave a mixed graph, e.g. the queued write's description next to ours. So after sending a difference,
RdfEntityWritePlanner.writereads the projection back, and sends the full replacement if it differs (outcomecorrected):new Semaphore(1, true)in Jena 6.2.0'sTransactionCoordinator, the version in our Fuseki image). Once our update has returned, every write queued ahead of it has committed, so the read-back sees all of them.rdf.fuseki.entity.writes{outcome=corrected}shows how often it happens; it should only appear while Fuseki is timing out.The remaining limits are in the decision record: a stale write sent after ours (as on
main), an unchanged write followed by a stale write still queued, and the unordered moment right after a compaction ends.Alternatives rejected.
Unchanged: bulk reindex (
INSERT_ONLY), relationship writes, the rebuild journal (journal replay now passesREPLACEexplicitly, as it did before).Compatibility.
GET /v1/rdf/entity/{type}/{id}) show a list as namedrdf:first/rdf:restresources instead of a( … )collection. The graph means the same, SPARQL list paths still match, and JSON-LD export is unaffected.recreateIndex: truereindex.datasetByFqn) stays out of scope, as before, and is listed as a follow-up in the decision record.Release. This targets
mainand is labelled2.1. Note that the2.1branch does not contain the #36437 maintenance work this builds on (its backport #36473 was closed unmerged), while2.0does (#36660, #36661).Measured with
scripts/rdf-live-update-benchmark.sh(new): 200 tables × 300 columns, 1,000 writes per scenario, oneopenmetadata/fuseki:6.2.0-c75b095container. Disk is the dataset directory's growth.The difference column was rerun at
f95b681287b, read-back included: it added no update requests, and no write came backcorrected. The synthetic tables are wider than typical (every column has a description), so the ratio is the meaningful number. New metrics to watch:rdf.fuseki.entity.writes{outcome},rdf.fuseki.entity.triples{change},rdf.fuseki.payload.bytes{operation=storeEntity}.Tests:
Use cases covered
om:upstream,om:downstream,om:contains,om:owns) survive.corrected); a changed write nobody interfered with is not replaced.Unit tests
RdfEntityWritePlannerTest: the generated SPARQL runs against an in-memory Jena dataset and is compared with a full replacement.RdfOwnedResourcesTest: the Java owned-resource walk matches the SPARQL scope.EntityWriteCircuitBreakerTest.RdfMutationReplayTest: journal replay replaces.InferenceInvalidatingRdfStorageTest(an unchanged write leaves rules clean; a failed one marks them dirty),AssertedGraphTrackingRdfStorageTest.-Pstatic-code-analysis, 112 targeted unit tests atf95b681287b) on the new classes:RdfEntityWritePlanner(read-back included),RdfEntityDifference,RdfEntityWriteResult,RdfEntityWriteStrategy,RdfOwnedResources.RdfEntityScope.RdfPropertyMapper86%,InferenceInvalidatingRdfStorage45%,JenaFusekiStorage38%. The changedstoreEntitypath runs against real Fuseki inRdfEntityDiffWriteIT.Backend integration tests
RdfEntityDiffWriteIT. It starts its own Fuseki and counts update requests from Fuseki's/$/stats. It writes the same versions through the difference path and the replacement path into two datasets and compares the graphs.RdfBlueGreenRebuildIT(its fault-injecting storage forwards the newstoreEntity).Local Java test run: PASSED
f95b681287bc(baseorigin/main); the only later commit,a66a8986f26, changes the decision record only.Every test skipped, so these exercised nothing (check their assumptions — usually the engine):
BaseEntityIT$ListEntityHistoryByTimestampPaginationTest (mysql-elasticsearch · parallel),RdfIndexAppScaleIT (mysql-elasticsearch · rdf)Ingestion integration tests
Playwright (UI) tests
Manual testing performed
FUSEKI_ENDPOINT=http://localhost:3031/openmetadata FUSEKI_PASSWORD=bench bash scripts/rdf-live-update-benchmark.sh(REPLACE then DIFFERENCE, compacting before each scenario). Results are in the table above./$/stats/openmetadatareports endpoints keyed byoperation: "update"withRequests, which the IT and the harness parse.UI screen recording:
Not applicable — backend-only change with no UI.
Checklist:
I have read the CONTRIBUTING document.
My PR title is
Fixes <issue-number>: <short explanation>My PR is linked to a GitHub issue via
Fixes #<issue-number>above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: I updated the migration scripts or explained why it is not needed. Not applicable: no schema change.
For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable). Not applicable: backend only.
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: I reviewed the final diff against
REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.8e8904aaa33and270082486edfound no 🔴. Their 🟡 were fixed in270082486edanda58bad35002: the circuit breaker on entity-write reads, test hardening, an unreachable guard.f46173a9fdaby the read-back, which replaced the queue-based redelivery rule.f46173a9fda:f95b681287b, with a test that fails without it.RdfEntityWriteStrategyJavadoc, and a test pinning journal replay toREPLACE.Decision check: if this PR decides something the next contributor could undo — a schema field, REST path or format another component or repo must agree with, a new default or limit, an ordering that must hold, or a rule stated only in this description — it adds a record under
docs/decisions/(see itsREADME.md). This description is gone fromgit logafter the squash-merge. Addeddocs/decisions/2026-11-03-live-rdf-entity-writes-send-only-the-changed-triples.md.I have added a test that covers the exact scenario we are fixing. For complex issues, comment the issue number in the test for future reference.
🤖 Generated with Claude Code