dotCMS / dotCMS/core

OpenSearch: unique-field validation query fails with 'all shards failed' under phase 2

Open
#36,579 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Team : Scout
Dominant language
Java
Stars
970
Forks
486
Avg merge
3d 33m
Merged PRs (30d)
170

Description

Found during the phase-2 (dual-write, reads from OpenSearch) integration triage (#36501), while debugging a different test. Captured from a healthy phase-2 run (OS reachable, PHASE_2 active).

Symptom

Unique-field validation issues a search that fails against OpenSearch with search_phase_execution_exception: all shards failed. ContentFactoryIndexOperationsOS.cachedIndexSearch catches it and returns ERROR_HIT (total=0), so the failure is silent (validation may then behave as if no duplicate exists).

Captured query (OS, phase 2)

{"_source":{"includes":["inode","identifier"]},
 "query":{"query_string":{"query":
   "+structurename:testvarname<ts> +languageid:1 +( +conhost:<siteHash>testvarname<ts>.testfieldvarname<ts>_sha256:<valueHash> )"}},
 "size":10000,"sort":[{"_score":{"order":"desc"}},{"moddate":{"order":"desc"}}],
 "timeout":"15s","track_total_hits":10000000}

The <contentTypeVar>.<fieldVar>_sha256 term targets a dynamic unique-hash field. Likely cause: that field isn't mapped (or the query_string parses the dotted _sha256 term in a way OpenSearch rejects), producing a per-shard query_shard_exception → "all shards failed". The ES path handles the same query in phase 0/1.

Where

  • Query build/translation: dotCMS/src/main/java/com/dotcms/content/index/opensearch/ContentFactoryIndexOperationsOS (query_string translation) and the OS content mapping / dynamic templates (os-content-settings.json).
  • Silent swallow: ContentFactoryIndexOperationsOS.cachedIndexSearchERROR_HIT (total=0) (see also #36577).

Impact

Unique-field uniqueness checks rely on this search; if it silently returns 0 under phase 2, duplicate detection could be bypassed. Needs: (1) make the unique-hash field/query valid on OS (mapping or query translation), (2) stop swallowing a real search error as 0 results under phase 2 (#36577).

Related: #36501, #36577.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in dotCMS/src/main/java/com/dotcms/content/index/opensearch/ContentFactoryIndexOperationsOS, tracing query_string translation and cachedIndexSearch, then inspect os-content-settings.json for the dynamic unique-hash mapping. Reproduce or inspect the captured phase-2 query and verify that unique-field validation no longer produces an all-shards-failed error or treats a real search error as zero results.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.