Skip to content

[bug] A plugin update can overwrite a newer install of the same plugin that finished during its download #4352

Closed

Description

@Quick104

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.

  1. 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.
  2. Run Check Plugin Updates, so the automatic update starts downloading 1.1.0.
  3. While it downloads, install 2.0.0 from Admin > Plugins.
  4. 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 (on main) from the existing snapshot loaded before the download, then stops existing.ID and writes.
  • internal/plugins/installer.go, the replacement write (replaceBinary / replaceArchive on main, writeBinaryReplacement / writeArchiveReplacement after fix(plugins): check a plugin update's package before stopping the plugin #4330): SaveArchive and installations.Update run without UpdateInstallationInput.IfVersion, which the store already supports.
  • internal/plugins/service.go, InstallCatalog and the upload paths load existing the same way, so two manual replacements can race too. The second one's removeInstallationFiles targets 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

  1. added
    bug
    on Nov 15, 2026
  2. added
    priority: P2
    triaged
    on Nov 15, 2026
  3. Rhainland commented on Nov 18, 2026

    @Rhainland
    Contributor

    Reproduced on origin/main at 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.

  4. added a commit that references this issue on Nov 18, 2026
    939cf24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: P2triaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions