Repository navigation
fix(search): run search-index nightly on PRs, guard flattened-extension highlight (OpenSearch), stabilize DB↔ES reconciliation IT - #29073
Conversation
…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]>
❌ 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 |
| 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(); | ||
| }); |
There was a problem hiding this comment.
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]>
|
🟡 Playwright Results — all passed (9 flaky)✅ 4289 passed · ❌ 0 failed · 🟡 9 flaky · ⏭️ 88 skipped
🟡 9 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Code Review ✅ ApprovedIntegrates search-index CI triggers for relevant PRs and resolves stability issues by patching OpenSearch highlight errors and preventing orphan record leakage in integration tests. OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |



Summary
Three related search-index "nightly" improvements, surfaced by the nightly
search-it-nightlyrun (27598436788):CI — auto-run the search-index nightly on relevant PRs.
java-playwright-nightly.ymlnow also triggers onpull_requestwhen search-indexing code changes (paths: servicesearch/**,apps/bundles/searchIndex/**, the specelasticsearch/**index mappings + loader, the search ITs/UIITs, the integration-testspom.xml, and the workflow). Usespull_request(notpull_request_target) so fork PRs never run with secrets; Slack notifications suppressed on PR runs.Fix — OpenSearch highlight 500 on flattened
extensionfields.extensionisflat_objecton OpenSearch (no analyzer), so highlightingextension/extension.*failed the whole shard (Field [extension.foundry_rid] has no associated analyzer→ 500).OpenSearchSourceBuilderFactory.buildHighlightsV2now drops those fields before building the highlight; Elasticsearch tolerates them and is unchanged. FixesExtensionHighlightSearchIT. Adds a unit guard inSearchSourceBuilderFactoryTest.Fix —
ReindexStatsITleaks a forged orphan, breakingDbToEsCountReconciliationIT. Root-caused locally:ReindexStatsIT.orphanedSchemaDoesNotFailReindexdeliberately 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 aREADER_RELATIONSHIP_WARNINGand skips it, but the test then leaks the orphan — recursive service cleanup can't reach the table through the severedservice → db → schema → tablechain. The lingering non-deleted, unindexable table makes the later cluster-wideDbToEsCountReconciliationITcount it (db=2) though it is never indexed (es=1). Fix:ReindexStatsITnow hard-deletes the orphan it forged (DAO, in afinally).DbToEsCountReconciliationITis 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
InterruptedExceptionannotations on the failing run are shutdown noise.)Verified locally (postgres + opensearch, embedded)
table db=2/es=1in the full search-it suite, then a diagnostic dump (404: databaseSchema …) traced the orphan toReindexStatsIT.DbToEsCountReconciliationITpasses in the full suite withReindexStatsITrunning before it, and in isolation.ExtensionHighlightSearchITpasses against a freshly-built service carrying the highlight guard (zerono associated analyzer500s).SearchSourceBuilderFactoryTest13/13 (incl. the new highlight-guard test).Relationship to #28674
#28674 tackles the same flattened-highlight root cause from the config-hygiene side (a
v11211migration scrubbing stored highlight fields by ahighlight: trueflag, plus a UI guard). This PR's commit (2) is the complementary runtime guard covering the query-time path #28674 doesn't — the pathExtensionHighlightSearchITexercises (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_objectextension fields before they cause a shard-level 500, and a test-isolation fix that cleans up an orphaned table inReindexStatsIT'sfinallyblock so it no longer skewsDbToEsCountReconciliationIT.java-playwright-nightly.yml): Adds apull_request(notpull_request_target) trigger with precise path filters, a concurrency group withcancel-in-progress, updated checkout-ref expressions, and suppressed Slack notifications for PR runs.OpenSearchSourceBuilderFactory):buildHighlightsV2now filters outextensionandextension.*fields viaisFlattenedExtensionField, backed by a new unit test that asserts the exact surviving highlight-field set.ReindexStatsIT): The orphaned-table fixture is wrapped intry/finally, with a DAO-leveldeletein thefinallyblock 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
Reviews (2): Last reviewed commit: "fix(search-it): stop ReindexStatsIT leak..." | Re-trigger Greptile