Skip to content

Fixes 30008: Improve server startup and write-path latency - #30009

Merged
harshach merged 37 commits into
mainfrom
harshach/perf-analysis-startup-latency
Aug 23, 2026
Merged

harshach merged 37 commits into
mainfrom
harshach/perf-analysis-startup-latency

Conversation

@harshach

@harshach harshach commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #30008

I improved server startup and request/write latency, and hardened lineage queries because warm boots repeated bundled-data and search reconciliation, writes repeated JSON serialization, the pipeline-summary service type was interpolated into SQL, and pipeline-reference relation filters had incorrect Boolean precedence.

Type of change:

  • Improvement

High-level design:

  • Startup observability: ordered step timings, slow-resource attribution, standard request-latency buckets, and opt-in percentile histograms
  • Warm-start path: SHA-256 gates for bundled seed data and search templates, an indexed hard-row presence check for every required bundled seed entity, failure-safe retries, bounded parallel index initialization, and database-backed type-registry hydration
  • Classpath/auth path: one shared ClassGraph scan, one cached classpath resource index, and bounded RBAC SpEL memoization
  • Write path: direct Jakarta JSON-P conversion, replayable TokenBuffer retry snapshots, storage-JSON reuse for cache write-through, and lifecycle snapshot gating
  • Database path: bound pipeline-summary filters plus correctly grouped pipeline-reference relationship predicates
  • Rollout: startup gates default on with force/disable controls; fingerprint persistence uses the existing settings table
  • Compatibility: AI control FQNs are now framework-qualified; this entity is only on unreleased 2.0.0-SNAPSHOT, so no production migration is required, but development databases that already seeded flat control FQNs should be reset
  • Alternatives: duplicate MySQL pipeline-name DDL was rejected because migration 1.2.0 already creates it; Flowable/Quartz deferral remains evidence-gated behind the new timing data

Tests:

Use cases covered

  • First, unchanged, changed, failed, and forced seed/template fingerprint decisions
  • Matching seed fingerprints with hard-missing required rows rerun seed loaders; matching search checksums verify live template markers; probe failures fail open and intentionally deletable seeds remain optional
  • Parallel index creation and template acknowledgement/failure handling
  • PATCH conversion equivalence, replayable retry state, cache JSON reuse, and lifecycle snapshot suppression
  • Pipeline-summary filtering/pagination and quote-containing service-type input
  • Pipeline-reference lineage relation precedence and source-lineage deletion
  • Forced-deadlock update replay without double version bumps or consolidation corruption

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: CommonUtilTest, StartupTimerTest, SeedDataGateTest, FrameworkSeedLoaderTest, ClasspathScanIndexTest, CollectionRegistryTest, RBACConditionEvaluatorCacheTest, IndexTemplateManagerTest, EntityRepositoryStorageJsonReuseTest, EntityLifecycleEventDispatcherTest, RequestLatencyContextTest, MicrometerBundleTest, SettingsRowMapperTest, and JsonUtilsTest
  • Final review-focused result: SeedDataGateTest and FrameworkSeedLoaderTest passed 9/9 combined; IndexTemplateManagerTest passed 10/10
  • Coverage %: not measured

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for new/changed backend behavior.
  • Files added/updated: PipelineResourceIT.java, LineageResourceIT.java, SeedDataPresenceIT.java, AIFrameworkControlResourceIT.java, and IndexTemplateIT.java
  • LineageResourceIT: PostgreSQL and MySQL each passed 51 tests with 0 failures and 0 errors (3 skipped)
  • MySQL 8.3 + Elasticsearch 9.3: 2 forced-deadlock replay tests passed
  • The seed-presence, AI control collision, and search-template integration sources compile; local container execution was blocked before test discovery because exhausted Docker VM storage prevented Testcontainers from creating a container

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Ran clean specification generation/install and compiled service plus integration-test sources
  2. Ran MySQL and PostgreSQL migration smoke checks
  3. Ran mvn spotless:apply, mvn spotless:check, schema validation, and git diff --check

UI screen recording / screenshots:

Not applicable.

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: I updated the migration scripts or explained why it is not needed.
  • For UI changes: not applicable; this PR has no UI changes.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added tests around the new logic.

Greptile Summary

This PR improves startup gating, search initialization, write-path latency, and lineage query behavior. The main changes are:

  • Startup fingerprints for bundled seed data and search templates.
  • Required seed-row checks before skipping warm-start seed loaders.
  • Live search-template fingerprint checks before skipping template updates.
  • Bounded parallel search index initialization.
  • Pipeline summary filtering and pipeline lineage query fixes.
  • JSON/write-path reuse and lifecycle snapshot gating.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The seed-data warm-start path now checks required database rows before skipping loaders.
  • The search-template warm-start path now checks live template fingerprints before skipping updates.

