Skip to content

[Detail Bug] Data Insights: Elasticsearch mapping-conflict rollover recovery never runs (HTTP 400 is silently ignored) #39141

In review

Description

@detail-app

Detail Bug Report

https://app.detail.dev/org_3377c26d-da48-4ccd-b83a-22c542f4fe83/bugs/bug_534b7d3a-c026-463d-83e3-416f9d736757

Introduced in #33479 by @anuj-kumary on Sep 18, 2026

Summary

  • Context: The Data Insights app keeps a per-entity-type Elasticsearch/OpenSearch data stream in sync with the latest index template on every run; updateDataAssetsDataStream in DataInsightsSearchInterface implements a documented recovery path that rolls the stream over when the engine rejects an in-place mapping change with HTTP 400.
  • Bug: ElasticSearchDataInsightsClient.putWriteIndexMapping ignores the HTTP status of the PUT /<stream>/_mapping?write_index_only=true request, and the pinned Rest5Client 9.2.9 only throws on status ≥ 500 — so the 400 mapping-conflict never surfaces as an IOException and the rollover recovery is dead code on Elasticsearch.
  • Actual vs. expected: Expected (per the Javadoc and the working OpenSearch implementation): a 400 is caught via isMappingConflict, rolloverDataStream is called, and the mapping is re-applied to a fresh write index. Actual on ES: the 400 is silently swallowed as a normal Response, the stale write-index mapping persists, and recovery never runs.
  • Impact: On Elasticsearch deployments upgrading from pre-1.13, the documented compatibility fix never executes — incompatible/obsolete field types (e.g. fields that changed from simple to nested/object) persist in the write index, new sub-fields (e.g. completeness facts) are silently not applied, and the DI app proceeds to run against a stream whose mapping was never updated; ES and OpenSearch deployments diverge.

Code with Bug

openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/search/elasticsearch/ElasticSearchDataInsightsClient.java:

@Override
public void putWriteIndexMapping(String name, String mappings) throws IOException {
    Request request = new Request("PUT", "/" + name + "/_mapping");
    request.addParameter("write_index_only", "true");
    request.setEntity(new StringEntity(mappings, ContentType.APPLICATION_JSON));
    client.performRequest(request);   // <-- BUG 🔴 returned Response's status is never checked; on 400 this silently succeeds
}

openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/search/DataInsightsSearchInterface.java:

try {
    putWriteIndexMapping(name, mappings);
} catch (IOException e) {
    if (!isMappingConflict(e)) {
        throw e;
    }
    rolloverDataStream(name);
    putWriteIndexMapping(name, mappings);   // <-- BUG 🔴 relies on IOException from 400, but ES client doesn't throw on 4xx
}

Explanation

  • The Elasticsearch DI client uses Rest5Client.performRequest, which returns a Response for all HTTP statuses < 500 (including 400), and only throws an IOException for status ≥ 500.
  • Because putWriteIndexMapping does not check response.getStatusCode() and never throws on ≥ 300, a 400 mapping conflict is treated as success.
  • updateDataAssetsDataStream depends on catching an IOException to detect mapping conflicts and trigger rollover; since no exception is raised on 400, rollover is never executed on Elasticsearch.

Codebase Inconsistency

The OpenSearch DI client explicitly checks status and throws on ≥ 300, making the rollover recovery work there:

openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/insights/search/opensearch/OpenSearchDataInsightsClient.java:

try (var response = client.generic().execute(request)) {
    int status = response.getStatus();
    if (status >= 300) {
        throw new IOException(
            "Data Insights request PUT /" + name + "/_mapping failed with " + status);
    }
}

Recommended Fix

In ElasticSearchDataInsightsClient, check the returned Response status and throw on ≥ 300 (mirroring the OpenSearch implementation), at least for putWriteIndexMapping (and similarly for other ES DI methods where 4xx are currently silent):

Response response = client.performRequest(request);
int status = response.getStatusCode();
if (status >= 300) {
    throw new IOException(
        "Data Insights request PUT /" + name + "/_mapping failed with " + status);
}

History

This bug was introduced in commit 664a4f6 (PR #33479, "fix(data-insights): rollover DI data stream after template update for AUT compatibility"). That commit added putWriteIndexMapping and the 400-driven rollover recovery, but putWriteIndexMapping never checked the HTTP status, so with Rest5Client’s non-throwing 4xx behavior the rollover recovery has been dead code on Elasticsearch since it was written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions