Skip to content

[BUG] Refactor DocStatusStats #18438

@msfroh

Description

@msfroh

Describe the bug

While reviewing #18405, I ended up going down a rabbit hole of looking at existing indexing stats, where I stumbled across DocStatusStats, which violates so many rules of our stats:

  1. Stats should have a clear separation between mutable accumulators (generally an implementation of the Metric interface) and immutable snapshots. For indexing stats, the mutable counters are in InternalIndexingStats and the immutable snapshot is supposed to be IndexingStats. DocStatusStats is a mutable set of counters arbitrarily crammed into IndexingStats. (Oh, also DocStatusStats uses AtomicLongs, when properly-implemented Metric instances use LongAdder, which would also be more appropriate here if not for all the other things wrong with it.)
  2. DocStatusStats has a toXContent method that's reading from mutable state. The values returned are not guaranteed to be true for any particular instant, since they could be changing within the toXContent call.
  3. Everything else in IndexingStats is tracking shard-level metrics. Then there's this weird DocStatusStats crammed in that gets computed on the coordinator node. Which only "works" because it's abusing OldShardStats, which is meant to hold statistics for shards that were previously held on this node, but closed.

The PR that introduced DocStatusStats should never have been merged. Since it was, we should go back and clean up this mess.

Related component

Indexing

To Reproduce

  1. Read OpenSearch code
  2. See this abomination
  3. Claw out your eyes

Expected behavior

Consistent architecture for stats APIs.

Additional Details

Plugins
Please list all plugins currently enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    IndexingIndexing, Bulk Indexing and anything related to indexingbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions