Page 2 of 2
Re: Bug with Wapt server 2.2
Published: April 20, 2022 - 3:34 PM
by sfonteneau
That definitely helps!
Can you provide the database version? It's available on the WAPT server's web interface
Re: Bug with Wapt server 2.2
Published: April 20, 2022 - 3:46 PM
by guigeek
WAPT Deploy version: 2.2.1.11899
DB status: OK (2.0.8.0)
Re: Bug with Wapt server 2.2
Published: April 20, 2022 - 5:51 PM
by sfonteneau
Okay, the base has apparently upgraded incorrectly:
If we run this on the server, it should be better: (take a snapshot of the server beforehand if possible)
Code: Select all
cd /opt/wapt && sudo -u wapt /opt/wapt/bin/python3 -c "from waptserver.model import *; from waptserver.config import *; logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s'); setloglevel(logger, 'info'); load_db_config(load_config()); print('Version actuelle: %s' % get_db_version()); wapt_db.connect(); set_db_version('2.0.0'); wapt_db.close(); print(upgrade_db_structure()); print('Version upgradee: %s' % get_db_version());"
Re: Bug with Wapt server 2.2
Published: April 21, 2022 - 9:00 AM
by guigeek
I have this error here:
2022-04-21 08:59:34,590 INFO Migrating from 2.0.5.0 to 2.0.8
2022-04-21 08:59:34,600 INFO Migrating from 2.0.8.0 to 2.1.0
2022-04-21 08:59:34,600 INFO Fix column type for created_by and updated_by on all tables
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.UniqueViolation: could not create unique index "wsusupdates_pkey"
DETAIL: Key (update_id)=(13fe64fa-334d-4d6a-8033-6f9a8fbe1307_200) is duplicated.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
File "/opt/wapt/waptserver/model.py", line 2854, in upgrade_db_structure
migrate(*opes)
File "/opt/wapt/lib/python3.8/site-packages/playhouse/migrate.py", line 886, in migrate
operation.run()
File "/opt/wapt/lib/python3.8/site-packages/playhouse/migrate.py", line 164, in run
self._handle_result(method(*self.args, **kwargs))
File "/opt/wapt/lib/python3.8/site-packages/playhouse/migrate.py", line 153, in _handle_result
self.execute(result)
File "/opt/wapt/lib/python3.8/site-packages/playhouse/migrate.py", line 149, in execute
self.migrator.database.execute(node)
File "/opt/wapt/lib/python3.8/site-packages/playhouse/postgres_ext.py", line 490, in execute
cursor = self.execute_sql(sql, params, commit=commit)
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.IntegrityError: could not create unique index "wsusupdates_pkey"
DETAIL: Key (update_id)=(13fe64fa-334d-4d6a-8033-6f9a8fbe1307_200) is duplicated.
Re: Bug with Wapt server 2.2
Published: April 27, 2022 - 8:50 AM
by guigeek
Any idea what the problem might be?
Re: Bug with Wapt server 2.2
Published: April 27, 2022 - 11:09 AM
by dcardon
Hello guigeek,
Could you please submit the following request?
Code: Select all
DELETE FROM wsusupdates a USING wsusupdates b WHERE a.created_on < b.created_on AND a.update_id = b.update_id;
Then restart the database upgrade as Simon indicated earlier?
Sincerely,
Denis
Re: Bug with Wapt server 2.2
Published: April 27, 2022 - 11:18 AM
by guigeek
Still the same...
2022-04-27 11:17:19,287 INFO Fix column type for created_by and updated_by on all tables
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.UniqueViolation: could not create unique index "wsusupdates_pkey"
DETAIL: Key (update_id)=(bb49cc19-8847-4986-aa93-5e905421e55a_103) is duplicated.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
File "/opt/wapt/waptserver/model.py", line 2854, in upgrade_db_structure
migrate(*opes)
File "/opt/wapt/lib/python3.8/site-packages/playhouse/migrate.py", line 886, in migrate
operation.run()
File "/opt/wapt/lib/python3.8/site-packages/playhouse/migrate.py", line 164, in run
self._handle_result(method(*self.args, **kwargs))
File "/opt/wapt/lib/python3.8/site-packages/playhouse/migrate.py", line 153, in _handle_result
self.execute(result)
File "/opt/wapt/lib/python3.8/site-packages/playhouse/migrate.py", line 149, in execute
self.migrator.database.execute(node)
File "/opt/wapt/lib/python3.8/site-packages/playhouse/postgres_ext.py", line 490, in execute
cursor = self.execute_sql(sql, params, commit=commit)
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.IntegrityError: could not create unique index "wsusupdates_pkey"
DETAIL: Key (update_id)=(bb49cc19-8847-4986-aa93-5e905421e55a_103) is duplicated.
Re: Bug with Wapt server 2.2
Published: April 27, 2022 - 12:01 PM
by dcardon
So after investigation with guigeek, it seems we've stumbled upon a postgres bug [1]. To fix it, we need to drop the index to see the duplicate, clean it up, and then put the index/fkey back in.
Code: Select all
ALTER TABLE wsusupdates DROP constraint wsusupdates_pkey cascade;
DELETE FROM wsusupdates a USING wsusupdates b WHERE a.ctid < b.ctid AND a.update_id = b.update_id;
CREATE UNIQUE INDEX wsusupdates_pkey on wsusupdates(update_id);
ALTER TABLE hostwsus ADD CONSTRAINT hostwsus_update_id_fkey FOREIGN KEY (update_id) REFERENCES wsusupdates (update_id);
Thanks to guigeek for the debugging session (and I'm still quite perplexed by this postgres bug...)
Denis
[1] There have been fixes for index corruptions recently
https://www.postgresql.org/docs/release/9.6.24/ "Also, several bugs have been found that may have resulted in corrupted indexes, as explained in the next several changelog entries. If any of those cases apply to you, it's recommended to reindex possibly-affected indexes after updating."