Check context post processing queue before sending status to cloud (#16472)
Waiting until the context post processing queue is empty before sending node info and collectors
Stelios Fragkakis committed
Nov 28, 2023 at 15:56 UTC
f6a4ce8972fe5278493f6d8d827755394f98d608
1 file changed
+17
-5
database/sqlite/sqlite_aclk_node.c
+17
-5
@@ -136,6 +136,7 @@ void aclk_check_node_info_and_collectors(void)
136
137
size_t context_loading = 0;
138
size_t replicating = 0;
139
+ size_t context_pp = 0;
140
dfe_start_reentrant(rrdhost_root_index, host)
141
{
142
struct aclk_sync_cfg_t *wc = host->aclk_config;
@@ -154,13 +155,18 @@ void aclk_check_node_info_and_collectors(void)
155
continue;
156
}
157
157
- if (wc->node_info_send_time && wc->node_info_send_time + 30 < now_realtime_sec()) {
158
+ bool pp_queue_empty = !(host->rrdctx.pp_queue && dictionary_entries(host->rrdctx.pp_queue));
159
+
160
+ if (!pp_queue_empty && (wc->node_info_send_time || wc->node_collectors_send))
161
+ context_pp++;
162
+
163
+ if (pp_queue_empty && wc->node_info_send_time && wc->node_info_send_time + 30 < now_realtime_sec()) {
164
wc->node_info_send_time = 0;
165
build_node_info(host);
166
internal_error(true, "ACLK SYNC: Sending node info for %s", rrdhost_hostname(host));
167
}
168
163
- if (wc->node_collectors_send && wc->node_collectors_send + 30 < now_realtime_sec()) {
169
+ if (pp_queue_empty && wc->node_collectors_send && wc->node_collectors_send + 30 < now_realtime_sec()) {
170
build_node_collectors(host);
171
internal_error(true, "ACLK SYNC: Sending collectors for %s", rrdhost_hostname(host));
172
wc->node_collectors_send = 0;
@@ -168,10 +174,16 @@ void aclk_check_node_info_and_collectors(void)
174
}
175
dfe_done(host);
176
171
- if (context_loading || replicating) {
177
+ if (context_loading || replicating || context_pp) {
178
nd_log_limit_static_thread_var(erl, 10, 100 * USEC_PER_MS);
173
- nd_log_limit(&erl, NDLS_DAEMON, NDLP_INFO,
174
- "%zu nodes loading contexts, %zu replicating data", context_loading, replicating);
179
+ nd_log_limit(
180
+ &erl,
181
+ NDLS_DAEMON,
182
+ NDLP_INFO,
183
+ "%zu nodes loading contexts, %zu replicating data, %zu pending context post processing",
184
+ context_loading,
185
+ replicating,
186
+ context_pp);
187
}
188
}
189