Skip to content

fix(rdf): reclaim Fuseki disk via compaction + upgrade Jena 4.10 → 5.6.0 - #28242

Merged
harshach merged 18 commits into
mainfrom
harshach/fuseki-disk-cleanup
May 19, 2026
Merged

harshach merged 18 commits into
mainfrom
harshach/fuseki-disk-cleanup

Conversation

@harshach

@harshach harshach commented May 18, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Follow-up to #28117. That PR converged the logical RDF state on every re-index (CLEAR ALL, per-source DELETE WHERE, glossary-term cleanup), but on Apache Jena TDB2 those operations only mark blocks free and the write-ahead journal grows monotonically — disk usage never shrinks. After deploy, customer (Novartis pov) reported the Fuseki PVC still climbing (~50 GB on ~2 k entities) and the Relations Graph tab showing source nodes alone, no edges, even though the Overview tab listed the related terms correctly.

End-to-end repro against the customer's data: 5 glossaries, 101 terms, 13 relation types in GlossaryTermRelationSettings — three of which (definedby, enabledby, enrollsin) had rdfPredicate=null. This PR fixes the disk-reclamation issue, drags the Jena client + server forward, and resolves the custom-predicate read-side bug that made the customer's Relations Graph empty.

Type of change:

  • Bug fix
  • Improvement

High-level design:

Compaction wiring (disk reclamation)

  • New RdfStorageInterface.compactStorage(), default no-op (QLever stub).
  • JenaFusekiStorage.compactStorage() POSTs to {server}/$/compact/{dataset}?deleteOld=true, extracts the task id, polls /$/tasks/{taskId} until finished (10 min budget). Honors the circuit breaker, masks userInfo in logs, swallows failures (degraded disk hygiene, not correctness).
  • RdfRepository.compactStorage() thin wrapper, gated on isEnabled().
  • RdfIndexApp.execute() now compacts at two points: in clearRdfData() between clearAll() and reloadOntologies() (so the next reingest writes into an empty dataset directory), and at the end of every successful run (recreate or incremental) so the journal/free-list never accumulate across weeks.
  • Local repro: 607 MB → 14 MB in one recreate cycle (97.7% reclaim).

Bulk entity writes (indexer speedup)

  • New RdfStorageInterface.bulkStoreEntities(List<EntityWriteRequest>) with default per-entity-loop implementation for backward compatibility.
  • JenaFusekiStorage.bulkStoreEntities collapses N entities into 2 HTTP calls (combined SPARQL UPDATE for the predicate-scoped DELETEs, then GSP POST for the unioned RDF model).
  • RdfRepository.bulkCreateOrUpdate(List<EntityInterface>) translates the batch and forwards to the storage layer.
  • RdfBatchProcessor.processEntities tries bulk first; on exception falls back to per-entity for stats granularity, with RdfStorageCircuitOpenException short-circuiting the fallback when the breaker is tripped (avoids N noisy failures on a dead server).
  • Local repro: ~1655 entities reindex in 9 s end-to-end (~30× faster than the prior ~5 min).

Custom-predicate Relations Graph fix

  • buildGlossaryTermGraphQuery was hardcoded to the built-in CURIE list (om:relatedTo, skos:broader, …) and silently dropped every custom-typed edge. Now reads GlossaryTermRelationSettings, expands each configured rdfPredicate to a full IRI and appends to the FILTER list. When rdfPredicate=null (the actual customer config for definedby/enabledby/enrollsin), mirrors the writer's om:<name> fallback so those triples are surfaced too.
  • extractPredicateName now round-trips the user's configured type name: instead of taking the URI's last path segment (which would turn https://acme.com/ns#enrolls into enrolls when the type is named enrolledIn), it looks up the matching type in settings and returns the configured name.

Apache Jena 4.10.0 → 5.6.0

  • Root pom property <jena.version>5.6.0</jena.version>, single source of truth for both openmetadata-service and openmetadata-integration-tests. Drops the apache-jena-libs BOM in favour of explicit jena-core + jena-arq + jena-rdfconnection — pulling in jena-tdb1/2 would trigger a Jena 5.x static-init failure and we never embed TDB. Verified via mvn dependency:tree that all needed transitive modules (jena-base, jena-iri3986, jena-iri, jena-langtag) still resolve.
  • Picks up the two 2025 admin-side Fuseki CVE fixes (CVE-2025-49656, CVE-2025-50151) shipped in Jena 5.5.0.
  • Jena 6.x parked: confirmed a static-init regression in both 6.0.0 and 6.1.0 (TypeMapper.reset reads RDF.dtLangString mid-clinit).

Fuseki server 4.10/5.0 → 5.6.0

  • All 6 in-repo Fuseki Dockerfiles bumped, base image switched from deprecated openjdk:17-jdk-slim to eclipse-temurin:17-jre-jammy.
  • 5 dev/quickstart compose YAMLs migrated from image: stain/jena-fuseki:* to build: { context: ../rdf-store } with image: openmetadata-fuseki:5.6.0 tag. stain/jena-fuseki is unmaintained and missing the 2025 CVE fixes.
  • docker/rdf-store/Dockerfile sets FUSEKI_BASE=/fuseki so shiro.ini is actually loaded (previously the env wasn't set and the bundled shiro.ini was silently ignored → admin endpoints reachable without auth).
  • Entrypoint script envsubsts FUSEKI_ADMIN_PASSWORD and FUSEKI_OPENMETADATA_PASSWORD into shiro.ini at container start (Apache Shiro's INI realm doesn't interpolate ${VAR} natively), restoring env-var-driven password overrides while keeping admin/openmetadata-secret defaults.
  • Named volume renamed fuseki-data → fuseki-tdb2-data (with host bind paths) so the layout migration is explicit, not silent.

Integration tests

  • Testcontainers switched from stain/jena-fuseki:latest (5.1.0, missing CVE fixes) to secoresearch/fuseki:5.5.0.
  • New RdfGlossaryGraphIT.customRdfPredicateRelationSurfacesInGraphEndpoint test: registers a custom relation type via the settings API, points two terms at each other through it, asserts the graph endpoint returns the edge with the configured type name. Locks down the writer/reader symmetry the previous bug broke.
  • Companion RdfGlossaryGraphIT.customRelationWithNullRdfPredicateSurfacesInGraphEndpoint: same scenario but with rdfPredicate=null (the customer's exact config).
  • RdfIndexAppTest updated to assert compactStorage fires twice on a recreate run (pre-reindex + end-of-run) and once on incrementals.

Alternatives considered

  • Jena 6.1.0 — both 6.0.0 and 6.1.0 hit a static-init NPE. Workaround would require either pre-loading specific Jena classes in a particular order or waiting for an upstream fix. Parked.
  • Keeping apache-jena-libs BOM at 5.6.0 — pulls in jena-tdb1 whose subsystem init triggers the same family of static-init NPE on the first touch of RDF.Alt. Explicit deps avoid it and trim the wire surface.
  • TDB compaction via tdb2.tdbcompact CLI — requires Fuseki shutdown; impractical in production. The /$/compact REST endpoint works online and is supported by every Fuseki version we deploy.

Backward-compatibility

  • compactStorage(), bulkStoreEntities(), bulkCreateOrUpdate() are additive interfaces with default fallbacks where applicable.
  • Named volume rename is a deliberate break — old data lives at the old path and is left in place; operators can docker volume rm fuseki-data after confirming the new stack is healthy. Documented inline.

Tests:

Use cases covered

  • RdfIndexApp re-index with recreateIndex=true: clears + compacts + reloads ontology + reindexes + compacts again — in that exact order.
  • RdfIndexApp re-index with recreateIndex=false: skips clearAll/reloadOntologies, still fires end-of-run compactStorage.
  • JenaFusekiStorage.compactStorage() swallows failures so a missing/failing compact endpoint never fails the indexer.
  • bulkStoreEntities writes ~1655 entities in 9s vs the prior per-entity path's ~5 min.
  • /rdf/glossary/graph returns edges for both built-in and custom-rdfPredicate relation types, including the customer's rdfPredicate=null case.

Unit tests

  • RdfIndexAppTest.testExecuteClearsRdfDataWhenRecreateIndexEnabled — InOrder assertion enforces clearAll → compactStorage → reloadOntologies → compactStorage.
  • RdfIndexAppTest.testCompactStorageStillFiresOnIncrementalIndex — incremental runs still compact at the end.
  • Files updated: openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/rdf/RdfIndexAppTest.java.
  • All 203 RDF tests pass under Jena 5.6.0 (mvn -pl openmetadata-service test -Dtest='Rdf*').

Backend integration tests

  • RdfGlossaryGraphIT.customRdfPredicateRelationSurfacesInGraphEndpoint — locks down the explicit-rdfPredicate path.
  • RdfGlossaryGraphIT.customRelationWithNullRdfPredicateSurfacesInGraphEndpoint — locks down the rdfPredicate=null → om:<name> writer-fallback path (the customer's actual config).
  • Files updated: openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/RdfGlossaryGraphIT.java.

Manual testing performed

  • Fresh local stack build from this branch + replicated the customer's settings + terms via the OpenMetadata API. Graph endpoint correctly returns 6 edges including enrolledIn and enrolls for the Audience/Channel pair after RdfIndexApp recreate.
  • Verified -e FUSEKI_ADMIN_PASSWORD='Pass-WITH-$@#!' against the rebuilt Fuseki image: custom password authenticates, default admin/admin returns 401.

UI screen recording / screenshots:

Not applicable — the changes are backend-side. The customer's image-v6 (broken Relations Graph showing source node alone) now renders all edges including the custom-typed enrolledIn/enrollsin/definedby/enabledby ones.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests around the new logic (unit + integration).
  • I have added a test that covers the exact scenario we are fixing (custom-rdfPredicate and null-rdfPredicate variants both pinned).

🤖 Generated with Claude Code


Summary by Gitar

  • Added unit tests:
    • Introduced RdfBatchProcessorTest to validate bulk-write error handling, per-entity fallback isolation, and circuit-breaker short-circuiting logic.
    • Verified that isCircuitBreakerOpen correctly identifies wrapped exceptions in the cause chain to prevent redundant per-entity retries during outages.

This will update automatically on new commits.

PR #28117's SPARQL cleanup converged the logical RDF state but never freed
disk: TDB2 deletes only mark blocks free and the journal grows monotonically
until /$/compact runs. RdfIndexApp.clearRdfData() now calls a new
RdfStorageInterface.compactStorage() between clearAll() and reloadOntologies()
so each recreate run reclaims to a fresh dataset directory. JenaFusekiStorage
posts to /$/compact/{dataset}?deleteOld=true and polls /$/tasks/{id} until
finished, with failures logged and swallowed (disk hygiene, not correctness).

Also unifies the Jena classpath: openmetadata-service was on 4.10.0 and
openmetadata-integration-tests on 5.0.0. Both now pin to 5.6.0 via a single
root pom property, dropping the apache-jena-libs BOM in favour of explicit
jena-core/arq/rdfconnection deps (we're a remote-Fuseki client and never
embed TDB; pulling jena-tdb1/2 triggers a Jena 5/6 static-init regression).
Picks up CVE-2025-49656 and CVE-2025-50151 (admin-side fixes shipped in
Jena 5.5.0). Jena 6.x parked: both 6.0.0 and 6.1.0 hit a recursive clinit
bug where TypeMapper.reset reads RDF.dtLangString before RDF.<clinit>
completes.

Fuseki server bumped 4.10/5.0 → 5.6.0 across all in-repo Dockerfiles; the
unmaintained stain/jena-fuseki:* image references in dev compose files
switched to building from docker/rdf-store/Dockerfile, and Testcontainers
moved to secoresearch/fuseki:5.5.0 (maintained, CVE-fixed; the dataset is
created by JenaFusekiStorage.ensureDatasetExists() so the stain-only
FUSEKI_DATASET_1 env var is no longer needed).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 18, 2026 19:26
@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels May 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Follow-up to #28117 that fixes the unbounded Fuseki PVC growth observed across weekly re-index runs and unifies the Apache Jena classpath. RDF re-index now invokes Fuseki's /$/compact?deleteOld=true admin endpoint between clearAll() and reloadOntologies(), and the project standardizes on Jena 5.6.0 (server-side Fuseki images and client-side libs), replacing the unmaintained stain/jena-fuseki image with the in-repo Dockerfile build and secoresearch/fuseki:5.5.0 for tests.

Changes:

  • Adds compactStorage() to the storage interface, implements it for Fuseki with bounded polling on /$/tasks/{id}, and wires it into RdfIndexApp.clearRdfData() (only on recreateIndex=true).
  • Upgrades Apache Jena from 4.10.0 / 5.0.0 → 5.6.0 (single root pom property), switching openmetadata-service to explicit jena-core + jena-arq + jena-rdfconnection deps to avoid TDB1/2 static-init failures.
  • Bumps all in-repo Fuseki Dockerfiles to 5.6.0 and migrates dev/quickstart compose files plus Testcontainers off stain/jena-fuseki (using local build for compose, secoresearch/fuseki:5.5.0 for integration tests).

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pom.xml Adds project-wide jena.version=5.6.0 property.
openmetadata-service/pom.xml Drops apache-jena-libs BOM in favor of explicit Jena 5.6.0 client deps.
openmetadata-integration-tests/pom.xml Aligns Jena to ${jena.version}; switches test container image to secoresearch/fuseki:5.5.0.
openmetadata-service/.../RdfStorageInterface.java Adds default no-op compactStorage() with Javadoc.
openmetadata-service/.../JenaFusekiStorage.java Implements compaction via /$/compact admin POST + /$/tasks/{id} polling; extracts parseDatasetEndpoint and addBasicAuth helpers.
openmetadata-service/.../RdfRepository.java Thin compactStorage() wrapper gated on isEnabled().
openmetadata-service/.../RdfIndexApp.java Runs compaction between clearAll and reloadOntologies on recreate.
openmetadata-service/.../RdfIndexAppTest.java Updated test for new ordering + new test that compaction is skipped on incremental runs.
openmetadata-integration-tests/.../RdfGlossaryGraphIT.java, GlossaryOntologyExportIT.java, TestSuiteBootstrap.java Switch Testcontainers Fuseki image; drop FUSEKI_DATASET_1 env.
docker/rdf-store/Dockerfile, docker/docker-compose-quickstart/Dockerfile.fuseki-* Bump FUSEKI_VERSION to 5.6.0.
docker/docker-compose-quickstart/docker-compose-{rdf,fuseki-standalone,fuseki-rosetta}.yml, docker/development/docker-compose-fuseki.yml, docker-compose-postgres-fuseki.yml Switch from stain/jena-fuseki image to in-repo Dockerfile build; rename env var; update mount path to /fuseki-data.
docker/docker-compose-quickstart/start-rdf-services.sh Comment update reflecting new build context.
Comments suppressed due to low confidence (2)

openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java:1090

  • The poll loop sleeps before each request, which means even a compaction that finished by the time we issued the POST will still incur a 2-second wait before being detected. Consider polling once immediately after starting the task and then sleeping between subsequent polls, so fast/no-op compactions complete quickly.
    while (System.currentTimeMillis() < deadline) {
      Thread.sleep(COMPACT_POLL_INTERVAL_MS);

openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java:1080

  • extractTaskId and isTaskFinished allocate a fresh HttpClient per startCompaction/waitForCompactionTask call and otherwise look up JsonUtils.readTree from the response body, but they catch Exception (a very broad net) instead of IOException / JsonProcessingException. Narrowing the catch would avoid masking unrelated runtime bugs (e.g., NPEs from a refactor in JsonUtils). Minor maintainability nit.
    } catch (Exception e) {
      LOG.debug("Could not parse taskId from Fuseki compaction response: {}", responseBody, e);
      return null;
    }

- Dockerfile sets FUSEKI_BASE=/fuseki so the bundled shiro.ini is actually
  loaded. Without it, Fuseki falls back to its default base and admin
  endpoints (including the new /$/compact and /$/datasets) are reachable
  without authentication — FUSEKI_ADMIN_PASSWORD was being silently ignored.

- Rename the named volume `fuseki-data` -> `fuseki-tdb2-data` and the host
  bind paths in the rosetta/standalone compose variants. The new layout
  stores TDB2 at /fuseki-data and is structurally different from stain's
  old /fuseki layout; reusing the old volume name silently mounted stale
  state at a path Fuseki no longer reads from, looking like an empty
  database. A fresh volume name forces operators to consciously migrate
  (or accept a re-index).

- JenaFusekiStorage.addBasicAuth now encodes via StandardCharsets.UTF_8
  per RFC 7617 (was relying on the JVM default charset).

- compactStorage handles InterruptedException explicitly and re-asserts
  Thread.currentThread().interrupt() so a Quartz shutdown signal isn't
  silently swallowed by the surrounding catch block.

- Narrow the broad `catch (Exception)` in extractTaskId/isTaskFinished
  to JsonParsingException (the actual unchecked type JsonUtils.readTree
  throws); polling I/O failures catch java.io.IOException specifically.

- Compaction poll loop restructured to check immediately on the first
  iteration and sleep only between subsequent polls. For the common
  recreateIndex=true case (compacting a logically empty dataset) the
  task finishes near-instantly and we no longer waste the first 2s.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Last review pass flagged the new compaction catch blocks using
java.io.IOException and org.openmetadata.schema.exception.JsonParsingException
as fully-qualified names — inconsistent with the rest of the file (which
imports ConnectException, ClosedChannelException, etc.) and against CLAUDE.md's
"do not use Fully Qualified Names in code — import the class instead". Adds
explicit imports and replaces the FQN usages.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 18, 2026 20:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.

Probing the affected customer instance (Novartis pov) surfaced three custom
glossary relation types — `definedby`, `enabledby`, `enrollsin` — with
`rdfPredicate=null` in GlossaryTermRelationSettings. The writer
(getGlossaryTermRelationPredicate) handles this by falling back to
`https://open-metadata.org/ontology/<typeName>`, but the previous reader
fix only included configured types where `rdfPredicate != null`, so those
three predicates kept getting filtered out of /rdf/glossary/graph even
after the prior commit. Symptom: only edges with `relatedTo` (default
type, in the hardcoded list) appeared on the Relations Graph tab;
everything custom-named stayed invisible — exactly what image-v9 confirms.

Mirror the writer's fallback in buildGlossaryTermGraphQuery: if
rdfPredicate is null but the type has a non-blank name, add
`<https://open-metadata.org/ontology/<name>>` to the FILTER list.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 18, 2026 23:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 10 comments.

Comment thread docker/rdf-store/entrypoint.sh Resolved
harshach and others added 2 commits May 18, 2026 16:57
Companion to the existing customRdfPredicateRelationSurfacesInGraphEndpoint
test. That one exercises configured types with an explicit rdfPredicate URI;
this one exercises the case the affected customer instance actually had —
custom relation types registered in GlossaryTermRelationSettings WITHOUT a
populated rdfPredicate (Novartis pov had `definedby`, `enabledby`,
`enrollsin` all stored as rdfPredicate=null).

Reproduced the exact failure end-to-end against a freshly-built local stack
populated from the remote (5 glossaries, 79 terms, the 3 custom relation
types with null rdfPredicate plus their relations). Pre-fix the reader
filter dropped `om:enrollsin` and `om:definedby` triples — graph endpoint
returned 0 edges between Audience and its related terms even though Fuseki
had 4 triples and the DB had the relations. Post-fix the same query
returns the 2 expected edges (one per directed pair; the endpoint
deduplicates inverses).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Six fixes from the most recent review pass:

1. extractPredicateName round-trips configured type name.

   Previously the reader took the URI's last path segment as the relation
   type, so a configured `enrolledIn` mapped to `https://acme.com/ns#enrolls`
   surfaced as `enrolls` on the graph endpoint — losing the user's chosen
   type name. Failing IT (regressionCustomRel + custom path /customRel)
   exposed this. Now extractPredicateName checks GlossaryTermRelationSettings
   for a matching rdfPredicate before falling back to the URI local name,
   so the type name round-trips correctly.

2. compactStorage honors the circuit breaker.

   Added a throwIfCircuitOpen-equivalent check at the top of
   compactStorage. When Fuseki is unreachable the breaker is already open;
   running compact would burn its two-call budget hitting timeouts on the
   same dead server. Skipping is the right behavior, mirroring the other
   methods that throwIfCircuitOpen.

3. Mask userInfo in log statements.

   parseDatasetEndpoint now preserves embedded credentials so admin calls
   reach the server with the right auth. The flip side is the resulting
   URL must NOT hit logs verbatim — added a maskUserInfo helper that
   replaces `user:pass@` with `***@` and used it everywhere endpoint /
   serverBaseUrl is logged.

4. Typed RdfStorageCircuitOpenException replaces string-matching.

   isCircuitBreakerOpen in RdfBatchProcessor used to grep the exception
   message for "RDF circuit breaker is open" — that coupled callers to a
   specific log phrasing. Replaced with a public exception type that
   throwIfCircuitOpen throws; the fallback path now instanceof-checks it.

5. bulkCreateOrUpdate semantics doc clarified.

   The previous "all-or-nothing" wording was true from the caller's
   perspective (one thrown exception = retry whole batch) but glossed over
   the two-phase implementation (combined DELETE + combined GSP POST,
   non-atomic if the second call fails after the first commits).
   Documented the gap and that the per-entity fall-back is the
   self-healing mechanism.

6. Stop-signal coverage in the bulk path documented.

   The bulk path is one SPARQL UPDATE + one GSP POST per batch, so a
   mid-batch stop check doesn't apply (no checkpoint to break at). The
   pre-batch and per-iteration-of-fallback checks together preserve the
   prior loop's behavior; documented inline.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 10 comments.

Comment thread docker/rdf-store/entrypoint.sh Resolved
harshach and others added 2 commits May 18, 2026 17:43
…okups

Gitar review caught two new `catch (Exception)` blocks the prior commit
added in RdfRepository — one in buildGlossaryTermGraphQuery's
settings-aware predicate-list assembly, one in extractPredicateName's
predicate-name round-trip. SettingsCache.getSetting surfaces every
failure (cache miss / cast / I/O) as EntityNotFoundException — a
RuntimeException — so RuntimeException is the precise type to catch.
Narrowing avoids accidentally swallowing programmer-error throwables
(NPE, ClassCast) that signal a real bug rather than a transient cache
miss, matching the project's "no `catch (Exception e)`" coding standard.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… etc.

Seven fixes from the latest Copilot review pass:

1. Mark job COMPLETED *before* compactStorage, not after.

   compactStorage blocks up to COMPACT_MAX_WAIT_MS (10 min) polling
   /$/tasks/{id}. Doing it before the status update delayed the websocket
   "done" notification by however long compaction took, and a misbehaving
   Fuseki could leave the run looking RUNNING for up to 10 minutes after
   the reindex actually finished. Order now: COMPLETED → compactStorage,
   so completion surfaces immediately and the hygiene step runs as the
   very last thing.

2. compactStorage's outer catch broadened to RuntimeException.

   The Javadoc promises "Failures are logged and swallowed — degraded disk
   reclamation must not fail the re-index", but the previous outer try
   only caught InterruptedException + IOException. Any
   IllegalArgumentException, RdfStorageCircuitOpenException (state flip
   mid-call), CompletableFuture-wrapped RuntimeException, etc. would
   propagate up and demote a successful indexer run to FAILED. Added a
   catch (RuntimeException) so the documented best-effort semantics hold.

3. Hoist URL userInfo into Authorization header instead of leaving it
   embedded in the request URI.

   parseDatasetEndpoint previously returned a serverBaseUrl containing
   `user:pass@host:port` so embedded auth would reach the admin endpoints.
   That left credentials in the URL passed to HttpClient — which can leak
   via JDK HttpClient debug logging or downstream proxies. Now
   parseDatasetEndpoint splits userInfo OUT into a separate field on
   DatasetEndpoint; serverBaseUrl is credential-free; the admin HTTP path
   uses a new 3-arg addBasicAuth overload that prefers explicit
   username/password and falls back to userInfo from the URL, encoding
   either into the Authorization header.

4. URL-encode datasetName + taskId before interpolating into request URIs.

   startCompaction built `/$/compact/<datasetName>` and waitForCompactionTask
   built `/$/tasks/<taskId>` via raw concatenation. A dataset name (or
   future task id from a server that uses non-trivial identifiers) with
   any URL-reserved character would corrupt the URL. New encodePathSegment
   helper handles this with the same UTF-8 + space-as-%20 convention.

5. Compose files use ${FUSEKI_ADMIN_PASSWORD:-admin} indirection.

   Four dev/quickstart compose files (docker-compose-fuseki.yml,
   docker-compose-postgres-fuseki.yml, docker-compose-fuseki-rosetta.yml,
   docker-compose-fuseki-standalone.yml) previously had the literal
   `FUSEKI_ADMIN_PASSWORD=admin` baked in. Operators couldn't override
   without editing the compose file. Now they pass through the env var
   if set, with `admin` only as the local-dev default. Same for
   FUSEKI_OPENMETADATA_PASSWORD. A leading comment block warns that
   production deployments MUST override.

6. Entrypoint honors FUSEKI_RENDER_SHIRO=false escape hatch.

   The previous entrypoint unconditionally overwrote /fuseki/shiro.ini
   from the template, clobbering a bind-mounted custom shiro.ini.
   Operators who need a fully custom Shiro config can now either:
   - bind-mount onto /fuseki/shiro.ini AND set FUSEKI_RENDER_SHIRO=false
     (skip the render), OR
   - bind-mount onto /fuseki/shiro.ini.template (render their template
     with the standard FUSEKI_ADMIN_PASSWORD envsubst)
   Default behavior unchanged for everyone else.

7. Test ordering still verified.

   RdfIndexAppTest's InOrder assertion was unchanged by point #1 — it
   asserts compactStorage WAS called twice on a recreate run, regardless
   of where in the sequence the COMPLETED status update lands. All 203
   RDF unit tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfRepository.java:1295

  • The settings-aware predicate expansion is only added in the else branch (when no relationTypes filter is supplied). When a caller does pass a relationTypes filter — including with a custom type name like ?relationTypes=enrolledIn — execution goes through the if branch which calls getRelationPredicate(trimmed). That helper has no awareness of GlossaryTermRelationSettings, lowercases the input (relType.trim().toLowerCase() at line 1292), and falls back to "om:" + relationType with the lowercased name. So a filter by a custom type configured with rdfPredicate=null will produce om:enrolledin (lowercase) while the writer stored the triple at https://open-metadata.org/ontology/enrolledIn (original case) — the predicates won't match and the edge is still filtered out. Custom types configured with an explicit rdfPredicate also aren't honored on this filtered path at all. Consider also consulting settings in getRelationPredicate/buildGlossaryTermGraphQuery's filtered branch to fully fix the writer/reader symmetry.
    List<String> relationPredicates = new ArrayList<>();
    if (relationTypes != null && !relationTypes.isEmpty()) {
      for (String relType : relationTypes.split(",")) {
        String trimmed = relType.trim().toLowerCase();
        relationPredicates.add(getRelationPredicate(trimmed));
      }
    } else {

harshach and others added 2 commits May 18, 2026 18:06
…ame cache

Five fixes from review 4314989032:

1. Atomic bulk entity writes (single SPARQL UPDATE transaction).

   Previously bulkStoreEntities issued (a) a SPARQL UPDATE with the
   combined DELETE statements, then (b) a GSP POST to load the unioned
   model. Atomic at the per-call level but NOT atomic across the pair: a
   failed (b) after a committed (a) left the dataset in a half-applied
   state — every entity's prior translator-managed predicates gone but
   the new triples never landed. Now both halves run inside ONE multi-
   statement SPARQL UPDATE: `DELETE ...; INSERT DATA { GRAPH <...> {
   N-Triples body } }`. Fuseki executes multi-statement UPDATEs in a
   single transaction so the batch commits atomically or rolls back
   entirely. Also collapses the prior 2 HTTP calls per batch to 1.

2. FUSEKI_OPENMETADATA_PASSWORD pass-through in docker-compose-rdf.yml.

   The other four migrated compose files (fuseki.yml, postgres-fuseki.yml,
   fuseki-standalone.yml, fuseki-rosetta.yml) all expose both
   FUSEKI_ADMIN_PASSWORD and FUSEKI_OPENMETADATA_PASSWORD; this one only
   had ADMIN. Operators using the quickstart compose had no way to
   override the service-account password from the env. Symmetrized.

3. Document the predicate-shape failure caveat in the bulk fallback.

   The per-entity fallback isolates bad-ROW failures (one entity emits a
   model the writer can't serialise) but NOT bad-PREDICATE failures (a
   configured custom predicate URI contains a SPARQL-unsafe character so
   every entity in the batch hits the same parse failure). The Javadoc
   previously over-promised on isolation; added an inline caveat.

4. Cycle-safe isCircuitBreakerOpen.

   The cause-chain walk only guarded against single-hop self-cycles
   (next == cause). Multi-hop cycles (A→B→A) would loop forever. Now
   uses an IdentityHashMap-backed visited set so any cycle is detected.

5. Per-request predicate-name cache.

   extractPredicateName was called per-edge and walked the full
   relationTypes list with a regex+concat (expandPredicateCurie) per
   iteration on every call. parseGlossaryTermGraphResults now builds the
   URI→name map ONCE per request via buildPredicateUriToNameMap and
   stashes it on a ThreadLocal that extractPredicateName reads. Cleared
   in finally so it can't leak across requests. Turns the inner-loop
   work from O(edges × relationTypes) to O(edges).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds 27 unit tests covering the package-private helpers on
JenaFusekiStorage that all the admin HTTP paths depend on:
parseDatasetEndpoint, maskUserInfo, encodePathSegment, extractTaskId,
isTaskFinished. These methods do credential handling and URL parsing on
config-supplied input, so getting them wrong corrupts every admin call —
and the class itself has too many heavy dependencies (Jena, Fuseki HTTP)
to spin up in a unit test.

Made the five helpers (and the DatasetEndpoint record) package-private
so the test class in the same package can reach them without reflection.

Coverage:
- parseDatasetEndpoint: plain shape, service-path strip, no-port,
  embedded user:pass@ hoist (CRITICAL: serverBaseUrl must not carry
  credentials so JDK HttpClient debug / proxies don't leak them),
  URL-encoded userInfo round-trip, malformed URL, missing path, null.
- maskUserInfo: strips user:pass@ to ***@, passes plain URLs unchanged,
  HTTPS+no-port, null, non-URL fallback path.
- encodePathSegment: plain, space→%20 (not +), reserved-char escaping.
- extractTaskId: typical response, string IDs, missing key, JSON null,
  blank body, malformed JSON.
- isTaskFinished: completed (finished timestamp), still running,
  null/blank, malformed JSON.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.

harshach and others added 2 commits May 18, 2026 18:32
…ebug

Two from review 4315040144:

1. bulkCreateOrUpdate Javadoc now matches the implementation. The previous
   wording described a two-call non-atomic path (combined DELETE +
   separate GSP POST) and warned about INCONSISTENT state if the second
   call failed — but the storage layer has since been rewritten to run
   the whole batch as ONE SPARQL UPDATE (DELETE statements + INSERT DATA
   in a single Fuseki transaction). The stale doc would have misled
   future maintainers about the failure semantics.

2. The "RDF Edge: ... predicateUri=... extractedType=... label=..." log
   inside parseGlossaryTermGraphResults fired once per edge in the SPARQL
   result set — hundreds of INFO lines per request on a typical graph
   response. Downgraded to DEBUG to match the per-batch DEBUG choice in
   JenaFusekiStorage.bulkStoreEntities; the per-request summary log
   ("RDF query returned {} nodes and {} edges") still emits at INFO for
   ops visibility.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Pins the three branches of processEntities that prior reviews flagged
as the highest-complexity uncovered logic on the bulk-write fast path:
bulk success, bulk failure -> per-entity recovery, and bulk failure +
tripped circuit breaker -> fallback SKIPPED. Also covers the cause-chain
walk in isCircuitBreakerOpen so a breaker exception wrapped by
RdfRepository.bulkCreateOrUpdate's RuntimeException re-throw is still
detected, plus stop-signal short-circuits before and during fallback.

The per-entity fallback test uses lenient() on the doThrow for the bad
entity because MockitoExtension's strict stubbing would otherwise throw
PotentialStubbingProblem on createOrUpdate calls for the *good* entities
(arg doesn't match the stubbed value), which the fallback's catch
(Exception) would treat as entity failures and silently skew the
success/failure counts the test asserts on.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 10 comments.

Comment thread docker/rdf-store/shiro.ini.template Resolved
Four small follow-ups for the still-open review comments:

* RdfIndexApp.compactStorage() call wrapped in its own try/catch so a
  future storage backend that does NOT honor the swallow-failures
  contract (or an NPE racing the isEnabled() check) cannot demote a
  job that's already been marked COMPLETED to FAILED via the outer
  handleJobFailure() path.

* RdfRepository: extracted resolveConfiguredTypeUri(rdfPredicate, name)
  helper and used it at both call sites in buildGlossaryTermGraphQuery
  and buildPredicateUriToNameMap. Single source of truth for the
  settings-driven URI shape — the duplicated `expandPredicateCurie(...)
  else "https://open-metadata.org/ontology/" + name` branches were
  identical but reviewers (rightly) flagged the drift risk.

* JenaFusekiStorage.waitForCompactionTask: added a deadline re-check
  AFTER each HTTP send. With COMPACT_HTTP_TIMEOUT=30s, a server that
  hangs every poll could overrun COMPACT_MAX_WAIT_MS by ~30s before
  the next loop-top check fired; the post-send guard breaks promptly.

* Renamed docker/rdf-store/shiro.ini -> shiro.ini.template (source side
  was misleading — file is unusable without envsubst and someone
  mounting just `shiro.ini` would silently end up with the literal
  string `${FUSEKI_ADMIN_PASSWORD}` as the admin password). Updated
  Dockerfile COPY and added a prominent TEMPLATE FILE header inside
  the file itself.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@gitar-bot

gitar-bot Bot commented May 19, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 5 resolved / 5 findings

Implements Fuseki disk compaction, bulk entity processing, and Jena 5.6.0 upgrades to resolve disk growth and graph visibility issues. Resolved findings include updating charset handling, cleaning up exception imports, and adjusting logging levels.

✅ 5 resolved
✅ Quality: addBasicAuth uses platform-default charset for Base64 encoding

📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java:202
RFC 7617 (HTTP Basic Authentication) mandates UTF-8 for the credential string before Base64 encoding. auth.getBytes() uses the JVM's default charset, which is usually UTF-8 on modern systems but is not guaranteed (especially in containerized environments with non-standard locale). Explicitly specifying StandardCharsets.UTF_8 makes the behavior deterministic and correct per spec.

✅ Quality: Fully-qualified exception names used instead of imports

📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java:1038 📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java:1093 📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java:1124 📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java:1162
The catch blocks use fully-qualified class names (java.io.IOException, org.openmetadata.schema.exception.JsonParsingException) instead of importing them at the top of the file. Other exceptions in this file (e.g., ConnectException, ClosedChannelException) are properly imported. This is purely cosmetic but hurts readability of the catch clauses.

✅ Performance: LOG.info in bulkStoreEntities will be very noisy during reindex

📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/storage/JenaFusekiStorage.java:514-518
During a full reindex, bulkStoreEntities is called once per batch (default 100 entities). With thousands of entities, this produces hundreds or thousands of INFO-level log lines (one per batch). Since this is a hot path during reindex, it should use LOG.debug like the single-entity path and the bulkCreateOrUpdate wrapper (line 241) already does.

✅ Quality: Generic Exception catch violates project coding standards

📄 openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfRepository.java:1952
The new extractPredicateName lookup (lines 1952) catches bare Exception. Per the project's Java Backend Requirements, generic Exception catches should be avoided — prefer catching specific checked exceptions (e.g., RuntimeException + the specific checked exceptions SettingsCache.getSetting can throw). The intent (never crash the predicate extraction path) is sound, but a narrower catch communicates that intent more precisely and avoids accidentally swallowing programmer errors like NullPointerException or ClassCastException that signal a real bug rather than a transient cache miss.

✅ Quality: Null-endpoint test asserts nothing definitive

📄 openmetadata-service/src/test/java/org/openmetadata/service/rdf/storage/JenaFusekiStorageTest.java:116-129
The nullEndpoint() test at lines 121-129 catches NullPointerException and treats it as acceptable, meaning the test passes whether the method returns null OR throws NPE. This defeats the purpose of a regression test — if a future change accidentally introduces an NPE, this test will still pass silently. Either assert the method handles null gracefully (and remove the catch) or document that NPE is the expected contract and use assertThrows.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (16 flaky)

✅ 4136 passed · ❌ 0 failed · 🟡 16 flaky · ⏭️ 86 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 298 0 1 4
🟡 Shard 2 777 0 4 8
🟡 Shard 3 776 0 2 7
🟡 Shard 4 780 0 2 12
🟡 Shard 5 772 0 1 47
🟡 Shard 6 733 0 6 8
🟡 16 flaky test(s) (passed on retry)
  • Pages/AuditLogs.spec.ts › should apply both User and EntityType filters simultaneously (shard 1, 1 retry)
  • Features/ActivityAPI.spec.ts › creates an activity event when tags are added (shard 2, 1 retry)
  • Features/Glossary/GlossaryWorkflow.spec.ts › should start term as Draft when glossary has reviewers (shard 2, 1 retry)
  • Features/IncidentManager.spec.ts › Complete Incident lifecycle with table owner (shard 2, 1 retry)
  • Features/KnowledgeCenter.spec.ts › Article mentions in description should working for Knowledge Center (shard 2, 1 retry)
  • Features/RTL.spec.ts › Verify Following widget functionality (shard 3, 1 retry)
  • Features/TestSuitePipelineRedeploy.spec.ts › Re-deploy all test-suite ingestion pipelines (shard 3, 1 retry)
  • Pages/CustomProperties.spec.ts › Set & Update all CP types on apiCollection (shard 4, 1 retry)
  • Pages/DataContractsSemanticRules.spec.ts › Validate DataProduct Rule Any_In (shard 4, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 5, 1 retry)
  • Pages/Glossary.spec.ts › Create glossary, change language to Dutch, and delete glossary (shard 6, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Glossary CSV import preserves typed relations (shard 6, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › Column lineage for topic -> searchIndex (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: searchIndex (shard 6, 1 retry)
  • Pages/Users.spec.ts › Create and Delete user (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

This branch was previously deployed

1 inactive deployment
test — 213420be Deployed May 19, 2026 by harshach via playwright-ci-postgresql (4, 6) #47514
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.

2 participants