Skip to content

Fixes 35198: Keep RDF reasoning freshness exact during rolling upgrades and failed updates - #35199

Merged
harshach merged 7 commits into
mainfrom
fix/rdf-watermark-freshness
Oct 12, 2026
Merged

harshach merged 7 commits into
mainfrom
fix/rdf-watermark-freshness

Conversation

@harshach

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #35198

Follow-up to phase 2 (#34975) of docs/plans/2026-10-07-fuseki-native-reasoning.md. A reasoning result decides whether it is still current from the live-write watermark; this closes the cases where the watermark missed a write, and makes the job-request schema enforce what each operation needs.

Type of change:

  • Bug fix

High-level design:

  1. Retired queue IDs stay in the watermark. RdfLiveWriteStore.retire(handle, id) deletes a queue row and raises rdf_projection_health.enqueuedWatermark to its ID in the same transaction. Delivery, dead-lettering and recordUntrackedWrite all use it, so a row inserted by a server on the previous version (which never raised the column) no longer drops out of the watermark once drained. Two gaps remain during a rolling upgrade and are documented in rdf-production-setup.md and the plan: an older server draining its own write, and an older server promoting a blue/green build without a new generation.
  2. Untracked writes are recorded on failure too. RdfSparqlService.update and PipelineRepository record the untracked write in a finally; an update that timed out may still have been applied by Fuseki. recordUntrackedWrite never throws, so it cannot mask the original error.
  3. Per-operation required fields in rdfReasoningJobRequest.json as draft 2020-12 allOf/if/then (the snowplowConnection.json precedent): REFRESH needs ruleBundleDigest; CHECK needs ontologyIri and check; EXPLAIN needs ontologyIri and explain; SATISFIABILITY, SUBSUMPTION and ENTAILMENT need their expressions. Generated Java and TypeScript are byte-identical.
  4. Cleanup: remove RdfActiveDatasetDAO.setActiveDataset, upsertActiveDataset and clearActiveDataset, which have no callers; RdfRebuildStore owns every write to the table.

Not done: comparing the dataset name in ReasoningFreshness would add a field to the merged RdfSourceRevision protocol; nothing calls ReasoningFreshness in production yet, so it is documented as an upgrade limitation instead.

Tests:

Use cases covered

  • A queue row left by an older server, delivered or dead-lettered, keeps its ID in the enqueued watermark (MySQL and Postgres).
  • An admin SPARQL Update that throws still records its untracked write.
  • An untracked write that cannot be recorded marks the projection degraded, and freshness is UNKNOWN.
  • Each untracked writer advances the watermark by exactly its own writes: admin update 1, pipeline status 1, in-place reindex 2, measured with delivery paused.
  • Job requests missing a per-operation field are rejected; a CONSISTENCY check without expressions is valid.

Unit tests

  • RdfReasoningContractTest (43), RdfUpdaterTest (12), ReasoningFreshnessTest (7), RdfSparqlServiceTest (12), RdfProjectionHealthTest (3): 0 failures. The new cases fail on the previous code.
  • PipelineRepository has no new test: it reaches RdfRepository through a static singleton; the change mirrors the tested RdfSparqlService one.

Backend integration tests

  • RdfLiveWriteRecoveryIT (new older-server cases, which fail on the previous RdfLiveWriteStore), RdfSourceRevisionIT (now reads RdfLiveWriteStore.enqueuedWatermark() and counts IDs without a queue row).
IT mysql-elasticsearch postgres-opensearch
RdfBlueGreenRebuildIT 34 passed 34 passed
RdfLiveWriteRecoveryIT 32 passed 32 passed
RdfSourceRevisionIT 3 passed 3 passed

Manual testing performed

None beyond the tests above.

UI screen recording:

Not applicable — backend-only change.

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.
  • For JSON Schema changes: rdfReasoningJobRequest.json gains validation rules only; generated code is unchanged.
  • I have added tests (unit / integration as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

Servers that predate rdf_projection_health.enqueuedWatermark enqueue
without recording it, so the watermark counted their writes only through
MAX(id) of the queue. Once such a row was delivered or dead-lettered it
dropped out, and a reasoning result captured before it could pass for
current. Record the ID in the same transaction that deletes the row.

Document the gap that remains while older servers still drain the queue
or promote a blue/green build.
The test copied the production watermark SQL instead of calling
RdfLiveWriteStore.enqueuedWatermark(), and its assertions held for any
live write that happened to be enqueued meanwhile. Pause delivery by
holding the drain guard, so queued live writes stay visible, and count
exactly the queue IDs that left no row behind.
The admin SPARQL Update and pipeline-status provenance writes recorded
themselves only after executeSparqlUpdate returned. A failure that
arrives after Fuseki applied the update, such as a response timeout,
recorded nothing, so earlier reasoning results kept passing for current.
Record in a finally block, as RdfIndexApp already does.
setActiveDataset, upsertActiveDataset and clearActiveDataset have no
callers; RdfRebuildStore owns every write to rdf_active_dataset.
CHECK needs ontologyIri and check, EXPLAIN needs ontologyIri and
explain, REFRESH needs ruleBundleDigest, and each check kind needs its
expressions. These were only described in prose. The generated Java and
TypeScript models are unchanged.
@harshach
harshach requested a review from a team as a code owner October 11, 2026 05:26
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Oct 11, 2026
Add decision records for the per-operation fields the job request schema
enforces, which the store's validator in open-metadata/jena also checks,
and for the two single writers freshness relies on: queue rows leave only
through RdfLiveWriteStore.retire, and RdfRebuildStore alone writes
rdf_active_dataset. Cite them from the code that implements them.
@gitar-bot

gitar-bot Bot commented Oct 11, 2026

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

🟡 Medium risk · Recording failed RDF updates and retiring legacy queue IDs changes freshness tracking; missed watermark updates could let stale reasoning results appear current.

Tightens RDF reasoning freshness during rolling upgrades and failed updates by keeping retired queue IDs in the enqueued watermark, recording untracked writes even when updates fail, and requiring per-operation fields in the reasoning job request schema. The contract and ownership rules are now recorded in docs/decisions, resolving the open documentation gap. No open issues remain.

✅ 1 closed
✅ Quality: Contract and ownership rules from the PR body are not recorded in docs/decisions

📄 openmetadata-spec/src/main/resources/json/schema/api/rdf/rdfReasoningJobRequest.json:41-55 📄 openmetadata-spec/src/main/resources/json/schema/api/rdf/rdfReasoningJobRequest.json:130-144 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/RdfInfraDAOs.java 📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfLiveWriteStore.java:152-155
This PR sets two rules that nothing in docs/decisions/ records, and the repository squash-merges, so the description will not survive. (1) The job request now has per-operation required fields, and every producer and consumer of rdfReasoningJobRequest has to follow them. A record should say: "REFRESH requires ruleBundleDigest; CHECK requires ontologyIri and check; EXPLAIN requires ontologyIri and explain; SATISFIABILITY, SUBSUMPTION and ENTAILMENT require their expressions; CONSISTENCY takes none." (2) The description says "RdfRebuildStore owns every write to the table" (rdf_active_dataset), and the removed DAO writers depend on that rule. The removal of every queue row also has to raise enqueuedWatermark in the same transaction ("Delivery, dead-lettering and recordUntrackedWrite all use it"). Neither sentence exists anywhere in the tree. Add a dated record under docs/decisions/ that states these rules, so a later change cannot add a second writer, or delete a queue row without retire, and silently break freshness.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

@sonarqubecloud

Copy link
Copy Markdown

@harshach
harshach merged commit 388d4e3 into main Oct 12, 2026
81 checks passed
@harshach
harshach deleted the fix/rdf-watermark-freshness branch October 12, 2026 01:43

This branch was previously deployed

1 inactive deployment
test — 354a42de Deployed Oct 11, 2026 by harshach via RDF Playwright execution #29041
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RDF reasoning freshness misses writes during a rolling upgrade and after failed updates

1 participant