Skip to content

fix(search): run search-index nightly on PRs, guard flattened-extension highlight (OpenSearch), stabilize DB↔ES reconciliation IT - #29073

Merged
pmbrull merged 4 commits into
mainfrom
search-nightly-improvements
Jun 17, 2026
Merged

pmbrull merged 4 commits into
mainfrom
search-nightly-improvements

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Three related search-index "nightly" improvements, surfaced by the nightly search-it-nightly run (27598436788):

  1. CI — auto-run the search-index nightly on relevant PRs. java-playwright-nightly.yml now also triggers on pull_request when search-indexing code changes (paths: service search/**, apps/bundles/searchIndex/**, the spec elasticsearch/** index mappings + loader, the search ITs/UIITs, the integration-tests pom.xml, and the workflow). Uses pull_request (not pull_request_target) so fork PRs never run with secrets; Slack notifications suppressed on PR runs.

  2. Fix — OpenSearch highlight 500 on flattened extension fields. extension is flat_object on OpenSearch (no analyzer), so highlighting extension / extension.* failed the whole shard (Field [extension.foundry_rid] has no associated analyzer → 500). OpenSearchSourceBuilderFactory.buildHighlightsV2 now drops those fields before building the highlight; Elasticsearch tolerates them and is unchanged. Fixes ExtensionHighlightSearchIT. Adds a unit guard in SearchSourceBuilderFactoryTest.

  3. Fix — ReindexStatsIT leaks a forged orphan, breaking DbToEsCountReconciliationIT. Root-caused locally: ReindexStatsIT.orphanedSchemaDoesNotFailReindex deliberately forges an orphaned table (deletes the parent schema row via the in-JVM DAO — a state the REST API rejects/cascades) to assert the reindex tolerates it. The reindex correctly records a READER_RELATIONSHIP_WARNING and skips it, but the test then leaks the orphan — recursive service cleanup can't reach the table through the severed service → db → schema → table chain. The lingering non-deleted, unindexable table makes the later cluster-wide DbToEsCountReconciliationIT count it (db=2) though it is never indexed (es=1). Fix: ReindexStatsIT now hard-deletes the orphan it forged (DAO, in a finally). DbToEsCountReconciliationIT is left in its original strict form — the invariant was correct and caught the leak. (Corrects an earlier polling band-aid that wrongly treated the persistent mismatch as refresh lag.)

This is not a product indexing bug — healthy tables index correctly; the only un-indexed table is synthetic, DAO-forged corruption that the reindex visibly records and skips. (The InterruptedException annotations on the failing run are shutdown noise.)

Verified locally (postgres + opensearch, embedded)

  • Reproduced table db=2/es=1 in the full search-it suite, then a diagnostic dump (404: databaseSchema …) traced the orphan to ReindexStatsIT.
  • DbToEsCountReconciliationIT passes in the full suite with ReindexStatsIT running before it, and in isolation.
  • ExtensionHighlightSearchIT passes against a freshly-built service carrying the highlight guard (zero no associated analyzer 500s).
  • SearchSourceBuilderFactoryTest 13/13 (incl. the new highlight-guard test).

Relationship to #28674

#28674 tackles the same flattened-highlight root cause from the config-hygiene side (a v11211 migration scrubbing stored highlight fields by a highlight: true flag, plus a UI guard). This PR's commit (2) is the complementary runtime guard covering the query-time path #28674 doesn't — the path ExtensionHighlightSearchIT exercises (it configures the bad field via the settings API after migrations have run, then searches). If maintainers prefer #28674 to own the highlight fix entirely, commit (2) can be dropped; the CI trigger (1) and the orphan-leak fix (3) are independent.

🤖 Generated with Claude Code

Greptile Summary

This PR bundles three related search-indexing improvements: a CI path trigger for the nightly suite on relevant PRs, a runtime guard in the OpenSearch highlight builder to drop flat_object extension fields before they cause a shard-level 500, and a test-isolation fix that cleans up an orphaned table in ReindexStatsIT's finally block so it no longer skews DbToEsCountReconciliationIT.

  • CI (java-playwright-nightly.yml): Adds a pull_request (not pull_request_target) trigger with precise path filters, a concurrency group with cancel-in-progress, updated checkout-ref expressions, and suppressed Slack notifications for PR runs.
  • OpenSearch fix (OpenSearchSourceBuilderFactory): buildHighlightsV2 now filters out extension and extension.* fields via isFlattenedExtensionField, backed by a new unit test that asserts the exact surviving highlight-field set.
  • IT stabilization (ReindexStatsIT): The orphaned-table fixture is wrapped in try/finally, with a DAO-level delete in the finally block to prevent the orphan from leaking into other tests sharing the cluster.

Confidence Score: 5/5

Safe to merge; all three changes are well-scoped, independently motivated, and backed by targeted tests.

The OpenSearch highlight guard is narrow and correctly scoped to OpenSearch only, with a new unit test and an integration test exercising the exact failure path. The ReindexStatsIT cleanup is a root-cause fix for a known inter-test contamination. The CI trigger uses pull_request (not pull_request_target), concurrency cancellation is correctly keyed by PR number, and Slack suppression is guarded on event_name. No production data paths are altered beyond the existing highlight-field filtering logic.

The finally block in ReindexStatsIT.orphanedSchemaDoesNotFailReindex could mask a test-assertion failure if the cleanup delete call itself throws; worth a glance but low risk in practice.

Important Files Changed

Filename Overview
.github/workflows/java-playwright-nightly.yml Adds pull_request path-filtered trigger with concurrency cancellation, updates checkout ref expressions, and suppresses Slack notifications on PR runs.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/search/ReindexStatsIT.java Wraps orphan-reindex assertions in try/finally to clean up the orphaned table via DAO; minor exception-masking risk if the finally-block delete itself throws.
openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java Adds isFlattenedExtensionField guard in buildHighlightsV2 to drop extension/* fields, preventing OpenSearch 500 on flat_object fields with no analyzer.
openmetadata-service/src/test/java/org/openmetadata/service/search/SearchSourceBuilderFactoryTest.java Adds unit test verifying OpenSearch highlight builder drops extension and extension.* fields while retaining other analyzable fields.

Reviews (2): Last reviewed commit: "fix(search-it): stop ReindexStatsIT leak..." | Re-trigger Greptile

mohityadav766 and others added 2 commits June 16, 2026 13:27
…ht; stabilize DB↔ES reconciliation IT

OpenSearch maps the `extension` custom-properties object as flat_object, which has no
analyzer, so highlighting `extension`/`extension.*` failed the whole shard with a 500 —
caught by ExtensionHighlightSearchIT (OpenSearch-only; Elasticsearch tolerates it). Skip
flat_object extension fields when building the OpenSearch highlight request; the ES path is
unchanged. Adds a fast unit guard in SearchSourceBuilderFactoryTest.

DbToEsCountReconciliationIT read DB/ES counts immediately after the reindex reported
success, racing the async refresh (table db=2 es=1). Poll the reconciliation until counts
settle so refresh lag / a brief external-cluster churn window no longer flakes it; a
genuine, persistent drift still fails once the window elapses.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Jun 16, 2026
@mohityadav766 mohityadav766 self-assigned this Jun 16, 2026
Comment on lines +86 to +97
Awaitility.await("DB <-> ES entity counts reconcile post-reindex")
.atMost(Duration.ofSeconds(60))
.pollInterval(Duration.ofSeconds(3))
.untilAsserted(
() -> {
final List<String> mismatches = collectCountMismatches();
assertThat(mismatches)
.as(
"entity-type counts must reconcile DB ↔ ES post-reindex:%n%s",
String.join("\n", mismatches))
.isEmpty();
});

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.

P2 untilAsserted silently swallows only AssertionError

Awaitility.untilAsserted retries only when the lambda throws an AssertionError. Any unchecked exception thrown by collectCountMismatches() — for example a transient SearchException or IOException from an ES/DB call — propagates immediately and fails the test without retrying. In a flaky-network or slow-start scenario this reintroduces the instability the Awaitility wrapper was meant to fix. Using .ignoreExceptionsInstanceOf(Exception.class) (or a targeted subtype) on the Awaitility chain would make the polling truly resilient.

…he reconciliation polling band-aid

Root-caused the DbToEsCountReconciliationIT `table db=2/es=1` failure: not a flake, not a
product bug. ReindexStatsIT.orphanedSchemaDoesNotFailReindex deliberately forges an orphaned
table (deletes the parent schema row via the in-JVM DAO — a state the REST API rejects or
cascades) to assert the reindex tolerates it. The reindex correctly records a
READER_RELATIONSHIP_WARNING and skips it, but the test then leaks the orphan: namespace
cleanup deletes the service recursively and can't reach the table through the severed
service->db->schema->table chain. The non-deleted, unindexable table lingers on the shared
embedded cluster, so the later cluster-wide reconciliation counts it (db) while it is never
indexed (es).

Fix: ReindexStatsIT now hard-deletes the orphaned table it forged (DAO, in a finally),
mirroring how it created the orphan. DbToEsCountReconciliationIT is reverted to its original
strict global form — the invariant was correct and caught the leak; the earlier polling
"stabilization" was the wrong fix (the mismatch is persistent, not refresh lag).

Verified locally (postgres + opensearch, embedded): full search-it suite passes
DbToEsCountReconciliationIT with ReindexStatsIT running before it; ExtensionHighlightSearchIT
passes with the highlight guard.

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

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (9 flaky)

✅ 4289 passed · ❌ 0 failed · 🟡 9 flaky · ⏭️ 88 skipped

Shard Passed Failed Flaky Skipped
✅ Shard 1 302 0 0 4
🟡 Shard 2 807 0 2 9
🟡 Shard 3 809 0 2 8
🟡 Shard 4 848 0 1 12
🟡 Shard 5 732 0 1 47
🟡 Shard 6 791 0 3 8
🟡 9 flaky test(s) (passed on retry)
  • Features/DataQuality/ColumnLevelTests.spec.ts › Column Values To Be In Set (shard 2, 1 retry)
  • Features/DataQuality/TestCaseImportExportE2eFlow.spec.ts › Admin: Complete export-import-validate flow (shard 2, 1 retry)
  • Features/KnowledgeCenterList.spec.ts › Knowledge Center List - Verify Recently Viewed widget (shard 3, 1 retry)
  • Features/Workflows/WorkflowOssRestrictions.spec.ts › add-event-filter-button is enabled in OSS (shard 3, 1 retry)
  • Pages/DataContractsSemanticRules.spec.ts › Validate Description Rule Is_Set (shard 4, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 5, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage service filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/ServiceEntity.spec.ts › Tier Add, Update and Remove (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

@pmbrull
pmbrull merged commit 7738765 into main Jun 17, 2026
62 of 68 checks passed
@pmbrull
pmbrull deleted the search-nightly-improvements branch June 17, 2026 09:58
@gitar-bot

gitar-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Integrates search-index CI triggers for relevant PRs and resolves stability issues by patching OpenSearch highlight errors and preventing orphan record leakage in integration tests.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

This branch was previously deployed

1 inactive deployment
test — 59be30b1 Deployed Jun 16, 2026 by mohityadav766 via playwright-ci-postgresql (6, 6) #51310
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