Closed tgurr closed 1 month ago
Looks like the function has been removed in GVM 20.8.0 via https://github.com/greenbone/gvmd/commit/87523bf9991d50f079de49bd138658285912faf2 but has not been removed from the database on the upgrade path to GVM 20.8.0 resulting in this issue.
Am I safe to just manually delete the three functions from my database?
I went on an tried it, ran into the next similiar error
[...]
pg_restore: erstelle FUNCTION »public.valid_db_resource_type("text")«
pg_restore: in Phase PROCESSING TOC:
pg_restore: in Inhaltsverzeichniseintrag 552; 1255 16480 FUNCTION valid_db_resource_type("text") dba
pg_restore: Fehler: could not execute query: FEHLER: konnte Funktion »sql_valid_db_resource_type« nicht in Datei »/usr/x86_64-pc-linux-gnu/lib/libgvm-pg-server.so« finden
Die Anweisung war: CREATE FUNCTION "public"."valid_db_resource_type"("text") RETURNS boolean
LANGUAGE "c"
AS '/usr/x86_64-pc-linux-gnu/lib/libgvm-pg-server', 'sql_valid_db_resource_type';
which has been removed with https://github.com/greenbone/gvmd/commit/659b29313c445c82af358c09a2342848b5c41d8d
You should really improve the upgrade path and take such things that have been removed during development into consideration when running gvmd --migrate on GVM version upgrades.
I don't think this is the issue. I have noticed something similar while upgrading vom PostgreSQL 12 to 13 and it was caused by having the postgresql-12 development files still installed. After removing it (cmake had picked out the postgresql-12 development files instead of the postgresql-13 ones) had to fix cmake to correctly build libgvm-pg-server against PostgreSQL-13:
https://community.greenbone.net/t/hint-postgresql-13-issues-when-building-gvmd/7167
To sum up i think you're basically using an outdated libgvm-pg-server.so
I don't think this is the issue
Well I don't have any problems with building gvmd with postgres 13, but with running pg_upgrade. We already pass -DPostgreSQL_TYPE_INCLUDE_DIR=
in our build process and don't rely on cmake for this so we already build with the correct headers. After removing the 4 functions mentioned above the pg_upgrade went through smooth without any additional steps.
Could be a different issue then the one i had faced. But note that the problem on my side was also seen while running pg_upgrade, and this only happened during the upgrade of PostgreSQL 12 to 13 with a wrong / not updated libgvm-pg-server.
Ah sorry got what you mean, since you relied on cmake it didn't actually pick up postgres 13 but still kept building against 12 instead. But not the problem in this case.
Any chances that you're building from the 20.08.0 tag? I guess it might be possible that this was already fixed in the (not released yet 20.08.1) with https://github.com/greenbone/gvmd/pull/1251
At least functions like "valid_db_resource_type" and "next_time" are mentioned there.
@cfi-gb indeed! Thank you very very much for that hint! If I only knew before or if there would be a patch release from time to time for such serious issues. I'll add that patch to our downstream packages asap, but this is the problem, we usually don't have time to dig through the commits of each projects so patch releases we could just bump to would be very welcome.
Still there seems to be something fishy as I was already on 20.08.0 and didn't try to dump/restore an old gvmd-9.0 dump. To my understanding gvmd --migrate
should take care of those when updating to a new GVM version to have a clean database. The commit just adds dummy functions and seems to delay the actual problem. Please correct me if I'm wrong and my gvmd --migrate
run on updating to 20.08.0 back then was buggy and should have removed the functions.
Unfortunately i'm not familiar with that stuff but maybe @timopollmeier or @mattmundell can say something about that.
Also cc @bjoernricks for the patch releases as i don't have any insights into the release process of GVM.
Just for the records, the issue i had faced / described in https://github.com/greenbone/gvmd/issues/1339#issuecomment-718718098 was indeed something different. Just had upgraded a second installation giving the following below which is caused by an outdated libgvm-pg-server / the mentioned cmake issue not finding PostgreSQL 13:
ERROR: could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR: function public.hosts_contains(text, text) does not exist
ERROR: could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR: function public.max_hosts(text, text) does not exist
ERROR: could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR: function public.next_time_ical(text, text) does not exist
ERROR: could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR: function public.next_time_ical(text, text, integer) does not exist
ERROR: could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR: function public.regexp(text, text) does not exist
ERROR: could not load library "/opt/gvm/lib/libgvm-pg-server.so": /opt/gvm/lib/libgvm-pg-server.so: undefined symbol: elog_finish
ERROR: function public.severity_matches_ov(double precision, double precision) does not exist
ERROR: function public.regexp(text, text) does not exist
ERROR: operator does not exist: text public.?~# text
ERROR: function public.hosts_contains(text, text) does not exist
LINE 41: ...IS NULL) OR ("overrides"."hosts" = ''::"text") OR "public"."...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: relation "public.result_overrides" does not exist
ERROR: relation "public.result_overrides" does not exist
LINE 10: FROM "public"."result_overrides"
^
ERROR: relation "public.result_new_severities" does not exist
Closing as this is related to an old version.
Expected behavior
See the upgrade succeed.
Actual behavior
pg_upgrade_dump_16401.log
Steps to reproduce
/usr/x86_64-pc-linux-gnu/libexec/postgresql-13/pg_upgrade -b /usr/x86_64-pc-linux-gnu/libexec/postgresql-12 -B /usr/x86_64-pc-linux-gnu/libexec/postgresql-13 -d /var/lib/postgresql/12/data -D /var/lib/postgresql/13/data
GVM versions
gsa: 20.08.0
gvm: 20.08.0 - Manager DB revision 233
openvas-scanner: 20.8.0
gvm-libs: 20.8.0
Environment
Operating system: Linux
Installation method / source: source-based distribution