[ZBX-17450] "Something impossible" with forecast\timeleft functions and polynomial6 approximation Created: 2020 Mar 13  Updated: 2024 Apr 10  Resolved: 2022 Jul 12

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 4.2.8
Fix Version/s: 5.0.26rc1, 6.0.7rc1, 6.2.1rc1, 6.4.0alpha1, 6.4 (plan)

Type: Problem report Priority: Trivial
Reporter: Elina Kuzyutkina (Inactive) Assignee: Andris Zeila
Resolution: Fixed Votes: 0
Labels: prediction, server
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Microsoft Word _SELECT_i_name_h_value_h_clock_to_date_01_01_1970_mm_dd_yyyy_num_202004131432.csv    
Issue Links:
Duplicate
Sub-task
Team: Team A
Sprint: Sprint 90 (Jul 2022)
Story Points: 1

 Description   
zabbix_server [3804]: ERROR [file:prediction.c,line:712] Something impossible has just happened.
  3804:20200312:235903.152 === Backtrace: ===
  3804:20200312:235903.153 13: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values](zbx_backtrace+0x35) [0x518555]
  3804:20200312:235903.153 12: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values]() [0x51d107]
  3804:20200312:235903.153 11: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values](zbx_forecast+0x4d5) [0x51e935]
  3804:20200312:235903.153 10: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values]() [0x422c50]
  3804:20200312:235903.153 9: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values](evaluate_function+0x2c77) [0x4dd627]
  3804:20200312:235903.153 8: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values](get_value_calculated+0xa3b) [0x44601b]
  3804:20200312:235903.153 7: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values]() [0x43958b]
  3804:20200312:235903.153 6: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values](poller_thread+0xe8) [0x4397a8]
  3804:20200312:235903.153 5: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values](zbx_thread_start+0x3e) [0x52182e]
  3804:20200312:235903.153 4: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values](MAIN_ZABBIX_ENTRY+0x90a) [0x42a7ca]
  3804:20200312:235903.153 3: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values](daemon_start+0x1a3) [0x5180a3]
  3804:20200312:235903.153 2: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values](main+0x3b3) [0x4296b3]
  3804:20200312:235903.153 1: /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f63700fe495]
  3804:20200312:235903.153 0: /usr/local/sbin/zabbix_server: poller #13 [got 1 values in 0.001764 sec, getting values]() [0x4299c6]

Calculated item key is like:

forecast("db.odbc.select[someparameters]",7d,,2h,polynomial6,min) 


 Comments   
Comment by Glebs Ivanovskis [ 2020 Mar 16 ]

Would be interesting to see item's history for 7 days prior to this error. Also Zabbix server should log the approximation formula if you increase log level, this may shed some light as well.

Comment by Glebs Ivanovskis [ 2020 May 04 ]

Data in _SELECT_i_name_h_value_h_clock_to_date_01_01_1970_mm_dd_yyyy_num_202004131432.csv does not correspond to the time of error message from the log file in issue Description. Would it be possible to get an error from log file and the data from history that would match each other? It would be perfect if timestamps included nanoseconds as well.

Comment by Vladislavs Sokurenko [ 2021 Mar 17 ]

Might be similar issue on zabbix_server (Zabbix) 5.2.6rc1

Create calculated item with formula:

forecast(trap1,1h,,2h,polynomial3,max)

Trapper item with uint64 value type:

trap1

