-
Problem report
-
Resolution: Fixed
-
Trivial
-
3.4.12, 4.0.0alpha9
-
Sprint 40
-
0.125
Alert manager does not close previous connection, this leads to memory leak after each successful reconnect.
==613== For counts of detected and suppressed errors, rerun with: -v ==613== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==637== at 0x4C30B06: calloc (vg_replace_malloc.c:711) ==637== by 0x4E58C16: mysql_init (in /usr/lib64/libmariadb.so.3) ==637== by 0x7B505E: zbx_db_connect (db.c:494) ==637== by 0x6EA30C: DBconnect (db.c:73) ==637== by 0x430DD7: alert_manager_thread (alert_manager.c:1943) ==637== by 0x66035C: zbx_thread_start (threads.c:133) ==637== by 0x41E986: MAIN_ZABBIX_ENTRY (server.c:1178) ==637== by 0x62FBAA: daemon_start (daemon.c:392) ==637== by 0x41D14D: main (server.c:854) ==637== ==637== 173,765 (6,360 direct, 167,405 indirect) bytes in 5 blocks are definitely lost in loss record 140 of 140 ==637== at 0x4C30B06: calloc (vg_replace_malloc.c:711) ==637== by 0x4E58C16: mysql_init (in /usr/lib64/libmariadb.so.3) ==637== by 0x7B505E: zbx_db_connect (db.c:494) ==637== by 0x6EA30C: DBconnect (db.c:73) ==637== by 0x430E9B: alert_manager_thread (alert_manager.c:1963) ==637== by 0x66035C: zbx_thread_start (threads.c:133) ==637== by 0x41E986: MAIN_ZABBIX_ENTRY (server.c:1178) ==637== by 0x62FBAA: daemon_start (daemon.c:392) ==637== by 0x41D14D: main (server.c:854) ==637== ==637== LEAK SUMMARY: ==637== definitely lost: 7,632 bytes in 6 blocks ==637== indirectly lost: 200,886 bytes in 120 blocks ==637== possibly lost: 0 bytes in 0 blocks ==637== still reachable: 146,440 bytes in 244 blocks ==637== suppressed: 0 bytes in 0 blocks ==637== Reachable blocks (those to which a pointer was found) are not shown. ==637== To see them, rerun with: --leak-check=full --show-leak-kinds=all
PostgreSQL
==22638== 35,532 (896 direct, 34,636 indirect) bytes in 1 blocks are definitely lost in loss record 103 of 104 ==22638== at 0x4C2EBAB: malloc (vg_replace_malloc.c:299) ==22638== by 0x4E4767A: ??? (in /usr/lib64/libpq.so.5.10) ==22638== by 0x4E4DD3A: PQsetdbLogin (in /usr/lib64/libpq.so.5.10) ==22638== by 0x783163: zbx_db_connect (db.c:542) ==22638== by 0x6E96AF: DBconnect (db.c:73) ==22638== by 0x44BAC4: alert_manager_thread (alert_manager.c:1884) ==22638== by 0x64AAB1: zbx_thread_start (threads.c:128) ==22638== by 0x43966D: MAIN_ZABBIX_ENTRY (server.c:1130) ==22638== by 0x61A2F0: daemon_start (daemon.c:392) ==22638== by 0x437F5D: main (server.c:832) ==22638== ==22638== LEAK SUMMARY: ==22638== definitely lost: 896 bytes in 1 blocks ==22638== indirectly lost: 34,636 bytes in 31 blocks ==22638== possibly lost: 0 bytes in 0 blocks ==22638== still reachable: 147,066 bytes in 251 blocks ==22638== suppressed: 0 bytes in 0 blocks ==22638== Reachable blocks (those to which a pointer was found) are not shown. ==22638== To see them, rerun with: --leak-check=full --show-leak-kinds=all
Following patch fixes the issue but need proper review and testing
Index: src/zabbix_server/alerter/alert_manager.c =================================================================== --- src/zabbix_server/alerter/alert_manager.c (revision 83601) +++ src/zabbix_server/alerter/alert_manager.c (working copy) @@ -1960,6 +1960,7 @@ if (ZBX_DB_DOWN == manager.dbstatus && time_connect + ZBX_DB_WAIT_DOWN <= now) { + DBclose(); if (ZBX_DB_DOWN == (manager.dbstatus = DBconnect(ZBX_DB_CONNECT_ONCE))) { am_queue_watchdog_alerts(&manager);