Upgrade from PHP7.4 to PHP8.1

Hi Community,

I tried an upgrade from PHP 7.4 to PHP8.1 on my Test-LibreNMS-Machine.
So far so good. I only get some error entries in the /logs/librenms.log
after I ran ./daily.sh

Here to Log entries:


[2022-07-28T23:32:46.934030+02:00] production.ERROR: SQLSTATE[HY093]: Invalid parameter number (SQL: DELETE
FROM alert_log
WHERE id IN(
SELECT id FROM(
SELECT id
FROM alert_log a1
WHERE
time_logged < DATE_SUB(NOW(),INTERVAL 31 DAY)
AND (device_id, rule_id, time_logged) NOT IN (
SELECT device_id, rule_id, max(time_logged)
FROM alert_log a2 WHERE a1.device_id = a2.device_id AND a1.rule_id = a2.rule_id
AND a2.time_logged < DATE_SUB(NOW(),INTERVAL 31 DAY)
)
) as c
)
) (SQL: DELETE
FROM alert_log
WHERE id IN(
SELECT id FROM(
SELECT id
FROM alert_log a1
WHERE
time_logged < DATE_SUB(NOW(),INTERVAL 31 DAY)
AND (device_id, rule_id, time_logged) NOT IN (
SELECT device_id, rule_id, max(time_logged)
FROM alert_log a2 WHERE a1.device_id = a2.device_id AND a1.rule_id = a2.rule_id
AND a2.time_logged < DATE_SUB(NOW(),INTERVAL 31 DAY)
)
) as c
)
)#0 /opt/librenms/includes/functions.php(1431): dbQuery()
#1 /opt/librenms/daily.php(291): lock_and_purge_query()
#2 {main}
[2022-07-29T07:07:43.769073+02:00] production.ERROR: SQLSTATE[HY093]: Invalid parameter number (SQL: DELETE
FROM alert_log
WHERE id IN(
SELECT id FROM(
SELECT id
FROM alert_log a1
WHERE
time_logged < DATE_SUB(NOW(),INTERVAL 31 DAY)
AND (device_id, rule_id, time_logged) NOT IN (
SELECT device_id, rule_id, max(time_logged)
FROM alert_log a2 WHERE a1.device_id = a2.device_id AND a1.rule_id = a2.rule_id
AND a2.time_logged < DATE_SUB(NOW(),INTERVAL 31 DAY)
)
) as c
)
) (SQL: DELETE
FROM alert_log
WHERE id IN(
SELECT id FROM(
SELECT id
FROM alert_log a1
WHERE
time_logged < DATE_SUB(NOW(),INTERVAL 31 DAY)
AND (device_id, rule_id, time_logged) NOT IN (
SELECT device_id, rule_id, max(time_logged)
FROM alert_log a2 WHERE a1.device_id = a2.device_id AND a1.rule_id = a2.rule_id
AND a2.time_logged < DATE_SUB(NOW(),INTERVAL 31 DAY)
)
) as c
)
)#0 /opt/librenms/includes/functions.php(1431): dbQuery()
#1 /opt/librenms/daily.php(291): lock_and_purge_query()
#2 {main}


My ./validate.php output:

Component Version
LibreNMS 22.7.0-24-g6ebcde3c0
DB Schema 2022_07_03_1947_add_app_data (244)
PHP 8.1.8
Python 3.8.10
MySQL 10.8.3-MariaDB-1:10.8.3+maria~focal
RRDTool 1.7.2
SNMP 5.8

====================================

[OK] Composer Version: 2.3.10
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database Schema is current
[OK] SQL Server meets minimum requirements
[OK] lower_case_table_names is enabled
[OK] MySQL engine is optimal
[OK]
[OK] Database schema correct
[OK] MySQl and PHP time match
[OK] rrdtool version ok
[OK] Connected to rrdcached


Anyone else here around who has the same log entries and can confirm this with PHP 8.1 ?
Seems this has anything to do with the cleaning/purge process.

Best regards

Anybody here who has an idea what this could be?

I see the same errors in the librenms.log when executing the daily.sh

[2022-08-10T11:42:43.610065+02:00] production.ERROR: SQLSTATE[HY093]: Invalid parameter number (SQL: DELETE
FROM alert_log
WHERE id IN(
SELECT id FROM(
SELECT id
FROM alert_log a1
WHERE
time_logged < DATE_SUB(NOW(),INTERVAL 365 DAY)
AND (device_id, rule_id, time_logged) NOT IN (
SELECT device_id, rule_id, max(time_logged)
FROM alert_log a2 WHERE a1.device_id = a2.device_id AND a1.rule_id = a2.rule_id
AND a2.time_logged < DATE_SUB(NOW(),INTERVAL 365 DAY)
)
) as c
)
) (SQL: DELETE
FROM alert_log
WHERE id IN(
SELECT id FROM(
SELECT id
FROM alert_log a1
WHERE
time_logged < DATE_SUB(NOW(),INTERVAL 365 DAY)
AND (device_id, rule_id, time_logged) NOT IN (
SELECT device_id, rule_id, max(time_logged)
FROM alert_log a2 WHERE a1.device_id = a2.device_id AND a1.rule_id = a2.rule_id
AND a2.time_logged < DATE_SUB(NOW(),INTERVAL 365 DAY)
)
) as c
)
)#0 /opt/librenms/includes/functions.php(1431): dbQuery()
#1 /opt/librenms/daily.php(291): lock_and_purge_query()
#2 {main}

I have been checking the logs and indead it is since I upgraded PHP7.4 to 8.1 this moring

$ ./validate.php

Component Version
LibreNMS 22.7.0-58-g83126161d
DB Schema 2022_07_19_081224_plugins_unique_index (244)
PHP 8.1.8
Python 3.8.10
Database MariaDB 10.3.34-MariaDB-0ubuntu0.20.04.1
RRDTool 1.7.2
SNMP 5.8

====================================

[OK] Composer Version: 2.0.6
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database Schema is current
[OK] SQL Server meets minimum requirements
[OK] lower_case_table_names is enabled
[OK] MySQL engine is optimal
[OK]
[OK] Database schema correct
[OK] MySQl and PHP time match
[OK] Active pollers found
[OK] Dispatcher Service not detected
[OK] Locks are functional
[OK] Python poller wrapper is polling
[OK] Redis is unavailable
[OK] rrd_dir is writable
[OK] rrdtool version ok
$

Thank you for confirming this.