[ZBX-25110] Postgres issue with 7.0.1/2 Created: 2024 Aug 25 Updated: 2024 Aug 28 Resolved: 2024 Aug 28 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | API (A) |
Affects Version/s: | 7.0.2 |
Fix Version/s: | None |
Type: | Patch request | Priority: | Trivial |
Reporter: | Jason Cormie | Assignee: | Zabbix Support Team |
Resolution: | Won't fix | Votes: | 0 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | 4h | ||
Original Estimate: | Not Specified | ||
Environment: |
Debian Bullseye backport of 7.0.1 with postgres |
Attachments: |
![]() ![]() |
Description |
See the description in the first 2 comments. |
Comments |
Comment by Jason Cormie [ 2024 Aug 25 ] |
On upgrade from Debian stable version 6.0.14 to 7.0.1 graphs failed to load with postgres error function round(double precision, integer) does not exist when display graphs. I fixed this by altering line 1128 of CHIstoryManager.php to include a cast as numeric from $calc_field = 'round('.$width.'.0*(clock-'.$time_from.')/'.$period.',0)'; to $calc_field = 'round(cast('.$width.'.0*(clock-'.$time_from.')/'.$period.' AS numeric),0)'; and this seems to have fixed it. |
Comment by Jason Cormie [ 2024 Aug 25 ] |
This was one of the visible errors in a graph box pg_query(): Query failed: ERROR: function round(double precision, integer) does not exist LINE 1: ...value) AS avg,MIN(value) AS min,MAX(value) AS max,round(604.... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SvgGraph\Actions\WidgetView->doAction() → Widgets\SvgGraph\Includes\CSvgGraphHelper::get() → Widgets\SvgGraph\Includes\CSvgGraphHelper::getMetricsData() → CHistoryManager->getGraphAggregationByWidth() → CHistoryManager->getGraphAggregationByWidthFromSql() → DBselect() → pg_query() in include/db.inc.php:249] Error in query [SELECT itemid,COUNT(*) AS count,AVG(value) AS avg,MIN(value) AS min,MAX(value) AS max,round(604.0*(clock-1724607591)/10800,0) AS i,MAX(clock) AS clock FROM history_uint WHERE itemid='161383' AND clock>='1724607591' AND clock<='1724618391' GROUP BY itemid,round(604.0*(clock-1724607591)/10800,0)] [ERROR: function round(double precision, integer) does not exist |
Comment by dimir [ 2024 Aug 26 ] |
Thanks for reporting this! We'll take a look. |
Comment by Gregory Chalenko [ 2024 Aug 26 ] |
JasonCormie what postgres version do you use? |
Comment by Jason Cormie [ 2024 Aug 26 ] |
postgres from Debian 12 stable 15.8 |
Comment by Gregory Chalenko [ 2024 Aug 26 ] |
JasonCormie will query below fail with reported error, when is run in your postgres installation? WITH clocks AS ( SELECT GENERATE_SERIES(1724607591,1724618391) AS clock ) SELECT round(604.0*(clock-1724607591)/10800,0) FROM clocks but this one will work without issue? WITH clocks AS ( SELECT GENERATE_SERIES(1724607591,1724618391) AS clock ) SELECT round(604.0*(clock-1724607591)/10800) FROM clocks |
Comment by Jason Cormie [ 2024 Aug 26 ] |
Both statements executed without issue, producing a table of incrementing numbers with no errors visible from psql. |
Comment by Gregory Chalenko [ 2024 Aug 28 ] |
JasonCormie can you please provide output of command SELECT VERSION() for database where registered error is triggered? |
Comment by Jason Cormie [ 2024 Aug 28 ] |
zabbix=# SELECT VERSION(); |
Comment by Alexander Vladishev [ 2024 Aug 28 ] |
Could you please provide the output of this command? SHOW ALL; |
Comment by Jason Cormie [ 2024 Aug 28 ] |
Output attached as too big for comments all.txt |
Comment by Alexander Vladishev [ 2024 Aug 28 ] |
Unfortunately, we have not been able to reproduce this issue. Could you let us know if the SQL queries we requested were executed on the same machine where the Zabbix web server is running? If not, please try executing them under the same system user that the web server runs as. There might be some differences in the environment. |
Comment by Jason Cormie [ 2024 Aug 28 ] |
The same machine has the zabbix server and the database. If I run my error message SQL I still get the round error zabbix=> SELECT itemid,COUNT(*) AS count,AVG(value) AS avg,MIN(value) AS min,MAX(value) AS max,round(604.0*(clock-1724607591)/10800,0) AS i,MAX(clock) AS clock FROM history_uint WHERE itemid='161383' AND clock>='1724607591' AND clock<='1724618391' GROUP BY itemid,round(604.0*(clock-1724607591)/10800,0); ERROR: function round(double precision, integer) does not exist LINE 1: ...value) AS avg,MIN(value) AS min,MAX(value) AS max,round(604.... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. zabbix=> The definition of history_uint looks like zabbix=> \d history_uint Table "public.history_uint" Column | Type | Collation | Nullable | Default --------+------------------+-----------+----------+------------ itemid | bigint | | not null | clock | double precision | | not null | 0 value | numeric(20,0) | | not null | 0::numeric ns | integer | | not null | 0 Indexes: "history_uint_pkey" PRIMARY KEY, btree (itemid, clock, ns) "history_uint_1" btree (itemid, clock) Triggers: partition_trg BEFORE INSERT ON history_uint FOR EACH ROW EXECUTE FUNCTION trg_partition('day') Number of child tables: 91 (Use \d+ to list them.) |
Comment by Edgar Akhmetshin [ 2024 Aug 28 ] |
Please show output for: \df round; |
Comment by Jason Cormie [ 2024 Aug 28 ] |
zabbix=> select version(); version ------------------------------------------------------------------------------------------------------------------- PostgreSQL 15.8 (Debian 15.8-0+deb12u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit (1 row) zabbix=> \df round; List of functions Schema | Name | Result data type | Argument data types | Type ------------+-------+------------------+---------------------+------ pg_catalog | round | double precision | double precision | func pg_catalog | round | numeric | numeric | func pg_catalog | round | numeric | numeric, integer | func (3 rows) |
Comment by Alexander Vladishev [ 2024 Aug 28 ] |
Could you please provide the output of the "SHOW ALL;" command under "zabbix" user? |
Comment by Jason Cormie [ 2024 Aug 28 ] |
SHOW all attached all.txt |
Comment by Edgar Akhmetshin [ 2024 Aug 28 ] |
Hello Jason, This is the original schema of the table on 16.3 PgSQL: zabbix=# \d history_uint Table "public.history_uint" Column | Type | Collation | Nullable | Default --------+---------------+-----------+----------+-------------- itemid | bigint | | not null | clock | integer | | not null | 0 value | numeric(20,0) | | not null | '0'::numeric ns | integer | | not null | 0 Indexes: "history_uint_pkey" PRIMARY KEY, btree (itemid, clock, ns) You have a not needed index (but it's not the case) and also you have clock field type double precision. With incorrect clock field you will have: zabbix=# SELECT itemid,COUNT(*) AS count,AVG(value) AS avg,MIN(value) AS min,MAX(value) AS max,round(604.0*(clock-1724607591)/10800,0) AS i,MAX(clock) AS clock FROM history_uint WHERE itemid='161383' AND clock>='1724607591' AND clock<='1724618391' GROUP BY itemid,round(604.0*(clock-1724607591)/10800,0); ERROR: function round(double precision, integer) does not exist LINE 1: ...value) AS avg,MIN(value) AS min,MAX(value) AS max,round(604.... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. zabbix=# select version(); version -------------------------------------------------------------------------------------------------------------------- PostgreSQL 16.3 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309, 64-bit (1 row) Please use official database schema. Closing as Won't fix. Regards, |
Comment by Jason Cormie [ 2024 Aug 28 ] |
Thank you all for looking at this, I'll go look at fixing my database before the next upgrade |