Repository navigation
fix(rdf): resolve RdfRepository fresh to unblock 2.0 parallel IT lane (RdfGlossaryGraphIT 500s) - #34005
Conversation
…instance RdfResource cached the first RdfRepository in a volatile field and never refreshed it. RdfUpdater.initialize() calls RdfRepository.reset() (close + null the static INSTANCE) and rebuilds it for durable live projection / reindex, so after such a swap RdfResource kept serving the closed store and every RDF endpoint 500'd. This surfaced on 2.0 once #33098 added RdfLiveProjectionIT (single-writer live projection) to the shared-app parallel IT lane: when it ran before RdfGlossaryGraphIT in the same JVM it reset the singleton, and all 11 RdfGlossaryGraphIT cases got 500 from GET /v1/rdf/glossary/graph. main does not hit this because #28042 resolves the repository fresh via a Supplier. - getRdfRepository(): return RdfRepository.getInstanceOrNull() on every call; drop the pinned field. - getSemanticSearchEngine(): rebuild when the underlying repository instance changes so it can't hold a reference the reset invalidated.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| private volatile SemanticSearchEngine semanticSearchEngine; | ||
| private volatile RdfRepository semanticSearchEngineRepository; |
There was a problem hiding this comment.
💡 Bug: Unlocked fast path can return engine bound to the old repository
Two separate volatile fields hold the engine/repository pair. Inside the lock, the writer sets semanticSearchEngine and then semanticSearchEngineRepository. The unlocked reader reads the engine into local first and checks the repository field second. A reader can therefore get the old engine, then see the new repository reference that matches repository, skip the rebuild, and return an engine still bound to the closed store. That is the same staleness this PR is trying to remove. Fix: publish the pair atomically in one volatile holder (a record) and compare against the holder's repository.
Publish engine and its repository atomically via a single volatile record:
private record EngineBinding(RdfRepository repository, SemanticSearchEngine engine) {}
private volatile EngineBinding engineBinding;
private SemanticSearchEngine getSemanticSearchEngine() {
final RdfRepository repository = getRdfRepository();
EngineBinding binding = engineBinding;
if (repository != null && (binding == null || binding.repository() != repository)) {
binding = new EngineBinding(
repository, new SemanticSearchEngine(repository, Entity.getSearchRepository()));
engineBinding = binding;
}
return repository == null ? null : binding.engine();
}
Was this helpful? React with 👍 / 👎
Addresses review: getRdfRepository() now resolves the live singleton on every call, which RdfUpdater.reset() can transiently null, so reading it twice in a handler (null/enabled check then use) could NPE if a reset lands between them. Each handler now reads it once into a final local and uses that, matching main's pattern. getSemanticSearchEngine() also resolves the repo once during construction. Reverted the getSemanticSearchEngine rebuild-on-repo-change change: it is not needed to fix the failing RdfGlossaryGraphIT (which uses getRdfRepository() directly) and kept /search/semantic exactly as it was.
✅ Playwright Results — workflow succeededValidated commit ✅ 897 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 43m 16s ⏱️ Max setup 2m 49s · max shard execution 18m 0s · max shard-job elapsed before upload 21m 40s · reporting 6s 🌐 188.01 requests/attempt · 2.29 app boots/UI scenario · 24.26% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Code Review 👍 Approved with suggestions 1 closed / 2 findings🟡 Medium risk · RDF endpoints now resolve the live repository per request, changing backend behavior Resolves stale repository references in Consider atomically publishing the semantic search engine and repository pair in a single volatile holder to prevent an unlocked reader from obtaining an engine bound to a closed repository while the writer is updating the pair. 💡 Bug: Unlocked fast path can return engine bound to the old repository📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfResource.java:58-59 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfResource.java:82-96 Two separate volatile fields hold the engine/repository pair. Inside the lock, the writer sets Publish engine and its repository atomically via a single volatile record✅ 1 closed✅ Bug: Repeated getRdfRepository() calls can NPE during reset window
🤖 Prompt for agentsOptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|



Problem
The
Integration Test Lane (parallel)is red on the 2.0 branch across unrelated PRs.RdfGlossaryGraphITfails 11/11 with500 "An internal error occurred"fromGET /v1/rdf/glossary/graph. It is order-dependent — it only fails when another RDF test runs before it in the same shared-app lane — so it also passes on retry, making CI flaky for everyone targeting 2.0.Root cause
RdfResourcepinned the repository:RdfUpdater.initialize()callsRdfRepository.reset()(whichclose()s and nulls the staticINSTANCE) and then rebuilds a fresh singleton — this is the durable single-writer live-projection / reindex path. After such a swap,RdfResourcekeeps returning the old, closed repository, sogetGlossaryTermGraph(...)throws and the handler returns 500.getSemanticSearchEngine()had the same latent staleness (it caches an engine built on one repository instance).Which PR introduced it
#33098 ("Backport single-writer RDF reindex pipeline to 2.0", Sep 10) added
RdfLiveProjectionIT, which exercises the live-projection path that resets/rebuilds theRdfRepositorysingleton mid-lane. In the shared-app parallel lane, when it runs beforeRdfGlossaryGraphIT, the pinned repo is left closed.maindoes not hit this because #28042 resolves the repository fresh via aSupplier<RdfRepository>instead of pinning it. The pinning itself predates #33098; #33098 introduced the mid-lane reset that exposes it.Fix
Mirror main's behaviour with a minimal change (no feature backport):
getRdfRepository()resolvesRdfRepository.getInstanceOrNull()on every call; the pinned field is removed.getSemanticSearchEngine()rebuilds when the underlying repository instance changes, so it can't hold a reference areset()invalidated.This is also correct beyond tests: in production any
RdfUpdater.initialize()re-run (config reload / reindex) would otherwise leave the endpoints serving a dead store.Verification
mvn -pl openmetadata-service -am install -DskipTests→ BUILD SUCCESS.Integration Test Lane (parallel)on this PR — the exact lane that is failing today.