Repository navigation
Description
Detail Bug Report
Introduced in #32262 by @harshach on Sep 9, 2026
Summary
- Context: The RDF projection (
openmetadata-service/src/main/java/org/openmetadata/service/rdf/) mirrors SQL relationship edges into a SPARQL knowledge graph via durableRdfLiveWritecommands (RdfLiveWriteStoreoutbox) and the blue-green rebuild journal, which replays the storage-level mutations those writes performed, long after capture. - Bug: Replayed ADD commands for non-UPSTREAM relationships and glossary term relations blindly re-insert their triples (
repository.addRelationship/repository.addGlossaryTermRelationare unconditionalINSERT DATA), unlike the UPSTREAM lineage branch which reconciles against SQL at replay time (refreshLineage). - Actual vs. expected: When an ADD command is delivered late (storage-outage retry, or blue/green rebuild journal replay) after the SQL edge was deleted by a path that emits no remove command (bulk relationship updates, CSV import), the replay resurrects a triple whose SQL row no longer exists; the established replay contract ("leaves the graph matching the database whatever order the add and delete replays run in") is honored only for lineage.
- Impact: Stale
om:owns/om:contains/prov:used/skos:broaderedges are served to SPARQL consumers indefinitely (until an indexing run happens to cover the source entity or a full rebuild), misrepresenting ownership, containment, lineage-adjacent and glossary relations.
Code with Bug
openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfLiveWrite.java:
record RelationshipChange(String relationshipJson, boolean remove) implements RdfLiveWrite {
...
@Override
public void apply(final RdfRepository repository) {
final EntityRelationship relationship =
JsonUtils.readValue(relationshipJson, EntityRelationship.class);
if (remove) {
repository.removeRelationship(relationship);
} else if (relationship.getRelationshipType() == Relationship.UPSTREAM) {
repository.refreshLineage(relationship); // <-- reconciles against SQL before projecting
} else {
repository.addRelationship(relationship); // <-- BUG 🔴 blind INSERT DATA, no SQL re-check
}
}
}
record GlossaryRelationChange(UUID fromId, UUID toId, String relationType, boolean remove)
implements RdfLiveWrite {
@Override
public void apply(final RdfRepository repository) {
if (remove) {
repository.removeGlossaryTermRelation(fromId, toId, relationType);
} else {
repository.addGlossaryTermRelation(fromId, toId, relationType); // <-- BUG 🔴 blind INSERT DATA
}
}
}Explanation
- The outbox/replay mechanism can deliver an ADD well after it was captured (e.g., Fuseki outage retry, or replay during blue/green promotion).
- For non-UPSTREAM relationships and glossary relations, the replayed ADD path unconditionally does
INSERT DATAand does not verify the correspondingentity_relationshiprow still exists. - Some SQL deletion paths do not enqueue any RDF remove command (bulk relationship updates, owner removals, CSV import relationship clears). If such a deletion happens after the ADD was captured but before the ADD is replayed, the replay will reinsert a triple that no longer exists in SQL.
- Once reinserted, later entity refresh/upsert does not delete these “hook-managed” relationship predicates, so the stale triple persists until a reindex run happens to cover the entity or a full rebuild.
Codebase Inconsistency
The lineage path implements the intended replay contract by reconciling against SQL during replay, removing the relationship instead of inserting if the SQL edge is gone:
// RdfRepository.refreshLineage — the replay contract the other two branches lack
final Optional<RdfProjectionLoaders.StoredLineageEdge> storedEdge =
projectionLoaders.lineageDetailsLoader().load(lineage.getFromId(), lineage.getToId());
if (storedEdge.isEmpty()) {
removeRelationship(lineage); // <-- replay of an add whose SQL edge is gone deletes instead
} else {
projectLineage(lineage, storedEdge.get().details());
}Failing Test
mvn -pl openmetadata-service test -Dtest=RdfLiveWriteTest
Two added tests in openmetadata-service/src/test/java/org/openmetadata/service/rdf/RdfLiveWriteTest.java fail on current code:
genericRelationshipAdditionReplayedAfterTheEdgeWasDeletedResurrectsIt(CONTAINS)glossaryRelationAdditionReplayedAfterTheRelationWasDeletedResurrectsIt(skos:broader)
Output summary: Tests run: 18, Failures: 2; failure is expected: <false> but was: <true> showing the triple is resurrected. The existing lineage test lineageAdditionReplayedAfterTheEdgeWasDeletedDoesNotResurrectIt passes, confirming the asymmetry.
Recommended Fix
Give the non-UPSTREAM and glossary add paths the same replay-time SQL reconciliation as lineage: if the replayed ADD’s SQL row no longer exists, remove/no-op rather than INSERT DATA.
// RdfLiveWrite.RelationshipChange.apply
} else if (relationship.getRelationshipType() == Relationship.UPSTREAM) {
repository.refreshLineage(relationship);
} else {
repository.refreshRelationship(relationship); // <-- FIX 🟢 loads the edge from SQL; gone → removeRelationship
}Implement refreshRelationship to consult SQL for (fromId, toId, relation) before projecting. Apply the same pattern for glossary term relations (including canonical-direction/relationType handling).
History
This bug was introduced in commit d821be9 ("Fixes #32057: single-writer RDF reindex pipeline and Jena 6.2.0 upgrade (#32262)", 2026-09-09). That commit shipped RelationshipChange.apply / GlossaryRelationChange.apply calling unconditional insert paths.
Commit 431885dde6 later added replay-time SQL reconciliation for lineage (refreshLineage) and a dedicated test, but left the non-UPSTREAM and glossary branches on the original blind INSERT DATA logic.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✅
Activity
iamkiayun commentedon Nov 23, 2026
Hi — I'd like to pick this up if no one is already working on it.
Verified on
mainthatRdfRepository.refreshRelationship(non-UPSTREAMbranch) andrefreshGlossaryTermRelationonly check endpoint liveness (hasLiveEnds/areLive) rather than reconciling edge existence against SQL likerefreshLineagedoes.Plan: reconcile replayed non-
UPSTREAMrelationships and typed glossary term relations against SQL at replay time (removing stale triples if the edge no longer exists or an endpoint is no longer live) and add unit +RdfLiveWriteRecoveryITregression tests. Let me know if there are any extra constraints to keep in mind.Fixes 36026: Reconcile replayed RDF non-lineage and glossary relation…