Skip to content

Backport fix for bulk helper semaphore hang when server responses are slower than flushInterval #1061

@Dadibom

Description

@Dadibom

Summary

The fix from elastic/elasticsearch-js#2027 addresses a hang in the bulk helper's semaphore logic when server responses arrive more slowly than the configured flushInterval. This can cause the bulk helper to deadlock and stop processing new requests under some timing conditions, especially in high-latency or intermittently slow environments.

Problem

Currently, opensearch-js appears to have the same semaphore implementation as in the pre-fix version of elasticsearch-js, where only a single resolveSemaphore reference is managed. This can result in unresolved promises and a hang when multiple requests are queued but not released due to slow responses. The semaphore logic needs to be updated to match the upstream fix.

Steps to Reproduce

  1. Use the bulk helper with a slow server (slower than the configured flushInterval).
  2. Observe that the bulk helper may hang and stop processing.

Proposed Solution

References

Labels

🐛 bug, Roadmap:Stability/Availability/Resiliency

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions