apache / apache/shenyu

[BUG] Elasticsearch existsIndex returns true on error, skipping index creation and dropping batches

Open Beginner friendly
#6,547 1 comment 0 reactions 0 assignees View on GitHub
plugin: logging-elasticSearch priority: high type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

## Description
In the `catch` of `existsIndex` the method returns `true`. `consume0` then treats the index as existing and skips `createIndex`/alias setup. On any transient error checking index existence (network blip, auth 401, ES temporarily unreachable) while the daily index does not yet exist, the day's index is never created; the subsequent `client.bulk(...)` then fails (if `auto_create_index` is disabled, common in secured clusters), so the **entire batch is dropped** on every failed check until the check happens to succeed.

## Location
```
shenyu-plugin-logging-elasticsearch/.../client/ElasticSearchLogCollectClient.java:134-142 (used at consume0 107-110)
```

## Impact
All log batches throw on insert; `AbstractLogCollector` catches and drops them, so no logs are persisted until the check happens to succeed.

## Suggested fix
Return `false` on error (fail-safe: attempt creation) or rethrow so the batch is retried; do not claim the index exists when the check itself failed.

## Related existing issue(s)
None

_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in shenyu-plugin-logging-elasticsearch/.../client/ElasticSearchLogCollectClient.java at existsIndex lines 134-142, then inspect its use in consume0 at lines 107-110. Ensure an existence-check error cannot make consume0 skip index and alias creation; done means transient check failures no longer cause the day's batch to be dropped because the index was falsely reported as present.

Written by the indexing model from the issue text.

Assessment

Tech stack
elasticsearch, java
Domain
backend, observability-sre, search
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.