Problem
When executing the command univention-pkgdb-scan
you get the following Traceback:
root@ucsdc0:/home/univention-support#
univention-pkgdb-scan
Reading package lists... Done
Building dependency tree
Reading state information... Done
Traceback (most recent call last):
File “/usr/sbin/univention-pkgdb-scan”, line 41, in <module>
univention.pkgdb.main()
File “/usr/lib/python3/dist-packages/univention/pkgdb.py”, line 627, in main
return action_scan(connection, cursor, config_registry)
File “/usr/lib/python3/dist-packages/univention/pkgdb.py”, line 534, in action_scan
scan_and_store_packages(cursor, sysname, fake_null, architecture)
File “/usr/lib/python3/dist-packages/univention/pkgdb.py”, line 460, in scan_and_store_packages
cursor.execute(delete_packages, {'sysname': sysname})
File “/usr/lib/python3/dist-packages/pgdb.py”, line 1030, in execute
return self.executemany(operation, [parameters])
File “/usr/lib/python3/dist-packages/pgdb.py”, line 1054, in executemany
rows = self._src.execute(sql)
pg.InternalError: ERROR: invalid page in block 34816 of relation base/16385/16395
It seems that the database has an error, now it is possible to delete and recreate it.
Hint
In this scenario it is important to mention that the package for univention-pkdg, i.e. the pkgdb server itself, is not located on the primary node / DC master (ucsdc0).
This plays an important role later in the solution, because the host name and domain name must match the pkgdb server so that the pkgdb can also be accessed.
Environment
root@ucs-pkgdb:/home/univention-support# univention-app info
UCS: 5.0-8 errataXXX
Installed: pkgdb=11.0
root@ucs-pkgdb:/home/univention-support# dpkg -l | grep pkgdb
ii python3-univention-pkgdb 13.0.5-2 all UCS - Software monitoring database Python 3 library
ii univention-management-console-module-pkgdb 13.0.5-2 all UMC module for software monitoring database
ii univention-pkgdb 13.0.5-2 all UCS - Software monitoring database
ii univention-pkgdb-tools 13.0.5-2 all UCS - Software monitoring database tools
root@ucsdc0:/home/univention-support# dpkg -l | grep pkgdb
ii python3-univention-pkgdb 13.0.5-2 all UCS - Software monitoring database Python 3 library
ii univention-pkgdb-tools 13.0.5-2 all UCS - Software monitoring database tools
Solution
- You have to connect with the user postgres to the DB.
root@ucs-pkgdb:~# su - postgres -c psql
psql (11.22 (Debian 11.22-0+deb10u2))
Geben Sie »help« für Hilfe ein.
postgres=# \l
List of Databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
---------------+---------------+-----------+--------------+-------------+-----------------------
importhttpapi | importhttpapi | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
pkgdb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(5 rows)
- Drop database and role for pkgdb and pkgdbg.
postgres-# DROP DATABASE pkgdb;
postgres-# DROP ROLE pkgdbg;
postgres=# \l
List of Databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
---------------+---------------+-----------+--------------+-------------+-----------------------
importhttpapi | importhttpapi | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
- Create the new pkgdb database.
root@ucs-pkgdb:/home/univention-support#
su - postgres -c 'psql -v ON_ERROR_STOP= -qf /usr/share/univention-pkgdb/sql/create-database.sql'
You have to also check:
See also: PostgreSQL Cheat Sheet