Important Files Changed

Filename Overview
openmetadata-service/src/main/java/org/openmetadata/service/seeding/SeedDataGate.java Adds startup checksum handling, seed-row drift checks, search-template gate state, and clean or failed startup stamping.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SystemRepository.java Adds a required seed-row presence check used by the startup seed gate.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java Adds seed-row counting, bound pipeline summary service-type filters, and grouped pipeline lineage predicates.
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java Adds bounded missing-index initialization and live search-template fingerprint validation.
openmetadata-service/src/main/java/org/openmetadata/service/search/GenericClient.java Adds the shared search-template fingerprint contract used by Elasticsearch and OpenSearch clients.

Reviews (23): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

Context used (3)

  • Context used - openmetadata-ui-core-components/CLAUDE.md (source)
  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Jul 14, 2026
@harshach
harshach marked this pull request as ready for review July 14, 2026 04:22
Copilot AI lite review requested due to automatic review settings July 14, 2026 04:22
@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

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

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

✅ TypeScript Types Auto-Updated

The generated TypeScript types have been automatically updated based on JSON schema changes in this PR.

Copilot AI review requested due to automatic review settings July 14, 2026 04:26
@github-actions
github-actions Bot requested a review from a team as a code owner July 14, 2026 04:26
@harshach
harshach removed the request for review from Copilot July 14, 2026 04:26
Copilot AI review requested due to automatic review settings July 14, 2026 04:40

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 67%
67.06% (80442/119952) 51.47% (49251/95678) 52.46% (14707/28032)

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 82 out of 85 changed files in this pull request and generated no new comments.

Suppressed comments (1)

common/src/main/java/org/openmetadata/common/utils/CommonUtil.java:59

  • classpathResourceIndex caches every resource entry from all openmetadata/collate JARs and directories (see indexResourcesFromJarFile adding every ZipEntry). This can be very large and is never bounded/evicted, increasing steady-state heap usage and risking OOM on deployments with large classpaths.

Consider caching per-pattern results with an LRU/size cap (the set of patterns is small), or at least filtering the indexed resources to the known prefixes you query (e.g., json/schema/, json/data/) so the cached index cannot grow to the full JAR contents.

  private static final List<String> JAR_NAME_FILTER = List.of("openmetadata", "collate");
  private static volatile List<ClasspathResource> classpathResourceIndex;

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 83 out of 86 changed files in this pull request and generated no new comments.

Suppressed comments (2)

openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:690

  • createMissingIndex swallows the stack trace by logging only exception.getMessage(). This makes diagnosing index-creation failures (e.g., auth, cluster state, mapping issues) much harder during startup because the root cause and stack are lost. Log the throwable as the last argument to SLF4J instead.
    openmetadata-service/src/test/java/org/openmetadata/service/monitoring/RequestLatencyContextTest.java:682
  • This assertion compares SLA bucket boundaries using Duration.toNanos(), but Timer histogram bucket boundaries are reported in the timer base unit (seconds). This will cause the test to fail (and may also include an extra +Inf bucket depending on registry). Convert expected buckets to seconds and compare against the prefix of the actual bucket array.

…s-startup-latency

# Conflicts:
#	ingestion/tests/unit/topology/database/test_unitycatalog_error_isolation.py
#	openmetadata-ui/src/main/resources/ui/playwright/e2e/VisualRegression/__snapshots__/staticPages.spec.ts-snapshots/incident-manager.png

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 83 out of 85 changed files in this pull request and generated no new comments.

Suppressed comments (2)

openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:690

  • The catch block logs only exception.getMessage() and drops the throwable, which makes diagnosing index-creation failures much harder (no stack trace / root cause). Log the exception as the last argument instead.
    openmetadata-service/src/main/java/org/openmetadata/service/resources/CollectionRegistry.java:178
  • This warning logs only ex.getMessage() and drops the throwable, which makes diagnosing startup failures (resource constructor/init errors) much harder. Log the exception itself so the stack trace is available.

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 83 out of 85 changed files in this pull request and generated no new comments.

Suppressed comments (4)

openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:842

  • When live fingerprint verification fails, the log drops the stack trace by only logging exception.getMessage(). This makes it hard to diagnose why template verification failed (auth issues, API compatibility, parsing errors) and could lead to repeated rebuilds without actionable logs.
    openmetadata-service/src/main/java/org/openmetadata/service/resources/CollectionRegistry.java:215
  • This LOG.warn call won’t include the exception stack trace because ex is being used as a formatting argument for the {} placeholder. In SLF4J, the throwable must be passed as the last parameter without a matching placeholder to get a stack trace.
    openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:690
  • createMissingIndex swallows the exception stack trace by logging only exception.getMessage(). This makes diagnosing index/alias creation failures (mapping errors, auth failures, cluster issues) much harder in production logs.

This issue also appears on line 839 of the same file.
openmetadata-service/src/main/java/org/openmetadata/service/resources/CollectionRegistry.java:178

  • Resource registration failures only log ex.getMessage(), which drops stack traces and root cause details (e.g., constructor resolution issues, dependency failures). That makes startup failures much harder to debug.

This issue also appears on line 212 of the same file.

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 85 out of 87 changed files in this pull request and generated no new comments.

Suppressed comments (1)

openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:756

  • skipped is always 0 here because it subtracts failed (which is initialized to buildResult.failures()); for each entity mapping, you either add a template or count a build failure, so entityIndexMap.size() - templates.size() - buildFailures cancels out. This makes the logged "Skipped" count misleading, and also mixes build-time failures with update-time failures in a single failed counter.

Consider tracking build failures vs update failures separately, and compute skipped as the number of mappings that were not attempted (size - templates.size()).

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 85 out of 87 changed files in this pull request and generated no new comments.

Suppressed comments (3)

openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:690

  • This catch logs only exception.getMessage() and drops the stack trace/cause chain, which makes index-init failures hard to diagnose (especially now that initialization can run in parallel). Log the throwable so the full root cause is preserved.
    openmetadata-service/src/main/java/org/openmetadata/service/resources/CollectionRegistry.java:179
  • This log statement drops the throwable and only prints ex.getMessage(). For resource registration failures (including NPEs when createResource returns null), this can hide the actual root cause and stack trace in startup logs.
    openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:843
  • This warning logs only exception.getMessage() and discards the stack trace. Since this path is taken when fingerprint verification fails (and triggers a full template rebuild), keeping the throwable will make startup issues (permissions, network, API changes) diagnosable.

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 85 out of 87 changed files in this pull request and generated no new comments.

Suppressed comments (2)

openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:841

  • This warning logs only exception.getMessage() and omits the throwable, which makes it hard to understand why template fingerprint verification failed (e.g., auth/transport errors, parsing errors). Logging the exception preserves the stack trace while still rebuilding templates as intended.
    openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:690
  • In the catch block, the warning logs only exception.getMessage() and drops the throwable. If index creation/alias reconciliation fails (e.g., mapping errors, auth issues), the stack trace is critical for diagnosing startup problems; messages are often null or too generic.

This issue also appears on line 839 of the same file.

A record the doc build skips as a stale reference (recordStaleReferenceWarning)
was dropped from processStats.totalRecords, which only summed process
success + failed. readerStats.totalRecords stays at the planner count, so a
single skipped record left reader=124 / processor=123 and failed
ReindexStatsIT.cleanRunBalancesReaderProcessorSink in search-it-nightly.

StageStatsTracker.flush folds every stage's warnings into the one
readerWarnings column, so the process-stage share is recovered from the
reader hand-off: each row the reader emits gets exactly one process outcome,
so whatever is neither a success nor a failure warned.

