Skip to content

Create extensions in name order and retry the ones that need another - #3216

Open
khushi-git-7 wants to merge 1 commit into
zalando:masterfrom
khushi-git-7:fix/2198-extension-order
Open

khushi-git-7 wants to merge 1 commit into
zalando:masterfrom
khushi-git-7:fix/2198-extension-order

Conversation

@khushi-git-7

Copy link
Copy Markdown

Fixes #2198

syncExtensions created the new extensions in Go map order, which changes from run to run. An extension that needs another one of the list (postgis_topology needs postgis, hstore_plperl needs plperl) then failed with required extension ... is not installed, and since #2262 it only got created on a later sync.

Now createExtensionsInOrder:

  • creates them in name order, so a sync behaves the same every time;
  • tries the failed ones again in the same sync, as long as a pass creates at least one more. An extension that cannot be created at all (for example one that is not available) stops the loop and is reported as before, once.

The SQL, the alter path and the error collection from #2262 stay as they are.

Tests

  • TestCreateExtensionsInOrder uses a create function that fails until the extensions it needs exist. hstore_plperl comes before plperl in name order, so one pass is not enough. It also checks that an extension that is not available is reported once and the others are still created.
  • On my fork: unit tests and the e2e tests pass (unit, e2e). With the retry switched off (one pass in name order), the new test fails with required extension "plperl" is not installed (run). gofmt -l is clean, go vet ./pkg/cluster/ passes, and the new test passed 20 runs with -race.
  • Not tried against a real database with postgis.

syncExtensions created new extensions in Go map order, which is random. An
extension that needs another one of the list (postgis_topology needs
postgis) then failed and waited for the next sync. Create them in name
order, and try the failed ones again in the same sync while a pass creates
at least one more. An extension that cannot be created still stops the
loop and is reported as before.

Fixes zalando#2198

Signed-off-by: Khushi Jain <jainkhushibts@gmail.com>
@FxKu FxKu added the bugfix label Nov 10, 2026
@FxKu FxKu added this to the 2.1.0 milestone Nov 10, 2026
@FxKu FxKu moved this to Waiting for review in Postgres Operator Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Waiting for review

Development

Successfully merging this pull request may close these issues.

PostgreSQL extensions are installed in a random order

2 participants