Upgrading to 3.3 fails

Hi, when upgrading from maas 3.1 Ubuntu 20.04 to maas 3.3 Ubuntu 22.04 I am getting an error:
$ sudo apt upgrade
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
Calculating upgrade… Done
Try Ubuntu Pro beta with a free personal subscription on up to 5 machines.
Learn more at https://ubuntu.com/pro
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up maas-region-controller (1:3.3.0~beta2-12870-g.34e582bb0-0ubuntu1~22.04.1) …
Operations to perform:
Apply all migrations: auth, contenttypes, maasserver, metadataserver, piston3, sessions, sites
Running migrations:
Applying maasserver.0268_partition_index…Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/django/db/backends/utils.py”, line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.ObjectInUse: cannot ALTER TABLE “maasserver_partition” because it has pending trigger events

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/sbin/maas-region", line 33, in <module>
    sys.exit(load_entry_point('maas==3.3.0b2', 'console_scripts', 'maas-region')())
  File "/usr/lib/python3/dist-packages/maasserver/region_script.py", line 77, in run
    run_django(is_snap, is_devenv)
  File "/usr/lib/python3/dist-packages/maasserver/region_script.py", line 66, in run_django
    management.execute_from_command_line()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3/dist-packages/maasserver/management/commands/dbupgrade.py", line 125, in handle
    call_command(
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 181, in call_command
    return command.execute(*args, **defaults)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/lib/python3/dist-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/lib/python3/dist-packages/django/db/migrations/operations/models.py", line 528, in database_forwards
    alter_together(
  File "/usr/lib/python3/dist-packages/django/db/backends/base/schema.py", line 419, in alter_unique_together
    self.execute(self._create_unique_sql(model, columns))
  File "/usr/lib/python3/dist-packages/django/db/backends/base/schema.py", line 145, in execute
    cursor.execute(sql, params)
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 79, in _execute
    with self.db.wrap_database_errors:
  File "/usr/lib/python3/dist-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.OperationalError: cannot ALTER TABLE "maasserver_partition" because it has pending trigger events

dpkg: error processing package maas-region-controller (--configure):
 installed maas-region-controller package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of maas:
 maas depends on maas-region-controller (= 1:3.3.0~beta2-12870-g.34e582bb0-0ubuntu1~22.04.1); however:
  Package maas-region-controller is not configured yet.

dpkg: error processing package maas (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were 
encountered while processing:
 maas-region-controller
 maas
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

Do you guys have an idea what could it be? Also juju status command started to not respond and show the following:
panic: cannot determine host series: could not determine series

goroutine 1 [running]:
github.com/juju/juju/vendor/github.com/juju/os/series.mustHostSeries(0x2540be400, 0x43107a0)
	github.com/juju/juju/vendor/github.com/juju/os/series/series.go:50 +0x65
github.com/juju/juju/api.init.ializers()
	github.com/juju/juju/api/certpool.go:19 +0x182

I was following this guide https://maas.io/docs/whats-new-in-maas#heading--How-to-upgrade-from-3-2-or-lower-to-MAAS-3-3

I have noticed that someone from the community also got this error previously https://bugs.launchpad.net/maas/+bug/1966506 . However their issue was related with deprecated postgresql version. As far as I see my psql version is 14, but I am not sure if maas uses this version:

$ psql -V
psql (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)

The problem was because our we were using old version of postgresql. You may check it by running following command:

sudo -u postgres psql -c “SELECT version();”

After I ran some steps here Upgrading Postgresql to version 12 issue was resolved

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.