Repository navigation
Conversation
…NG-1881] A release that declares a new index builds it in the scheduler's startup tasks, so `docker compose up -d` returns while the API serves against a database that is still building. On a large instances collection that has been about an hour, with nothing telling the operator beforehand. Between `docker compose pull` and `docker compose up -d` the new images are on disk and the old containers are still serving, so `docker compose run` reaches the version being upgraded to without any extra machinery: the tag already in .env is the new one. That window is where the plan is worth reading, and where the build can be done instead. `--gate` needs currents-dev/currents#4558 in a released image. The sync-indexes half works today. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016uVeGDCC9GMmYpp8gZQSYt
|
| Topic | Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Pre-build indexes | Explain how to run sync-indexes before upgrading to avoid startup downtime, and link index-build diagnosis from the startup-task troubleshooting guidance.Modified files (1)
Latest Contributors(2)
| |||||||||
| Check index costs | Document a pre-upgrade check that estimates index build duration using the new scheduler image, explains exit codes and rate assumptions, and directs operators to continue or investigate accordingly.Modified files (1)
Latest Contributors(2)
|
|
Local evidence on Setup
The check, as documented, while the old containers kept running: That confirms the three things the description reasoned about:
Building first
Two notes
🤖 Generated with Claude Code |
Owner: @twk3
Linear: ENG-1881
The compose half of ENG-1881. The chart's version is currents-dev/helm-charts#72; the CLI both rely on is currents-dev/currents#4558.
What and why
A release that declares a new index builds it the first time the new scheduler starts, in its startup tasks.
docker compose up -dreturns straight away, so the services look up while the API answers against a database that is still building. On a largeinstancescollection that has been about an hour, and nothing tells the operator beforehand.Between
docker compose pullanddocker compose up -dthe new images are on disk and the old containers are still serving. That window is where the question can be asked, and where the build can be done instead:Exit 0 means carry on, exit 2 means the estimated build is over ten minutes and the output names the collections and indexes, anything else means the check itself failed. The escape hatch is the same command with
sync-indexes, which builds the indexes while the old containers keep serving.Compose gets this almost for free. The hard part in the chart was reaching the next image before the upgrade — Helm needs
helm template --show-onlypiped intokubectl apply. Heredocker compose runusesDC_CURRENTS_IMAGE_TAGfrom.env, which the operator has already pointed at the new version by that point in every upgrade path in this guide. No new service, no compose change, no new variable.This is weaker than the chart's version, deliberately
The chart runs this as a
pre-upgradehook, so a long build stops the upgrade. Compose has no equivalent — the operator drives each step, so this only tells them. Making it enforcing would mean wrapping the upgrade in a script and changing how people upgrade, which is a much larger change than the problem warrants.I also kept it inline rather than adding
on-prem/scripts/check-indexes.sh. The upgrade guide is inlinedocker composecommands throughout;check-env.shexists because diffing env files is genuinely scripted work, and twodocker compose runlines are not. Happy to add the script if you'd rather it matched thescripts/pattern.What the recipe depends on
Three things about the scheduler image, checked against
packages/scheduler/Dockerfileandpackages/mongo/package.jsonin the currents repo, and since confirmed by @twk3 running it against a real 2M-documentinstances:ENTRYPOINT ["/usr/bin/tini", "--"]with the pm2 runtime asCMDmeansdocker compose run scheduler <cmd>replaces the command only, and tini execs it. No--entrypointneeded.@currents/mongois a scheduler dependency, the image copies the whole/appwithpackages/*/distretained, andmigrate:runin that package isnode ./dist/scripts/migrate.js— so/app/packages/mongo/dist/scripts/migrate.jsis right. The chart uses the same path against the same image.Correction: an earlier version of this description said the scheduler service has no
depends_on. That is wrong, and @twk3 caught it — I readtemplates/compose.currents.yml, where it is absent, butgenerate-compose.shadds it, so all three generated files havemongodb(service_healthy) andredis(service_started), bothrequired: false. Leaving--no-depsoff is still right, but for a different reason than I gave: both dependencies are already running at this point in an upgrade, so there is nothing for compose to start.Release dependency
--gateneeds currents-dev/currents#4558 in a released on-prem image. Thesync-indexeshalf of the section works against the images shipping today — that is the part that actually saves the downtime, so this is not blocked on a release in the way the chart PR is. Draft anyway so the three land in a sensible order.I also linked the new section from the "Database migration issues" troubleshooting entry: a long silent gap before
Startup tasks completeis usually an index build rather than a stuck service, and that entry did not say so.Checklist
(fix|feat|chore): title [CSR-xxx]Docs-only — no compose templates, no
.env.examplevariables, no scripts changed, so nothing indocs/configuration.mdoron-prem/README.mdneeded updating alongside it.🤖 Generated with Claude Code
https://claude.ai/code/session_016uVeGDCC9GMmYpp8gZQSYt