Page 2 sur 2

Re: bug with wapt server 2.2

Publié : 20 avr. 2022 - 15:34
par sfonteneau
Effectivement ça aide !

Pouvez-vous donner la version de la bdd ? dispo sur l'interface web du serveur wapt

Code : Tout sélectionner

Statut de la base : OK (2.2.5.1)

Re: bug with wapt server 2.2

Publié : 20 avr. 2022 - 15:46
par guigeek
WAPT Deploy version: 2.2.1.11899
DB status: OK (2.0.8.0)

Re: bug with wapt server 2.2

Publié : 20 avr. 2022 - 17:51
par sfonteneau
Ok la base s'est mal upgrade visiblement :

Si sur le serveur on exécute ça devrait être mieux : (faire un snapshoot du server avant si possible)

Code : Tout sélectionner

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

Publié : 21 avr. 2022 - 09:00
par guigeek
J'ai cette erreur là :

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 "<string>", line 1, in <module>
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

Publié : 27 avr. 2022 - 08:50
par guigeek
une idée du soucis ?

Re: bug with wapt server 2.2

Publié : 27 avr. 2022 - 11:09
par dcardon
Bonjour guigeek,

est ce que vous pourriez passer la requête suivante

Code : Tout sélectionner

DELETE FROM  wsusupdates a  USING wsusupdates b  WHERE a.created_on < b.created_on AND a.update_id = b.update_id; 
puis relancer l'upgrade de db comme indiqué par Simon précédemment?

Cordialement,

Denis

Re: bug with wapt server 2.2

Publié : 27 avr. 2022 - 11:18
par guigeek
Toujours pareil ...

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 "<string>", line 1, in <module>
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

Publié : 27 avr. 2022 - 12:01
par dcardon
Donc après investigation avec guigeek, il semble que l'on soit tombé sur un bug postgres [1]. Pour corriger, il faut droper l'index pour voir le doublon, le nettoyer et remettre les index/fkey après.

Code : Tout sélectionner

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);
merci à guigeek pour la scéance de débug (et je reste assez perplexe par rapport à ce bug postgres...)

Denis

[1] il y a eu des correctifs sur des corruptions d'index récemment 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."