[LockManager] Add scenarios to Lock manager readme

This commit is contained in:
Søren Louv-Jansen 2025-06-25 13:13:08 +02:00 committed by GitHub
parent 2ed4e8a341
commit bb966812b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,14 @@
A simple, distributed lock manager built on top of Elasticsearch.
Ensures that only one process at a time can hold a named lock, with automatic lease renewal and token fencing for safe release.
### Typical scenarios
**Re-indexing**
Starting multiple re-index operation on the same source simultaniously can lead to data corruption. Wrapping the re-index call in `withLock("my_reindex")` guarantees that only one consumer can start the operation.
**Bootstrapping tasks**
On Kibana startup you might need to run migrations, create/update index mappings or bootstrapping other types of assets. Without a lock, every Kibana node that boots in parallel will try to run the same migrations. A lock ensures that the startup migrations only runs exactly once, even if multiple Kibana nodes spin up concurrently.
# API Documentation
## `withLock<T>(lockId, callback, options)`