Co-Authored-By: Claude Opus 5 (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 88 out of 90 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

openmetadata-service/src/test/java/org/openmetadata/service/monitoring/RequestLatencyContextTest.java:682

  • Timer.takeSnapshot().histogramCounts().bucket() values are reported in the timer's base time unit (seconds for Prometheus), but this test compares them to Duration.toNanos(). This will fail (and may also be sensitive to an extra +Inf bucket). Convert the expected buckets to seconds and ignore any infinite bucket values before comparing.

indexResourcesFromDirectory built both the pattern-matching path and the
resource name from Path.toString(), which emits the platform separator. On
Windows a directory classpath element (an exploded target/classes rather than
a shaded jar) therefore matched no '/'-anchored pattern and produced names
that ClassLoader.getResourceAsStream cannot resolve — SeedDataGate's
fingerprint and FrameworkSeedLoader/PolicySeedLoader would find nothing.

Normalize both fields once at indexing time, so directory entries look like
the jar entries they sit beside. No-op on '/' platforms.

Co-Authored-By: Claude Opus 5 (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 88 out of 90 changed files in this pull request and generated no new comments.

Suppressed comments (3)

openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:1

  • The stored fingerprint used for gating only hashes mappingContent(), but template drift checks (indexTemplatesMatch) and live template markers include additional definition inputs (at least indexPattern, and priority via GenericClient.calculateIndexTemplateFingerprint). This means changes to indexPattern (e.g., clusterAlias updates) or priority could be missed by the gate, incorrectly skipping required template updates. Compute the gate fingerprint from the same canonical definition used for live verification (e.g., per-template searchClient.indexTemplateFingerprint(indexPattern, mappingContent) or GenericClient.calculateIndexTemplateFingerprint(indexPattern, mappingContent), then hash the resulting per-template fingerprint map).
    openmetadata-service/src/main/java/org/openmetadata/service/resources/CollectionRegistry.java:1
  • For non-empty signatures, resolveConstructor can return a non-public constructor, but createResource then calls constructor.newInstance(...) without making it accessible; this will fail with IllegalAccessException for resources in different packages with package-private/protected constructors. To avoid runtime failures, constrain matches to public constructors for all supported signatures (or switch to getConstructors() / getConstructor(...) so only public constructors are considered).
    openmetadata-service/src/main/java/org/openmetadata/service/seeding/RequiredSeedRows.java:1
  • This method hard-codes the provider discriminator as the literal string \"collate\". Since provider naming is also defined elsewhere (e.g., SeedDataGate constants / SMTP template settings), consider centralizing the allowed provider values (constants or an enum) and normalizing case to prevent subtle mismatches that could select the wrong email seed set.

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 88 out of 90 changed files in this pull request and generated no new comments.

Suppressed comments (1)

openmetadata-service/src/main/java/org/openmetadata/service/OpenMetadataApplication.java:408

  • SeedDataGate.stampIfClean() is called immediately after resource registration, but before later startup steps (event filter registration, authorizer/authenticator init, servlet registration, background workers, etc.). If any of those later steps throws and aborts startup, the persisted startupChecksums can still reflect a “successful startup”, causing the next boot to skip seed/template reconciliation even though the previous startup did not complete successfully. Consider stamping only after the full run() initialization completes without error (e.g., near the end of the method).
    ApplicationHandler.initialize(catalogConfig);
    IndexResource.initialize(catalogConfig);
    startupTimer.time(
        "resource registration", () -> registerResources(catalogConfig, environment, jdbi));
    SeedDataGate.getInstance().stampIfClean();

…s-startup-latency

# Conflicts:
#	openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java

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 88 out of 90 changed files in this pull request and generated no new comments.

…s-startup-latency

# Conflicts:
#	conf/openmetadata.yaml
#	openmetadata-service/src/main/java/org/openmetadata/service/OpenMetadataApplication.java
#	openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java
#	openmetadata-spec/src/main/java/org/openmetadata/schema/utils/JsonUtils.java
#	openmetadata-spec/src/main/resources/json/schema/settings/settings.json
#	openmetadata-ui/src/main/resources/ui/src/generated/settings/settings.ts
@gitar-bot

gitar-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 13 resolved / 14 findings

Improves server startup and write-path latency by adding warm-start fingerprint gates, optimized classpath scanning, and direct JSON conversion. Consider adding a unit test for history pagination behavior.

💡 Quality: Behavior-changing history pagination lacks a unit test in this commit

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:2876-2890 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java:1706-1720

listEntityHistoryByTimestamp/getEntityHistoryByTimestampRange were restructured to fix backward (beforeCursor) paging — previously it scanned DESC and returned the wrong rows, now it scans ASC per-branch, applies keyset+LIMIT inside each UNION ALL branch, and reverses in Java. This is a correctness fix, but the only tests added in this commit are the Playwright/Python planner tests; there is no Java unit/integration test exercising forward/backward cursor windows, the extra-row (hasMore) trim, or the UNION ALL dedup assumption. Add a focused test (e.g. in an EntityRepository/history IT) covering first page, afterCursor, and beforeCursor with a version count exceeding the page limit to lock in the fixed behavior.

✅ 13 resolved
✅ Bug: CommonUtil.getResources now returns an immutable list

📄 common/src/main/java/org/openmetadata/common/utils/CommonUtil.java:63-77
getResources() now returns stream()...toList() over an immutable index (buildClasspathResourceIndex uses List.copyOf), whereas it previously returned a mutable ArrayList. Any caller that mutates the returned list (add/remove/sort) will now throw UnsupportedOperationException at runtime. The new CommonUtilTest even asserts this immutability. Please confirm no downstream caller of getResources()/getJsonDataResources() mutates the result; if any does, wrap it in a new ArrayList or fix the caller.

✅ Performance: Search-template gate never stamps fingerprint if any mapping is missing

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:582 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:595-599 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:607-621
In createOrUpdateIndexTemplates, failed is initialized to entityIndexMap.size() - templates.size(). buildIndexTemplateDefinitions() silently drops any entity whose mapping content is null or fails to read, so templates.size() can be permanently smaller than entityIndexMap.size(). That makes failed > 0 on every boot, which triggers recordSearchTemplateFailure() (resetting the stored fingerprint to null). As a result the search-template gate never records a clean fingerprint and templates are rebuilt on every startup, defeating the warm-start optimization this PR adds. Consider only counting genuine per-template failures (increment inside the catch block) rather than pre-charging failed with the count of skipped/no-mapping entities.

✅ Quality: ClasspathScanIndex keeps ScanResult open for JVM lifetime

📄 openmetadata-service/src/main/java/org/openmetadata/service/util/ClasspathScanIndex.java:32-39 📄 openmetadata-service/src/main/java/org/openmetadata/service/util/ClasspathScanIndex.java:45-57
The new ClasspathScanIndex singleton opens a ClassGraph ScanResult in its constructor and never closes it, whereas the previous CollectionRegistry/Entity code wrapped the scan in try-with-resources. The loaded classes are cached in the two maps, so the ScanResult itself no longer needs to stay open after warmup; retaining it holds ClassGraph's class-graph metadata (and any file handles) for the life of the process. Consider closing the ScanResult after populating the caches, or eagerly materializing the needed lookups and closing the scan.

✅ Edge Case: Seed-data gate skips reseeding on DB drift when files are unchanged

📄 openmetadata-service/src/main/java/org/openmetadata/service/seeding/SeedDataGate.java:96-101 📄 openmetadata-service/src/main/java/org/openmetadata/service/seeding/SeedDataGate.java:173-187 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:1408-1413
SeedDataGate.shouldSeed() decides whether to seed based solely on a fingerprint of the classpath seed resources plus server version, compared to the fingerprint persisted in the settings table. If seed rows (roles, policies, bootstrap types, etc.) are removed or corrupted out-of-band while the seed files remain unchanged, a restart will skip reseeding and leave the system missing required seed data. This is mitigated by STARTUP_FORCE_SEED_DATA / seedDataGateEnabled=false, but the failure mode is silent. Consider documenting this operational caveat prominently, or gating on a lightweight presence check in addition to the file fingerprint.

✅ Edge Case: Warm-start seed gate reseeds every boot when email config is unset

📄 openmetadata-service/src/main/java/org/openmetadata/service/seeding/SeedDataGate.java:313-324 📄 openmetadata-service/src/main/java/org/openmetadata/service/seeding/RequiredSeedRows.java:55-67
When no EMAIL_CONFIGURATION settings row exists, SeedDataGate.getEmailTemplateProvider() returns null (SeedDataGate.java:316-317), and RequiredSeedRows.selectEmailDocuments(null) then requires BOTH openmetadata and collate email documents to be present (RequiredSeedRows.java:58-60). However the actual seeder DocumentRepository.getEntitiesFromSeedData() loads only ONE provider's templates — defaulting to openmetadata (DocumentRepository.java:64-75) via SettingsCache which returns the OPENMETADATA default rather than null. As a result the collate email documents are never seeded, hasRequiredSeedRows always returns false, and the drift check reseeds on every warm boot — defeating the startup optimization this PR introduces. Make getEmailTemplateProvider default to OPENMETADATA when the config row is absent (mirroring the seeder / DefaultOperationalConfigProvider), instead of returning null.

...and 8 more resolved from earlier reviews

🤖 Prompt for agents
Code Review: Improves server startup and write-path latency by adding warm-start fingerprint gates, optimized classpath scanning, and direct JSON conversion. Consider adding a unit test for history pagination behavior.

1. 💡 Quality: Behavior-changing history pagination lacks a unit test in this commit
   Files: openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:2876-2890, openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java:1706-1720

   listEntityHistoryByTimestamp/getEntityHistoryByTimestampRange were restructured to fix backward (beforeCursor) paging — previously it scanned DESC and returned the wrong rows, now it scans ASC per-branch, applies keyset+LIMIT inside each UNION ALL branch, and reverses in Java. This is a correctness fix, but the only tests added in this commit are the Playwright/Python planner tests; there is no Java unit/integration test exercising forward/backward cursor windows, the extra-row (hasMore) trim, or the UNION ALL dedup assumption. Add a focused test (e.g. in an EntityRepository/history IT) covering first page, afterCursor, and beforeCursor with a version count exceeding the page limit to lock in the fixed behavior.

Options

Display: compact → Showing less information.

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

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
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.

Improve server startup and write-path latency

3 participants