Skip to content

Fixes #36437: Refuse RDF writes before Fuseki's volume fills and compact early when it runs low - #36472

Merged
manerow merged 57 commits into
mainfrom
fix/36437-rdf-storage-guard
Nov 1, 2026
Merged

manerow merged 57 commits into
mainfrom
fix/36437-rdf-storage-guard

Conversation

@manerow

@manerow manerow commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #36437

Problem

OpenMetadata compacts the RDF store once a day, but a burst of ingestion can fill Fuseki's volume within hours. TDB2 memory-maps its files, so a write on a full volume kills the JVM (SIGBUS) on every restart. In production, its heap-sized core dumps also filled the node's disk and got the pod evicted.

What this PR changes

In the Fuseki image, which main now builds from the open-metadata/jena fork, so this part is jena PR #12:

  • A write guard. Once the data volume has less free space than OPENMETADATA_STORAGE_MIN_FREE (10% by default), every write gets HTTP 507 Insufficient Storage and nothing is applied. Reads and compaction keep working.
  • A storage report. GET /$/openmetadata/storage (admin only) returns the volume's size, free space, reserve and whether writes are refused.
  • No core dumps. The JVM no longer writes a heap-sized core dump when it crashes, even when a deployment sets its own JVM_ARGS.

In the server:

  • Refused writes wait instead of failing. A 507 is a maintenance hold-back: queued writes wait without using a delivery attempt or tripping the breaker. The queue's lag still marks the projection degraded.
  • Urgent compaction. When a maintenance check (every 15 minutes) finds free space below RDF_URGENT_COMPACTION_FREE_PERCENT (50) or the guard refusing writes, it compacts without waiting for the daily slot. 50% leaves room for the copy of the live data. If compacting cannot get back above the threshold, the server logs at ERROR that the volume needs expanding, and urgent compactions stop for one interval while the daily one still runs.
  • A recreate reindex recovers a full volume. Its storage check accepts a refused probe write, and when the guard refuses its clear it compacts to make room and clears once more.
  • A store without the report, such as today's production image or stock Fuseki, keeps the daily schedule only.

Decision record: ADR:2026-10-28-the-fuseki-image-refuses-writes-below-a-free-space-reserve-and-reports-its-volume.

What operators will notice

A volume that fills faster than the daily compaction no longer takes Fuseki down: writes pause while a compaction frees space, then resume. Expand the volume only when the server log says so. Roll out the new Fuseki image with or after the OpenMetadata release that has this PR: an older server dead-letters the writes the guard refuses.

How it was tested

  • Unit tests for the guard, the storage report, how the server recognises a refusal, a reindex clear refused for low disk, and when urgent compaction triggers and backs off. Contract tests pin the report format; a missing report means schedule only.
  • The RDF integration tests pass on the pinned openmetadata/fuseki:6.2.0-c75b095, which has no guard yet, so they cover the schedule-only path. Before the image moved to the fork, the full RDF lane also passed on an image with the guard.
  • Locally on the new image (1.5 GB volume): writes held below the reserve applied once space returned; an urgent compaction that could not free enough logged the expand-volume error; a copy that did not fit failed without crashing Fuseki; a recreate reindex below the reserve compacted, cleared and completed. No write was dead-lettered.

Not in this PR

  • Pinning the new production image in the Helm charts.
  • Bumping the pinned openmetadata/fuseki tag in this repository. That follows jena PR Logos for all services shows MySQL #12, which merges after the OpenMetadata release that has this PR: merging it also moves the 6.2.0 tag that production pulls.
  • Writing only the triples that changed.

Type of change:

  • Bug fix

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: no migration is needed; the new setting has a default.
  • I have added tests (unit / integration) and listed them above.
  • Decision check: docs/decisions/2026-10-28-the-fuseki-image-refuses-writes-below-a-free-space-reserve-and-reports-its-volume.md.

Collate configuration companion: https://github.com/open-metadata/openmetadata-collate/pull/8029. Stack refresh eafc7bc77c5: backend packaged successfully; StorageGuardRefusalTest, StorageFactsTest, and RdfStorageMaintenanceServiceTest passed (26 tests, 0 failures). Merge #36471 first, then retarget this PR to main and rerun its Collate compatibility workflow.

Refreshed maintenance base

Includes the recovery fixes from #36471: the shared serving pause survives a compaction budget overrun and malformed/unavailable task responses; the versioned consumer fence protects pipelineExecution during rolling upgrades; health reporting continues while compaction waits. Merge conflicts preserved both the disk-reporting/507 guard and the pause-preserving compaction API.

Validation at f283cc995f5: 113 focused unit tests plus 10 recovery integration cases passed, using real MySQL and PostgreSQL with an HTTP Fuseki boundary. Coverage includes disk facts, HTTP 507 retry classification, urgent compaction, pause retention, legacy-consumer exclusion and migration handoff, and compaction-health reporting. Spotless and independent review passed; no unanswered important findings.

