Configuration #
Every key is optional. Set them in .kuzzlerc, under plugins.mapping-migration:
{
"plugins": {
"mapping-migration": {
"batchSize": 1000,
"graceDelay": 5000
}
}
}or from the application code, before app.start():
app.config.set("plugins.mapping-migration", { batchSize: 1000, graceDelay: 5000 });| Key | Default | Purpose |
|---|---|---|
batchSize | 1000 | Documents copied per batch (and per checkpoint) |
graceDelay | 5000 | Milliseconds between the write lock and the copy, so that writes accepted just before the lock land first |
progressInterval | 2000 | Minimum milliseconds between two progress messages during the copy |
retryDelay | 1000 | Milliseconds before sending again documents Elasticsearch rejected for the moment, doubled at each of the 5 attempts |
resumeInterval | 10000 | Milliseconds between two checks, on each node, for a job to take over |
mutexTtl | 30000 | Milliseconds the job mutex lives without being renewed; the node running the job renews it every third of it |
Every key takes an integer, at least 1 for batchSize, 3000 for mutexTtl, 100 for resumeInterval, 0 for the others. A numeric string, as an environment variable gives, is read as a number. Any other value stops Kuzzle at startup with plugin.mapping-migration.invalid_config, naming the key.
The package exports the type of this object, MappingMigrationConfig.
Prefer .kuzzlerc or the application code to environment variables. Kuzzle's environment form of these keys, kuzzle_plugins__mapping-migration__mutexTtl=10000, has a - in its name: it is not a valid shell variable name, and POSIX sh (the entrypoint of the kuzzleio/kuzzle-runner image, for instance) drops it silently when it starts Kuzzle. The plugin then runs with its defaults, without any error.
To check the values Kuzzle passed to the plugin, call server:getConfig (an administrator's right) and read plugins["mapping-migration"]:
curl -s -H "Authorization: Bearer $TOKEN" http://localhost:7512/_getConfig \
| jq '.result.plugins["mapping-migration"]'A key missing there runs with its default from the table above.
Takeover delay #
Writes stay closed until another node takes over a job whose node stopped:
- Graceful stop (
SIGTERM, a rolling upgrade): withinresumeInterval(10 s by default). - Crash: between
2/3 × mutexTtlandmutexTtl + resumeInterval, 20 to 40 s with the defaults.
To shorten it, lower both, e.g. mutexTtl: 10000 and resumeInterval: 2000: 2 s at most after a graceful stop, 7 to 12 s after a crash. The limits:
- a node unresponsive for about
2/3 × mutexTtl(Redis slow or unreachable, a long garbage collection pause) loses the job, and Kuzzle warnsLock "{mapping-migration}/job/mutex" lost: …. Another node takes it over from the last checkpoint and the first node stops at its next batch, without writing the job state: nothing is lost, but a batch is copied again. Too low amutexTtlmakes this frequent, hence its minimum of 3000 (Kuzzle's own locks use 10000); - each node tries the mutex once per
resumeInterval, a single Redis call: a short interval costs little.
Grace delay #
graceDelay is part of the write downtime of every copy. Lower it only if no write can still be in flight a few seconds after the lock (no long bulk import running): a write that reaches the old indice during the copy makes the job end aborted rather than lose it, and the migration has to be started again.