canonical / postgresql-operator

A Charmed Operator for running PostgreSQL on machines
https://charmhub.io/postgresql
Apache License 2.0
8 stars 19 forks source link

Don't get new tuning options when upgrading from revision 323 to 331 #250

Closed mthaddon closed 1 year ago

mthaddon commented 1 year ago

Steps to reproduce

juju deploy postgresql --channel=14/edge --revision=323 pg-upgraded
juju deploy postgresql --channel=14/edge --revision=331 pg-not-upgraded
# Wait for units to deploy

# We wouldn't expect this unit to have shared_buffers yet in this file
juju ssh pg-upgraded/0 sudo grep shared_buff /var/snap/charmed-postgresql/common/var/lib/postgresql/postgresql.conf
# It doesn't

# We would expect this unit to have shared_buffers in this file
juju ssh pg-not-upgraded/0 sudo grep shared_buff /var/snap/charmed-postgresql/common/var/lib/postgresql/postgresql.conf
$ shared_buffers = '12550MB'

juju refresh pg-upgraded --revision=331 --channel=14/edge

# Wait for upgrade to finish

machine-0: 15:42:11 INFO juju.downloader downloading from ch:amd64/jammy/postgresql-331
machine-0: 15:42:11 INFO juju.downloader download complete ("ch:amd64/jammy/postgresql-331")
machine-0: 15:42:11 INFO juju.downloader download verified ("ch:amd64/jammy/postgresql-331")
unit-pg-upgraded-0: 15:42:17 INFO juju.worker.uniter found queued "upgrade-charm" hook
unit-pg-upgraded-0: 15:42:17 INFO unit.pg-upgraded/0.juju-log Running legacy hooks/upgrade-charm.
unit-pg-upgraded-0: 15:42:18 ERROR unit.pg-upgraded/0.juju-log Cluster upgrade failed, ensure pre-upgrade checks are ran first.
unit-pg-upgraded-0: 15:42:18 INFO juju.worker.uniter.operation ran "upgrade-charm" hook (via hook dispatching script: dispatch)
unit-pg-upgraded-0: 15:42:18 INFO juju.worker.uniter found queued "config-changed" hook
unit-pg-not-upgraded-0: 15:42:19 WARNING unit.pg-not-upgraded/0.juju-log No relation: certificates
unit-pg-upgraded-0: 15:42:19 INFO juju.worker.uniter.operation ran "config-changed" hook (via hook dispatching script: dispatch)
unit-pg-not-upgraded-0: 15:41:18 WARNING unit.pg-not-upgraded/0.upgrade-relation-changed error: snap "charmed-postgresql" has no "exporter" configuration option
unit-pg-not-upgraded-0: 15:41:18 WARNING unit.pg-not-upgraded/0.juju-log upgrade:5: Early exit update_config: Trying to reset metrics service with no configuration set
unit-pg-not-upgraded-0: 15:41:19 INFO juju.worker.uniter.operation ran "upgrade-relation-changed" hook (via hook dispatching script: dispatch)
unit-pg-not-upgraded-0: 15:41:20 INFO unit.pg-not-upgraded/0.juju-log database-peers:3: Starting cluster topology observer process
unit-pg-not-upgraded-0: 15:41:20 INFO unit.pg-not-upgraded/0.juju-log database-peers:3: Started cluster topology observer process with PID 18184
unit-pg-not-upgraded-0: 15:41:21 INFO juju.worker.uniter.operation ran "database-peers-relation-changed" hook (via hook dispatching script: dispatch)
unit-pg-upgraded-0: 15:42:11 INFO juju.worker.uniter.charm downloading ch:amd64/jammy/postgresql-331 from API server
unit-pg-not-upgraded-0: 15:42:19 INFO juju.worker.uniter.operation ran "update-status" hook (via hook dispatching script: dispatch)
^C

# We would now expect this unit to have shared_buffers in this file
juju ssh pg-upgraded/0 sudo grep shared_buff /var/snap/charmed-postgresql/common/var/lib/postgresql/postgresql.conf
# It doesn't

Expected behavior

Upgraded charm should have new tuning options

Actual behavior

Versions

Operating system: 22.04

Juju CLI: 3.1.6

Juju agent: 3.1.6

Charm revision:

LXD: 5.18

Log output

As above

Additional context

github-actions[bot] commented 1 year ago

https://warthogs.atlassian.net/browse/DPE-2747

mthaddon commented 1 year ago

Here's the output of /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml in case that's relevant https://pastebin.ubuntu.com/p/ycc8fWrN7C/

marceloneppel commented 1 year ago

Thanks for the report and all the logs, Tom.

The latest revision from 14/edge channel has the fix for this issue.

You can try with the following commands (note that you need to run the pre-upgrade-check action before refreshing the charm):

juju deploy postgresql --channel=14/edge --revision=323 pg-upgraded
juju deploy postgresql --channel=14/edge --revision=336 pg-not-upgraded

juju ssh pg-upgraded/0 sudo grep shared_buff /var/snap/charmed-postgresql/common/var/lib/postgresql/postgresql.conf

juju ssh pg-not-upgraded/0 sudo grep shared_buff /var/snap/charmed-postgresql/common/var/lib/postgresql/postgresql.conf

juju run pg-upgraded/leader pre-upgrade-check
juju refresh pg-upgraded --revision=336 --channel=14/edge

juju ssh pg-upgraded/0 sudo grep shared_buff /var/snap/charmed-postgresql/common/var/lib/postgresql/postgresql.conf