Skip to content

Conversation

@flash1293
Copy link
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

Fixes elastic#230499

The lock manager runs `setupLockManagerIndex` via lodash `once`, so it's
not happening on every call. However, if the first call to
`setupLockManagerIndex` errors out (e.g. because Elasticsearch isn't
ready yet), then every subsequent call will return the cached rejected
promise and fail as well, rendering all lock managers in that node
instance broken (since `once` keeps its state on module scope)

This leads to issues like this (timeout exception thrown from streams,
but the call stack originates from the slo plugin setup routine since
it's the cached rejected promise):
```
[2025-08-01T18:36:25.080+00:00][ERROR][plugins.streams] TimeoutError: Request timed out
    at KibanaTransport._request (/usr/share/kibana/node_modules/@elastic/transport/lib/Transport.js:564:50)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at runNextTicks (node:internal/process/task_queues:69:3)
    at listOnTimeout (node:internal/timers:549:9)
    at processTimers (node:internal/timers:523:7)
    at /usr/share/kibana/node_modules/@elastic/transport/lib/Transport.js:631:32
    at KibanaTransport.request (/usr/share/kibana/node_modules/@elastic/transport/lib/Transport.js:627:20)
    at KibanaTransport.request (/usr/share/kibana/node_modules/@kbn/core-elasticsearch-client-server-internal/src/create_transport.js:60:16)
    at Cluster.putComponentTemplate (/usr/share/kibana/node_modules/@elastic/elasticsearch/lib/api/api/cluster.js:600:16)
    at ensureTemplatesAndIndexCreated (/usr/share/kibana/node_modules/@kbn/lock-manager/src/setup_lock_manager_index.js:56:3)
    at setupLockManagerIndex (/usr/share/kibana/node_modules/@kbn/lock-manager/src/setup_lock_manager_index.js:110:3)
    at LockManager.acquire (/usr/share/kibana/node_modules/@kbn/lock-manager/src/lock_manager_client.js:53:5)
    at withLock (/usr/share/kibana/node_modules/@kbn/lock-manager/src/lock_manager_client.js:242:20)
    at /usr/share/kibana/node_modules/@kbn/slo-plugin/server/plugin.js:176:7
```

This PR fixes the problem by not using once but instead keeping the
state manually only if the promise succeeds, passing errors through.

(cherry picked from commit b4f8488)
@flash1293 flash1293 added the backport This PR is a backport of another PR label Aug 6, 2025
@flash1293 flash1293 added the backport This PR is a backport of another PR label Aug 6, 2025
@flash1293 flash1293 enabled auto-merge (squash) August 6, 2025 06:18
@flash1293 flash1293 merged commit 30e9aeb into elastic:8.19 Aug 6, 2025
13 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants