Page 1 of 1

[RESOLVED] Migration issue from 2.2.3 to 2.5

Published: February 7, 2024 - 11:09 AM
by essaghir
Good morning,

Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
Postgres 11.2

The migration failed, with the logs below:

Code: Select all

2024-02-07 10:52:53,126 INFO Migrating from 2.4.0.0 to 2.4.2.0
Traceback (most recent call last):
  File "/opt/wapt/lib/python3.8/site-packages/peewee.py", line 3144, in execute_sql
    cursor.execute(sql, params or ())
psycopg2.errors.UndefinedFunction: function string_to_array(character varying[], unknown) does not exist
LINE 1: ...kages ALTER COLUMN target_os TYPE varchar[] USING string_to_...
                                                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/wapt/waptserver/model.py", line 2677, in upgrade_db_structure
    wapt_db.execute_sql("ALTER TABLE packages ALTER COLUMN target_os TYPE varchar[] USING string_to_array(target_os,',');")
  File "/opt/wapt/lib/python3.8/site-packages/peewee.py", line 3151, in execute_sql
    self.commit()
  File "/opt/wapt/lib/python3.8/site-packages/peewee.py", line 2917, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/opt/wapt/lib/python3.8/site-packages/peewee.py", line 190, in reraise
    raise value.with_traceback(tb)
  File "/opt/wapt/lib/python3.8/site-packages/peewee.py", line 3144, in execute_sql
    cursor.execute(sql, params or ())
peewee.ProgrammingError: function string_to_array(character varying[], unknown) does not exist
LINE 1: ...kages ALTER COLUMN target_os TYPE varchar[] USING string_to_...
                                                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
Can you please help me debug the problem?

Thank you in advance for your answers.

Re: Migration problem from 2.2.3 to 2.5

Published: February 7, 2024 - 2:59 PM
by dcardon
Hello Mohamed,

Can you verify that it is indeed version 11 of PostgreSQL that is currently running on your server?
When upgrading a Debian system, the old version of Postgres is not automatically upgraded.

Code: Select all

sudo -u postgres psql template1
    SHOW server_version;

The command can be corrected with a CAST, but this shouldn't be necessary on a Postgres version >=10...

Sincerely,

Denis

Re: Migration problem from 2.2.3 to 2.5

Published: February 7, 2024 - 3:57 PM
by essaghir
Hello Denis,

Below is the result of the command:

Code: Select all

could not change directory to "/root": Permission denied
psql (11.22 (Debian 11.22-0+deb10u1))
Type "help" for help.

template1=# SHOW server_version;
         server_version
--------------------------------
 11.22 (Debian 11.22-0+deb10u1)
It appears to be version 11.

I am available if you require any further information.

Sincerely,
Mohamed

Re: Migration problem from 2.2.3 to 2.5

Published: February 7, 2024 - 5:44 PM
by dcardon
Hi Mohamed,

we managed to reproduce the problem internally. The column is already in varchar[] when the string_array function is called... It's quite strange. The problem only occurs when upgrading from version 2.2.3 to 2.5, not from 2.3 to 2.5. We'll keep you posted.

Best regards,

Denis

Re: Migration problem from 2.2.3 to 2.5

Published: February 8, 2024 - 12:11 PM
by dcardon
Hello Mohamed,

While waiting for a nightly build, you can comment out the following lines in the /opt/wapt/waptserver/model.py file (lines 2673 to 2680). This issue affects users upgrading from WAPT version 2.2.3 or earlier. It does not affect users upgrading from version 2.3 or 2.4

Code: Select all

#    next_version = '2.4.2.0'
#    if get_db_version() < next_version:
#        with wapt_db.atomic():
#            logger.info("Migrating from %s to %s" % (get_db_version(), next_version))
#            wapt_db.execute_sql("ALTER TABLE packages ALTER COLUMN target_os TYPE varchar[] USING string_to_array(target_os,',');")
#            wapt_db.execute_sql("ALTER TABLE packages ALTER COLUMN licence TYPE varchar[] USING string_to_array(licence,',');")
#            wapt_db.execute_sql("ALTER TABLE packages ALTER COLUMN locale TYPE varchar[] USING string_to_array(locale,',');")
#            wapt_db.execute_sql("ALTER TABLE packages ALTER COLUMN architecture TYPE varchar[] USING string_to_array(architecture,',');")
then restart the wapt server

Code: Select all

systemctl restart waptserver
Sincerely,

Denis

Re: Migration problem from 2.2.3 to 2.5

Published: February 9, 2024 - 11:03 AM
by essaghir
Hello Denis,
Thank you for your help. With the modification, the console launches in version 2.5.3.15292.

However, when I run "Build and send waptupgrade", I get an error: "-0 is not a valid version string".

Do you have any idea why?

Sincerely,

Re: Migration problem from 2.2.3 to 2.5

Published: February 9, 2024 - 12:02 PM
by dcardon
Hello Mohamed,

thank you for your feedback. The fix for upgrading from version 2.2.3 will be available in the next release, 2.5.4.

For other questions, please start a new thread (see forum rules: one topic per thread).

I'm marking this thread as RESOLVED.

Regards,

Denis