Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing time parameter on FROM_UNIXTIME function #207

Closed
netniV opened this issue Jun 28, 2021 · 2 comments
Closed

Missing time parameter on FROM_UNIXTIME function #207

netniV opened this issue Jun 28, 2021 · 2 comments

Comments

@netniV
Copy link
Member

netniV commented Jun 28, 2021

Describe the bug
Random and sporadic instances of errors in the log files:

SPINE: Poller[Main Poller] PID[5621] ERROR: SQL Failed! Error:'1582', 
Message:'Incorrect parameter count in the call to native function 'FROM_UNIXTIME'', 
SQL Fragment:
	INSERT INTO poller_output (local_data_id, rrd_name, time, output) 
	VALUES
		(13717,'apc_total_load',FROM_UNIXTIME(),'130'),
		(13718,'apc_bankb1_load',FROM_UNIXTIME(),'69'),
		(13719,'apc_bankb2_load',FROM_UNIXTIME(),'63') 
	ON DUPLICATE KEY UPDATE output=VALUES(output)

My own investigations lead me through the get_host_poll_time() function, which seems to be correct. It is possible this is only affecting devices using multiple threads and doing so too quickly. As such, it can end up freeing the "host_time" field when moving onto the next device.

Additional context
A partial fix is potentially:

diff --git a/spine.c b/spine.c
index a6661aa..8567c31 100644
--- a/spine.c
+++ b/spine.c
@@ -737,16 +737,12 @@ int main(int argc, char *argv[]) {
                                itemsPT   = atoi(mysql_row[0]);
                                db_free_result(tresult);

-                               if (host_time) free(host_time);
-
                                host_time = get_host_poll_time();
                                host_time_double = get_time_as_double();
                        }
                } else {
                        itemsPT = 0;

-                       if (host_time) free(host_time);
-
                        host_time = get_host_poll_time();
                        host_time_double = get_time_as_double();
                }

However, this has the potential to leave host_time "un" free'd.

@netniV netniV added the bug label Jun 28, 2021
@netniV netniV changed the title Missing time parameter on FROM_TIMESTAMP function Missing time parameter on FROM_UNIXTIME function Jun 28, 2021
@TheWitness
Copy link
Member

That's going to have to be it. It'll leak a little memory, but not enough to cause problems even with 30k hosts. Memory get's freed in the end enayway.

TheWitness added a commit that referenced this issue Jul 1, 2021
This will introduce a small leak, but I don't see another way around this for the moment.
@TheWitness
Copy link
Member

Likely there was a valgrind done at some point and showed a leak. Some things don't want to be free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants