Fix random crash during shutdown (#19978)
Drop precompiled statements from main thread
Stelios Fragkakis committed
Mar 27, 2025 at 01:43 UTC
1968b7c509070994d35bcc3e8d8a3c5ddac6ebfd
1 file changed
+8
-8
src/database/sqlite/sqlite_metadata.c
+8
-8
@@ -991,9 +991,9 @@ done:
991
// Store host and host system info information in the database
992
static int store_host_metadata(RRDHOST *host)
993
{
994
- static __thread sqlite3_stmt *res = NULL;
994
+ sqlite3_stmt *res = NULL;
995
996
- if (!PREPARE_COMPILED_STATEMENT(db_meta, SQL_STORE_HOST_INFO, &res))
996
+ if (!PREPARE_STATEMENT(db_meta, SQL_STORE_HOST_INFO, &res))
997
return false;
998
999
int param = 0;
@@ -1019,24 +1019,24 @@ static int store_host_metadata(RRDHOST *host)
1019
if (unlikely(store_rc != SQLITE_DONE))
1020
error_report("Failed to store host %s, rc = %d", rrdhost_hostname(host), store_rc);
1021
1022
- SQLITE_RESET(res);
1022
+ SQLITE_FINALIZE(res);
1023
1024
return store_rc != SQLITE_DONE;
1025
1026
bind_fail:
1027
REPORT_BIND_FAIL(res, param);
1028
- SQLITE_RESET(res);
1028
+ SQLITE_FINALIZE(res);
1029
return 1;
1030
}
1031
1032
static int add_host_sysinfo_key_value(const char *name, const char *value, nd_uuid_t *uuid)
1033
{
1034
- static __thread sqlite3_stmt *res = NULL;
1034
+ sqlite3_stmt *res = NULL;
1035
1036
if (!REQUIRE_DB(db_meta))
1037
return 0;
1038
1039
- if (!PREPARE_COMPILED_STATEMENT(db_meta, SQL_STORE_HOST_SYSTEM_INFO_VALUES, &res))
1039
+ if (!PREPARE_STATEMENT(db_meta, SQL_STORE_HOST_SYSTEM_INFO_VALUES, &res))
1040
return 0;
1041
1042
int param = 0;
@@ -1048,13 +1048,13 @@ static int add_host_sysinfo_key_value(const char *name, const char *value, nd_uu
1048
if (unlikely(store_rc != SQLITE_DONE))
1049
error_report("Failed to store host info value %s, rc = %d", name, store_rc);
1050
1051
- SQLITE_RESET(res);
1051
+ SQLITE_FINALIZE(res);
1052
1053
return store_rc == SQLITE_DONE;
1054
1055
bind_fail:
1056
REPORT_BIND_FAIL(res, param);
1057
- SQLITE_RESET(res);
1057
+ SQLITE_FINALIZE(res);
1058
return 0;
1059
}
1060