Skip to content

ReindexThread: single hung filesystem stat on network storage silently halts all content indexing #36498

Description

@wezell

Problem Statement

A single hung filesystem operation permanently freezes all content indexing for a dotCMS instance.

ReindexThread drains the dist_reindex_journal on a single thread (dot-ReindexThreadSubmitter-0). While mapping a contentlet for Elasticsearch, that thread performs blocking file I/O (File.exists() on binary fields). If the underlying storage is network-backed (NFS, EFS, S3-FUSE) and a single stat(2) never returns, the thread blocks forever in native code — RUNNABLE but frozen, no exception, no timeout, no log output. The reindex queue silently stops draining.

Production incident (2026-07-09): a tenant's assets live on an S3-backed FUSE mount (geesefs). A geesefs bug (yandex-cloud/geesefs#197) left single FUSE LOOKUP requests unanswered forever. One hung File.exists() froze all indexing for the instance for hours — three separate times in one day — with no error and no alert.

The FS bug is being pursued upstream, but dotCMS should not be architected so that one unanswered stat halts indexing forever.

Observed wedge points (thread dumps, Java 25, dotcms/dotcms:latest)

All three funnel through the single-threaded reindex loop (ReindexThread.runReindexLoop → appendToBulkProcessor):

  1. Title building during ES mapping
java.io.File.exists(File.java:790)
com.dotmarketing.portlets.contentlet.model.Contentlet.getBinary(Contentlet.java:1221)
com.dotmarketing.portlets.contentlet.model.Contentlet.buildName(Contentlet.java:446)
com.dotmarketing.portlets.contentlet.model.Contentlet.getTitle(Contentlet.java:347)
com.dotcms.content.elasticsearch.business.ESMappingAPIImpl.toMap(ESMappingAPIImpl.java:507)
com.dotcms.content.elasticsearch.business.ContentletIndexAPIImpl.addBulkRequestToProcessor(...)
com.dotmarketing.common.reindex.ReindexThread.runReindexLoop(ReindexThread.java:229)
  1. JSON→contentlet transform while loading version inodes
java.io.File.exists(File.java:790)
com.dotcms.content.business.json.ContentletJsonAPIImpl.getBinary(ContentletJsonAPIImpl.java:412)
com.dotcms.content.business.json.ContentletJsonAPIImpl.getContentletMapFromImmutable(...)
com.dotmarketing.portlets.contentlet.transform.ContentletTransformer.transform(...)
com.dotcms.content.elasticsearch.business.ESContentFactoryImpl.findInDb(...)
com.dotcms.content.elasticsearch.business.ContentletIndexAPIImpl.loadVersionInodes(...)
  1. Metadata generation during ES mapping
java.io.File.exists(File.java:790)
com.dotmarketing.portlets.contentlet.model.Contentlet.getBinary(Contentlet.java:1221)
com.dotcms.storage.FileMetadataAPIImpl.generateBasicMetadata(FileMetadataAPIImpl.java:146)
com.dotcms.storage.FileMetadataAPIImpl.generateContentletMetadata(...)
com.dotcms.content.elasticsearch.business.ESMappingAPIImpl.writeMetadata(ESMappingAPIImpl.java:720)
com.dotcms.content.elasticsearch.business.ESMappingAPIImpl.toMap(ESMappingAPIImpl.java:617)

Steps to Reproduce

  1. Store contentlet binary assets on a network-backed filesystem (e.g., an S3 FUSE mount such as geesefs).
  2. Cause a single stat/LOOKUP on one asset file to hang indefinitely (the geesefs bug above does this; any wedged NFS/FUSE mount reproduces it).
  3. Trigger a reindex of content that includes the affected contentlet.
  4. Observe: dot-ReindexThreadSubmitter-0 blocks forever in File.exists(); the dist_reindex_journal queue stops draining; no error is logged; all content indexing for the instance halts until restart.

Acceptance Criteria

  • A hung or slow storage operation while mapping one contentlet does not stop the reindex pipeline: that journal entry fails per existing dist_reindex_journal retry/failure semantics (markAsFailed), and the loop continues with subsequent entries.
  • Per-contentlet mapping in the reindex path runs under a config-driven bounded timeout (e.g. REINDEX_CONTENTLET_MAPPING_TIMEOUT_SECONDS, env-overridable via DOT_ prefix), with a generous default (60–120s); 0 disables the timeout and preserves current behavior exactly.
  • On timeout, a loud ERROR is logged including the contentlet identifier, inode(s), and mapping phase.
  • A thread wedged in uninterruptible native I/O is abandoned (not interrupted-and-reused); the executor is bounded so wedged threads cannot pile up unbounded, and pool exhaustion logs a clear alarm (indicates storage itself is down).
  • Existing journal failure semantics are reused, not reinvented.
  • Unit tests: a mapping that blocks past the timeout fails that entry while the next entry still processes; timeout=0 preserves current behavior.
  • Change is surgical to the reindex path — Contentlet.getBinary itself is not refactored.

dotCMS Version

Production, dotcms/dotcms:latest (Java 25). Code path present on main.

Severity

High - Major functionality broken

Links

Activity

  1. added theissue type on Jul 9, 2026
  2. github-actions commented on Jul 9, 2026

    @github-actions
    Contributor
  3. fabrizzio-dotCMS commented on Jul 14, 2026

    @fabrizzio-dotCMS
    Member

    QA Note — verified ✅ PASS

    Verified the merged fix (PR #36499) end-to-end against a real running instance, with a side-by-side pre-fix vs fix comparison. All acceptance criteria confirmed.

    How the disk hang was simulated (no code changes)

    The bug needs a filesystem operation that never returns. I reproduced that with an OS-level primitive — a writerless FIFO (named pipe) — instead of a mock/lock in the code, so the exact merged artifact is what gets tested:

    1. Create a File Asset with a real binary, then on disk replace its binary with a FIFO and delete its metadata sidecar:
      rm  <assets>/<i0>/<i1>/<inode>/fileAsset/<file>
      mkfifo <assets>/<i0>/<i1>/<inode>/fileAsset/<file>   # writerless FIFO
      rm  <assets>/<i0>/<i1>/<inode>/fileasset-metadata.json  # force metadata regeneration
      
    2. Kernel rule: open() on a writerless FIFO blocks forever in uninterruptible native I/O — the same RUNNABLE-but-frozen state as the incident's geesefs/NFS mount. Confirmed independently: timeout 3 cat <fifo> → exit 124.
    3. The sidecar is deleted because, for modern-json content, mapping only touches the binary when metadata must be regenerated (this is exactly the storage hardening in the PR working as intended). With the sidecar present the guarded region does no filesystem I/O at all.

    Two honest deltas vs. the production incident, neither affecting the validity of the fix: the incident hung a stat (File.exists) whereas the FIFO hangs the open/read — but after the fix the only remaining FS touch in the guarded region is that metadata open, and both funnel through the same single-threaded ReindexThread. And I did not use a real network mount (a FIFO is a faithful, uninterruptible substitute). Crucially, an uninterruptible FIFO also validates the "abandoned, not interrupted-and-reused" requirement: the fix's future.cancel(true) sends an interrupt that the FIFO open ignores — just like a wedged native stat.

    Headline contrast (identical FIFO + content on both builds)

    Observable 🔴 Pre-fix (dotcms:latest, no guard) 🟢 Fix (built from main)
    dot-ReindexThreadSubmitter-0 RUNNABLE frozen in native open0 forever TIMED_WAITING (idle, healthy)
    dist_reindex_journal stuck, never drains drains; only the wedged entry remains (priority 200→201, failed)
    Healthy sibling content never indexed indexed + searchable
    Timeout ERROR none (silent) logged at 10s with the identifier
    Wedged worker froze the ONLY reindex thread isolated on 1 abandoned carrier; loop continued

    Pre-fix wedge (the bug):

    "dot-ReindexThreadSubmitter-0" RUNNABLE
      at sun.nio.fs.UnixNativeDispatcher.open0(Native Method)
      ... TikaUtils.getForcedMetaDataMap
      ... FileMetadataAPIImpl.generateContentletMetadata
      ... ESMappingAPIImpl.writeMetadata → toMap
      ... ContentletIndexAPIImpl.appendToBulkProcessor
      ... ReindexThread.runReindexLoop(ReindexThread.java:245)
    

    Fix guard (the timeout):

    ERROR ReindexMappingRunner - Timed out after 10s mapping reindex entry with identifier
    '<id>' ... Marking the journal entry as failed and continuing with the queue.
    

    Results

    Case Result
    Hung binary read fails only that entry; queue keeps draining ✅ PASS (AC1)
    Config-driven timeout; 0 disables → legacy inline behavior restored (reindex thread wedges inline, no worker threads) ✅ PASS (AC2)
    Loud ERROR with identifier on timeout ✅ PASS (AC3)
    Wedged native-I/O thread abandoned, not reused; executor bounded (MAX_THREADS=2 → exactly 2 carriers), pool-exhaustion alarm (... The underlying storage may be down.) ✅ PASS (AC4)
    Existing journal semantics reused: failed entry priority+1, retried and succeeds once storage recovers ✅ PASS (AC5)
    File Asset & DotAsset title/name consistent after the buildName stat-removal change ✅ PASS
    Metadata still generated on reindex (width/height/contentType) ✅ PASS
    Genuinely-missing binary skipped gracefully (no timeout, no failure) ✅ PASS

    General reindex smoke (regression)

    Beyond the targeted hang cases, ran a manual smoke of general reindex functionality on the fix build with default config (timeout 120s, guard active but not triggered):

    • Triggered a full site reindex (all content types, 24 contentlets) via POST /api/v1/esindex/reindex.
    • inFullReindexation went true → false (clean index switchover), lastIndexationProgress reached 24/24, errorCount = 0.
    • dist_reindex_journal drained to 0; no timeout / pool-exhaustion / reindex ERROR log lines.
    • Content searchable across types after switchover (e.g. FileAsset 16 hits, DotAsset 4 hits).

    → The guard adds no regression to normal reindex when storage is healthy.

    One case not directly reproducible via FIFO (method limitation, not a fix defect): "slow-but-not-hung" — Tika re-opens the binary (MIME detect + parse) and a one-shot FIFO writer only satisfies the first open. The slow path shares the same code as the fast path (a plain future.get(timeout)) and is covered by the retry case (readable binary maps within the window) plus the PR's ReindexMappingRunnerTest.

    Environment: local Docker, single-node PostgreSQL + Elasticsearch. Pre-fix dotcms/dotcms:latest; fix built from main (ec2.../current tip). Test content: File Asset / DotAsset contentlets with image binaries.

  4. removed their assignment
    on Jul 14, 2026
  5. added a commit that references this issue on Jul 16, 2026
    32fd108
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions