Ad Widget

Collapse

Various Postgres problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pmhausen
    Junior Member
    • Jun 2022
    • 2

    #1

    Various Postgres problems

    Hi all,

    I inherited a Zabbix 5.4.4 with Postgres 13 as the database backend. The former admin who has left the company did not setup auto vacuum or a regularly scheduled vacuum job. So regardless of any retention/expiry policy set in Zabbix, the database just grows and grows until it filled the virtual disk and Postgres crashed.

    I analysed the problem, found the first cause - full disk - and then tried to clean up the installation. Since this is a virtual environment, enlarging the volume hosting the database was easy. I then tried to vacuum the database which failed for the "zabbix" DB. I did not copy the error message, unfortunately, and I am reluctant to try it again just now, because it will break my installation. I used "vacuumdb -a -f" for that. The error messages were about some invalid content "" for a certain field. I can of course reproduce the problem during off-hours if necessary. This left the DB in some inconsistent state and Zabbix stopped working. Complains about a missing "database version" right when there should be a login dialog.

    OK. The former admin did setup regular backups that look like this:
    Code:
    root@monitor:/var/zabbix-server-backup# ll
    [...]
    -rw-r--r-- 1 root root 6470805 Jun 19 05:44 zabbix-server_2022-06-19T05:44:02+02:00_data.sql.gz
    -rw-r--r-- 1 root root 20958 Jun 19 05:44 zabbix-server_2022-06-19T05:44:02+02:00_schema.sql.gz
    -rw-r--r-- 1 root root 6472745 Jun 20 05:44 zabbix-server_2022-06-20T05:44:02+02:00_data.sql.gz
    -rw-r--r-- 1 root root 20958 Jun 20 05:44 zabbix-server_2022-06-20T05:44:02+02:00_schema.sql.gz
    Create new database, import schema, import data - no worky. Postgres complains about a ton of foreign key constraint violations. So I have a backup that I cannot restore in a single simple operation. Is this a Zabbix provided tool that creates these? Seems to run via some systemd thingy named "zabbix-server-backup.timer".

    Additionally we have daily snapshots of the underlying BTRFS, even on a second machine. So I was able to restore the complete Postgres DB in binary fashion from the snapshot and restart everything after I enlarged the volume. So Zabbix is running again, phew.

    The problem I now face is that I need to clean up this mess to ensure continuing operation. I am much more experienced with MySQL than Postgres and honestly flabbergasted there is no equivalent to mysqlcheck to repair an internal database structure or that there is a dump tool producing backups that cannot be re-imported.

    What do you suggest how I go about restoring everything to a consistent state? I already talked to the teams and we need NO historical data. All we really need is the complete configuration.

    Thanks for all comments, pointers to docs equally welcome, of course.

    Kind regards,
    Patrick
    Last edited by pmhausen; 20-06-2022, 17:43.
  • pmhausen
    Junior Member
    • Jun 2022
    • 2

    #2
    More details about the failed vacuum - I did save the error in an internal ticket

    Code:
    vacuumdb: vacuuming database "zabbix"
    WARNING: unexpected attrdef record found for attr 2 of rel items
    WARNING: unexpected attrdef record found for attr 3 of rel items
    WARNING: unexpected attrdef record found for attr 5 of rel items
    WARNING: unexpected attrdef record found for attr 6 of rel items
    WARNING: unexpected attrdef record found for attr 7 of rel items
    WARNING: unexpected attrdef record found for attr 8 of rel items
    WARNING: unexpected attrdef record found for attr 9 of rel items
    WARNING: unexpected attrdef record found for attr 10 of rel items
    WARNING: unexpected attrdef record found for attr 11 of rel items
    WARNING: unexpected attrdef record found for attr 12 of rel items
    WARNING: unexpected attrdef record found for attr 13 of rel items
    WARNING: unexpected attrdef record found for attr 14 of rel items
    WARNING: unexpected attrdef record found for attr 15 of rel items
    WARNING: unexpected attrdef record found for attr 19 of rel items
    WARNING: unexpected attrdef record found for attr 20 of rel items
    WARNING: unexpected attrdef record found for attr 21 of rel items
    WARNING: unexpected attrdef record found for attr 22 of rel items
    WARNING: unexpected attrdef record found for attr 23 of rel items
    WARNING: unexpected attrdef record found for attr 24 of rel items
    WARNING: unexpected attrdef record found for attr 25 of rel items
    WARNING: unexpected attrdef record found for attr 28 of rel items
    WARNING: unexpected attrdef record found for attr 29 of rel items
    WARNING: unexpected attrdef record found for attr 30 of rel items
    WARNING: unexpected attrdef record found for attr 31 of rel items
    WARNING: unexpected attrdef record found for attr 33 of rel items
    WARNING: unexpected attrdef record found for attr 34 of rel items
    WARNING: unexpected attrdef record found for attr 35 of rel items
    WARNING: unexpected attrdef record found for attr 37 of rel items
    WARNING: unexpected attrdef record found for attr 38 of rel items
    WARNING: unexpected attrdef record found for attr 39 of rel items
    WARNING: unexpected attrdef record found for attr 40 of rel items
    WARNING: unexpected attrdef record found for attr 42 of rel items
    WARNING: unexpected attrdef record found for attr 43 of rel items
    WARNING: unexpected attrdef record found for attr 44 of rel items
    WARNING: unexpected attrdef record found for attr 45 of rel items
    WARNING: unexpected attrdef record found for attr 46 of rel items
    WARNING: unexpected attrdef record found for attr 47 of rel items
    WARNING: unexpected attrdef record found for attr 48 of rel items
    WARNING: unexpected attrdef record found for attr 49 of rel items
    WARNING: unexpected attrdef record found for attr 50 of rel items
    WARNING: unexpected attrdef record found for attr 51 of rel items
    vacuumdb: error: processing of database "zabbix" failed: ERROR: column name "" specified more than once

    Comment

    Working...