Send value 18446744073709551610, then send 18446744073709551605, and observe error when calculated check occurs.

 75263:20210317:132857.457 In get_value() key:'forecast'
 75263:20210317:132857.457 In get_value_calculated() key:'forecast' expression:'forecast(trap1,1h,,2h,polynomial3,max)'
 75263:20210317:132857.458 In calcitem_parse_expression() expression:'forecast(trap1,1h,,2h,polynomial3,max)'
 75263:20210317:132857.469 calcitem_parse_expression() functionid:1 function:'Zabbix server:trap1.forecast(1h,,2h,polynomial3,max)'
 75263:20210317:132857.471 calcitem_parse_expression() expression:'{1}'
 75263:20210317:132857.472 End of calcitem_parse_expression():SUCCEED
 75263:20210317:132857.473 In calcitem_evaluate_expression()
 75263:20210317:132857.482 In evaluate_function() function:'Zabbix server:trap1.forecast(1h,,2h,polynomial3,max)' ts:'2021.03.17 13:28:57 480360850'
 75263:20210317:132857.485 In evaluate_FORECAST()
 75263:20210317:132857.488 In get_function_parameter_int() parameters:'1h,,2h,polynomial3,max' Nparam:1
 75263:20210317:132857.492 get_function_parameter_int() type:sec value:3600
 75263:20210317:132857.493 End of get_function_parameter_int():SUCCEED
 75263:20210317:132857.493 In get_function_parameter_int() parameters:'1h,,2h,polynomial3,max' Nparam:2
 75263:20210317:132857.494 get_function_parameter_int() type:sec value:0
 75263:20210317:132857.494 End of get_function_parameter_int():SUCCEED
 75263:20210317:132857.494 In get_function_parameter_int() parameters:'1h,,2h,polynomial3,max' Nparam:3
 75263:20210317:132857.494 get_function_parameter_int() type:sec value:7200
 75263:20210317:132857.495 End of get_function_parameter_int():SUCCEED
 75263:20210317:132857.495 In get_function_parameter_str() parameters:'1h,,2h,polynomial3,max' Nparam:4
 75263:20210317:132857.496 get_function_parameter_str() value:'polynomial3'
 75263:20210317:132857.497 End of get_function_parameter_str():SUCCEED
 75263:20210317:132857.498 In get_function_parameter_str() parameters:'1h,,2h,polynomial3,max' Nparam:5
 75263:20210317:132857.499 get_function_parameter_str() value:'max'
 75263:20210317:132857.499 End of get_function_parameter_str():SUCCEED
 75263:20210317:132857.500 In zbx_vc_get_values() itemid:33550 value_type:3 seconds:3600 count:0 sec:1615980537 ns:480360850
 75263:20210317:132857.509 End of zbx_vc_get_values():SUCCEED count:2 cached:1
==75263== Invalid read of size 8
==75263==    at 0x5EF6BF: zbx_log_expression (prediction.c:955)
==75263==    by 0x5EFA1B: zbx_forecast (prediction.c:1008)
==75263==    by 0x57C98D: evaluate_FORECAST (evalfunc.c:2520)
==75263==    by 0x57DF72: evaluate_function (evalfunc.c:2945)
==75263==    by 0x4502CB: calcitem_evaluate_expression (checks_calculated.c:255)
==75263==    by 0x4506FA: get_value_calculated (checks_calculated.c:334)
==75263==    by 0x449EF5: get_value (poller.c:396)
==75263==    by 0x44C731: zbx_check_items (poller.c:768)
==75263==    by 0x44D2D6: get_values (poller.c:871)
==75263==    by 0x44DC04: poller_thread (poller.c:1040)
==75263==    by 0x5F4B51: zbx_thread_start (threads.c:136)
==75263==    by 0x42C86E: MAIN_ZABBIX_ENTRY (server.c:1272)
==75263==  Address 0x18281938 is 8 bytes after a block of size 16 alloc'd
==75263==    at 0x4839809: malloc (vg_replace_malloc.c:307)
==75263==    by 0x5FC9E2: zbx_malloc2 (misc.c:622)
==75263==    by 0x5EC00A: zbx_matrix_alloc (prediction.c:60)
==75263==    by 0x5ECD08: zbx_matrix_mult (prediction.c:279)
==75263==    by 0x5ECF48: zbx_least_squares (prediction.c:327)
==75263==    by 0x5ED4A4: zbx_regression (prediction.c:436)
==75263==    by 0x5EF9F4: zbx_forecast (prediction.c:1005)
==75263==    by 0x57C98D: evaluate_FORECAST (evalfunc.c:2520)
==75263==    by 0x57DF72: evaluate_function (evalfunc.c:2945)
==75263==    by 0x4502CB: calcitem_evaluate_expression (checks_calculated.c:255)
==75263==    by 0x4506FA: get_value_calculated (checks_calculated.c:334)
==75263==    by 0x449EF5: get_value (poller.c:396)
==75263== 
 75263:20210317:132857.532 fitted expression is: x = (0.000000) * (389.374214 + t) ^ 3 + (0.000000) * (389.374214 + t) ^ 2 + (0.000000) * (389.374214 + t) ^ 1 + (18446744073709547520.000000) * (389.374214 + t) ^ 0
zabbix_server [75263]: ERROR [file and function: <prediction.c,zbx_polynomial_roots>, revision:{ZABBIX_REVISION}] Something impossible has just happened.
 75263:20210317:132857.541 === Backtrace: ===
 75263:20210317:132857.571 17: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](zbx_backtrace+0x5a) [0x5e499f]
 75263:20210317:132857.572 16: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values]() [0x5eebbc]
 75263:20210317:132857.572 15: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values]() [0x5eec9d]
 75263:20210317:132857.572 14: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](zbx_forecast+0x5a4) [0x5efeaf]
 75263:20210317:132857.572 13: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values]() [0x57c98e]
 75263:20210317:132857.573 12: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](evaluate_function+0x817) [0x57df73]
 75263:20210317:132857.573 11: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values]() [0x4502cc]
 75263:20210317:132857.573 10: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](get_value_calculated+0x134) [0x4506fb]
 75263:20210317:132857.573 9: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values]() [0x449ef6]
 75263:20210317:132857.574 8: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](zbx_check_items+0xcd) [0x44c732]
 75263:20210317:132857.574 7: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values]() [0x44d2d7]
 75263:20210317:132857.574 6: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](poller_thread+0x1fc) [0x44dc05]
 75263:20210317:132857.574 5: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](zbx_thread_start+0x48) [0x5f4b52]
 75263:20210317:132857.574 4: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](MAIN_ZABBIX_ENTRY+0xb2f) [0x42c86f]
 75263:20210317:132857.575 3: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](daemon_start+0x2f3) [0x5e45d0]
 75263:20210317:132857.575 2: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](main+0x2ed) [0x42bce1]
 75263:20210317:132857.575 1: /lib64/libc.so.6(__libc_start_main+0xf2) [0x5ad61e2]
 75263:20210317:132857.575 0: ./sbin/zabbix_server: poller #1 [got 0 values in 0.006599 sec, getting values](_start+0x2e) [0x42acfe]
 75263:20210317:132857.580 End of evaluate_FORECAST():SUCCEED
 75263:20210317:132857.582 End of evaluate_function():SUCCEED value:'-1'
 75263:20210317:132857.590 End of calcitem_evaluate_expression():SUCCEED
 75263:20210317:132857.591 In evaluate() expression:'(-1)'
 75263:20210317:132857.608 End of evaluate() value:-1.000000
 75263:20210317:132857.609 get_value_calculated() value:-1.000000
 75263:20210317:132857.611 End of get_value_calculated():SUCCEED
 75263:20210317:132857.612 End of get_value():SUCCEED

wiper: The valgrind error happens because poly degree (K) is higher than the number (N) of available values. zbx_fill_independent() lowers the K to the N - 1 and allocates coefficient matrix based on that value. However zbx_log_expression() uses the original K value to dump the coefficient matrix.

Comment by Andris Zeila [ 2022 Jul 12 ]

Released ZBX-17450 in:

  • pre-5.0.26rc1 0fd75b3a193
  • pre-6.0.7rc1 266c95f4520
  • pre-6.2.1rc1 7b7f3eef66a
  • pre-6.4.0alpha1 8f4ca308627
Generated at Wed Jul 16 11:46:51 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.