[SOLVED] bug with wapt server 2.2

Questions about WAPT Server / Requests and help related to the WAPT server
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

April 20, 2022 - 3:34 PM

That definitely helps!

Can you provide the database version? It's available on the WAPT server's web interface

Code: Select all

Statut de la base : OK (2.2.5.1)
User avatar
guigeek
Messages: 147
Registration: Nov 21, 2017 - 9:21 p.m.

April 20, 2022 - 3:46 PM

WAPT Deploy version: 2.2.1.11899
DB status: OK (2.0.8.0)
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

April 20, 2022 - 5:51 PM

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());"
User avatar
guigeek
Messages: 147
Registration: Nov 21, 2017 - 9:21 p.m.

April 21, 2022 - 9:00 AM

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.
User avatar
guigeek
Messages: 147
Registration: Nov 21, 2017 - 9:21 p.m.

April 27, 2022 - 8:50 AM

Any idea what the problem might be?
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

April 27, 2022 - 11:09

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
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
User avatar
guigeek
Messages: 147
Registration: Nov 21, 2017 - 9:21 p.m.

April 27, 2022 - 11:18

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.
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

April 27, 2022 - 12:01

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."
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Locked