@cryptotaxi247 / netdata-1 / commits / b8958eb8a

Fix locking access to chart labels (#13064)

No write lock required

Stelios Fragkakis committed Jun 3, 2022 at 15:24 UTC b8958eb8adeabd22aea1117b813c22db77854b51
3 files changed +3 -3
database/rrdset.c
+1 -1
@@ -1974,7 +1974,7 @@ void rrdset_finalize_labels(RRDSET *st)
1974 replace_label_list(labels, new_labels);
1975 }
1976
1977 - netdata_rwlock_wrlock(&labels->labels_rwlock);
1977 + netdata_rwlock_rdlock(&labels->labels_rwlock);
1978 struct label *lbl = labels->head;
1979 while (lbl) {
1980 sql_store_chart_label(st->chart_uuid, (int)lbl->label_source, lbl->key, lbl->value);
database/sqlite/sqlite_aclk_chart.c
+1 -1
@@ -159,7 +159,7 @@ int aclk_add_chart_event(struct aclk_database_worker_config *wc, struct aclk_dat
159 chart_payload.id = strdupz(st->id);
160
161 struct label_index *labels = &st->state->labels;
162 - netdata_rwlock_wrlock(&labels->labels_rwlock);
162 + netdata_rwlock_rdlock(&labels->labels_rwlock);
163 struct label *label_list = labels->head;
164 struct label *chart_label = NULL;
165 while (label_list) {
database/sqlite/sqlite_aclk_node.c
+1 -1
@@ -76,7 +76,7 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat
76 node_info.data.ml_info.ml_enabled = host->system_info->ml_enabled;
77
78 struct label_index *labels = &host->labels;
79 - netdata_rwlock_wrlock(&labels->labels_rwlock);
79 + netdata_rwlock_rdlock(&labels->labels_rwlock);
80 node_info.data.host_labels_head = labels->head;
81
82 aclk_update_node_info(&node_info);