Repository navigation
Description
What happened
Nothing serializes two replacements of the same plugin installation, and the replacement write doesn't check that the row still holds the version it was prepared against. An automatic update that is downloading while an admin installs a newer version from the catalog can finish second: it stops the newer plugin, writes its older package and stored archive, and sets the row back to the older version. The admin's install reported success, and the plugin now runs the older release.
Steps to reproduce
Not reproduced live; found in source review.
- Install a catalog plugin at 1.0.0 with Update automatically, and list 1.1.0 and 2.0.0 in its catalog, with 1.1.0 served slowly.
- Run Check Plugin Updates, so the automatic update starts downloading 1.1.0.
- While it downloads, install 2.0.0 from Admin > Plugins.
- The manual install finishes and the plugin runs 2.0.0. When the 1.1.0 download completes, the automatic update stops the plugin and writes 1.1.0 over the row and stored archive.
Expected behavior
A replacement applies only to the installation state it was prepared against. A replacement whose target changed in the meantime is refused, and the newer install stays.
Silo version / commit
Source review of main at c11b0a968; the same code shape remains after #4330.
Deployment
Not applicable (source review).
Clients affected
- Other/not client-specific
Relevant logs
No logs available.
Technical notes
internal/plugins/auto_update.go,autoUpdatePlugin: prepares (after fix(plugins): check a plugin update's package before stopping the plugin #4330) or downloads (onmain) from theexistingsnapshot loaded before the download, then stopsexisting.IDand writes.internal/plugins/installer.go, the replacement write (replaceBinary/replaceArchiveonmain,writeBinaryReplacement/writeArchiveReplacementafter fix(plugins): check a plugin update's package before stopping the plugin #4330):SaveArchiveandinstallations.Updaterun withoutUpdateInstallationInput.IfVersion, which the store already supports.internal/plugins/service.go,InstallCatalogand the upload paths loadexistingthe same way, so two manual replacements can race too. The second one'sremoveInstallationFilestargets the old path the first already replaced.- A fix would guard the stored-archive write and the row update with the prepared version (
IfVersion), treat a skipped guarded update as a refusal, and decide whether replacements of one installation should take a lock shared across API servers (for example a Postgres advisory lock keyed on the installation ID). - This follows fix(plugins): check a plugin update's package before stopping the plugin #4330, which rewrites these functions.
AI harness
Claude Code (in T3 Code)
AI tool(s)
GitHub CLI, git, shell
AI model(s)
claude-opus-5-5
AI involvement
Raised by an automated reviewer on #4330 and confirmed by Claude Code (claude-opus-5-5) reading main. No human reproduced it.
Independent or adversarial review
The PR author confirmed it predates the PR in the review thread on #4330.
Source: found in review of #4330
Activity
Rhainland commentedon Nov 18, 2026
Reproduced on
origin/mainat e8de111: with 1.0.0 installed and a slowly served 2.0.0 in a local test catalog, I ran Check Plugin Updates and then installed 3.0.0 from the catalog while 2.0.0 was still downloading. The install reported 3.0.0, but when the 2.0.0 download finished the installation and its stored archive went back to 2.0.0, and the 3.0.0 files were left on disk.Cause: a replacement wrote its package over whatever the installation held when it finished. Neither the row update nor the stored-archive write checked that the installation was still the one the replacement had been prepared against.
Fix in #4509: an install, update or upload only replaces the installation it started from. If another install overtook it, it is refused before the plugin is stopped and writes nothing, so the newer release stays. A manual one answers 409; an automatic update is skipped. Checked on a local build of the fix with the same steps: the installation, its stored archive and its files stay at 3.0.0, and the server logs the skipped update. In the reverse order (a slow manual 2.0.0 install while the automatic update installs 3.0.0), the manual install answers 409 and 3.0.0 stays. Tests cover the guarded store write on Postgres, the catalog install and applied-update paths, the automatic update, and the 409 mapping.
AI disclosure: reproduced and fixed by Claude Code (claude-opus-5-5) at the maintainer's direction.
fix(plugins): refuse a plugin update that another install overtook du…