Merge #36471 first, then retarget this PR to its release branch and rerun the Collate build. The current feature-branch base does not exist in the Collate repository. Deploy upgraded servers before publishing/rolling out the guarded Fuseki image.

The broader affected-test run executed 620 service tests and stopped at the same 5 pre-existing RdfBatchProcessorTest failures caused by static registry interference with RdfResourceTest. It did not reach MCP or the wider IT matrix. The focused unit suite and 10 real-database recovery ITs above passed separately. The planner's ForwardingRdfStorage reference warning concerns additive pass-through delegation; combined storage behavior is exercised by the recovery ITs.

@manerow
manerow requested review from a team, akash-jain-10, harshach and tutte as code owners October 28, 2026 15:56
@github-actions

github-actions Bot commented Oct 28, 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

Copy link
Copy Markdown
Contributor

✅ Generated Sources Auto-Updated

The generated TypeScript types (src/generated/) and dereferenced JSON
schemas (src/jsons/, public/jsons/) have been automatically updated
based on JSON schema changes in this PR.

github-actions Bot and others added 3 commits October 28, 2026 16:05
…torage-guard

# Conflicts:
#	openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 81%
80.93% (136884/169131) 67.82% (49107/72404) 70.88% (27657/39017)

…torage-guard

# Conflicts:
#	openmetadata-ui/src/main/resources/ui/src/generated/api/configuration/rdfConfiguration.ts
… pause, compactions are tracked to the end, pipeline runs go through the queue
…, and wait for the next scheduled compaction after a futile urgent one
…torage-guard

# Conflicts:
#	openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java
#	openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/RdfStorageMaintenanceException.java
#	openmetadata-service/src/test/java/org/openmetadata/service/rdf/maintenance/RdfStorageMaintenanceServiceTest.java
…ing generation's size would refuse the compactions a full volume needs
pmbrull and others added 10 commits October 30, 2026 11:20
Keep the serving pause while Fuseki tasks outlive their budget or return unreadable responses. Transfer the queue consumer fence to upgraded servers before emitting pipeline execution payloads.

Refs #36437
Start the compaction health clock before contacting Fuseki and keep scheduled health reporting independent of the compaction worker. Keep consumer migration statements in the RDF schema section.
…e' into fix/36437-rdf-storage-guard

# Conflicts:
#	docker/rdf-store/Dockerfile
#	docker/rdf-store/entrypoint.sh
#	docker/rdf-store/src/main/java/org/openmetadata/fuseki/BoundedGraphStore.java
#	docker/rdf-store/src/main/java/org/openmetadata/fuseki/OpenMetadataFusekiModule.java
Base automatically changed from fix/36437-rdf-storage-maintenance to main November 1, 2026 11:50
…-guard

# Conflicts:
#	conf/openmetadata.yaml
#	docs/rdf-production-setup.md
#	openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/rdf/RdfIndexApp.java
#	openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfRepository.java
#	openmetadata-service/src/main/java/org/openmetadata/service/rdf/maintenance/RdfStorageMaintenanceService.java
#	openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/ForwardingRdfStorage.java
#	openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java
#	openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/RdfStorageInterface.java
#	openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/RdfStorageMaintenanceException.java
#	openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfIndexAppTest.java
#	openmetadata-service/src/test/java/org/openmetadata/service/rdf/maintenance/RdfStorageMaintenanceServiceTest.java
#	openmetadata-spec/src/main/resources/json/schema/api/configuration/rdfConfiguration.json
#	openmetadata-ui/src/main/resources/ui/src/generated/api/configuration/rdfConfiguration.ts
@gitar-bot

gitar-bot Bot commented Nov 1, 2026

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

🔴 High risk · Changing RDF write deferral, compaction, and reindex-clear behavior affects stored-data integrity; full storage could stall queued updates or prevent recovery.

Adds a free-space write guard to the Fuseki RDF store that refuses writes with HTTP 507 below a reserve, plus an admin storage report and urgent compaction when space runs low. Resolved this session: the urgent slot now holds a full interval instead of waiting for the next scheduled compaction, and the bulk reconcile path no longer logs guard refusals at ERROR or wraps them. No open issues found.

✅ 2 closed
✅ Bug: Urgent slot held a full interval, not until the next scheduled compaction

📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/maintenance/RdfStorageMaintenanceService.java:166-180 📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/maintenance/RdfStorageMaintenanceService.java:205-219 📄 docs/decisions/2026-10-28-the-fuseki-image-refuses-writes-below-a-free-space-reserve-and-reports-its-volume.md:37-41 📄 openmetadata-spec/src/main/resources/json/schema/api/configuration/rdfConfiguration.json:246
When an urgent compaction succeeds but does not free enough space, compactHoldingSlot keeps URGENT_COMPACTION_KEY for compactionInterval() counted from when the urgent run started (reserve(URGENT_COMPACTION_KEY, jobId, compactionInterval())). Nothing releases that slot when the next scheduled compaction (NEXT_COMPACTION_KEY) runs. For example: a scheduled run at T0, then an urgent run at T0+23h that can't free space. The urgent slot stays held until T0+47h. If the scheduled run at T0+24h frees space (say the operator expanded the volume), a burst after that still cannot trigger an urgent compaction for about 23 more hours. Meanwhile the guard refuses writes and the queue stalls. The ADR, rdf-production-setup.md, the schema description and the log message all say urgent compactions 'wait for the next scheduled compaction', but the code waits a full interval. The fix is either to reserve the urgent slot only until the NEXT slot expires, or to release the urgent slot once a scheduled compaction succeeds and leaves the store above the threshold.

✅ Quality: Bulk reconcile path still logs guard refusals at ERROR and wraps them

📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java:942-952 📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java:1214-1216
Every other write path in this diff now calls rethrowIfHeldBack(e) before logging, so a storage-guard refusal (RdfStorageLowDiskException) passes through unwrapped and is not logged. The new javadoc at lines 942-945 promises that behaviour. executeReconcileUpdate, which handles reconcile-mode bulkStoreEntities, was not updated. While the guard is engaged, every refused batch therefore logs Failed to bulk-store ... entities in Fuseki at ERROR with a full stack trace and is wrapped in a plain RuntimeException. Detection that uses find() still works, but a direct catch (RdfStorageMaintenanceException) will not see the exception, and indexing runs flood the logs during exactly the low-disk episodes operators are trying to diagnose. Fix: add rethrowIfHeldBack(e); as the first statement of that catch block.

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

@manerow
manerow enabled auto-merge November 1, 2026 12:45
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

@manerow
manerow added this pull request to the merge queue Nov 1, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

Merged via the queue into main with commit c013852 Nov 1, 2026
80 checks passed
@manerow
manerow deleted the fix/36437-rdf-storage-guard branch November 1, 2026 14:00
manerow added a commit that referenced this pull request Nov 1, 2026
…act early when it runs low (backport 2.0 #36472) (#36661)

* Fixes #36437: Compact the RDF store on a schedule and pause writes during maintenance

* Fixes #36437: Refuse RDF writes before Fuseki's volume fills and compact early when it runs low

* Simplify RDF storage maintenance: one compaction API, plain clear failure, metrics in OntologyMetrics

* Simplify the RDF storage guard: answer 507, report the volume only, check every 15 minutes

* Refuse a compaction the volume cannot hold, accept a 507 at readiness, and wait for the next scheduled compaction after a futile urgent one

* Keep RDF writes safe during storage maintenance: writers wait for the pause, compactions are tracked to the end, pipeline runs go through the queue

* Wait for the next interval after a compaction Fuseki lost, instead of crashing it again

* Never refuse a compaction: the copy holds only live data, so the serving generation's size would refuse the compactions a full volume needs

* Check that an urgent compaction Fuseki lost waits for the next scheduled one

* Name only the reindex lock for urgent compactions: 2.0 has no inference runs

* Wait for a maintenance pause up to the RDF request timeout

* Make RDF write delivery explicit: the queue, direct writers and the pause holder each write through their own handle

* Start RDF storage maintenance only once every live server holds its writes back, using a server registry

* Empty the dataset a blue/green promotion retires, so only the serving dataset keeps a full copy

* Run the storage maintenance IT on the production image with the OpenMetadata extension on, as production does

* Pin the storage report contract the Fuseki images serve, and an image without it

* Wait for the next interval after any compaction Fuseki started and did not finish, not only one it lost

* Drop the server registry: a compaction copies only live data, so servers that do not pause just wait it out

* Use one reindex lock factory for runs and storage maintenance

* Report a compaction overdue for two intervals at ERROR and as a degraded RDF projection, whatever stopped it

* Let a reindex recover a full volume: a clear the disk guard refuses compacts to make room and runs once more

* Keep core dumps off in the Fuseki image when a deployment sets its own JVM_ARGS

* Say what an urgent compaction that cannot free space does: urgent ones stop for an interval, the scheduled one still runs

* Say that the overdue rule counts maintenance compactions

* fix(ui): restore 2.0 schema generation

Resolve the pinned quicktype CLI without root node_modules so the lightweight PR workflow can regenerate the release schemas. Regenerate the committed TypeScript models, including RDF storage maintenance.

* chore(rdf): generate 2.0 disk guard types

* fix(rdf): retain maintenance delivery fences

Keep the serving pause while Fuseki tasks outlive their budget or return unreadable responses. Transfer the queue consumer fence to upgraded servers before emitting pipeline execution payloads.

Refs #36437

* test(rdf): count only SPARQL updates in recovery

* fix(rdf): monitor health during stalled compaction

Start the compaction health clock before contacting Fuseki and keep scheduled health reporting independent of the compaction worker. Keep consumer migration statements in the RDF schema section.

* test(rdf): await maintenance health report

* Reuse Guava's causal chain, Jena's 507 constant and the lenient JSON reader for the storage guard

* Pass low-disk refusals through the bulk reconcile path and do not bisect them

---------

Co-authored-by: Pere Miquel Brull <[email protected]>
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.

Fuseki disk grows until full because the RDF store is only compacted by the reindex app

2 participants