Name storage engine variables consistently. (#16753)
* Consistent naming of STORAGE_INSTANCE instances. Replace usages of `db_instance` and `instance` with `si`. * Rename array `storage_metrics_groups[tier]` to `smg[tier]` * Rename db_metric_handle to smh * Rename instances of `storage_engine_query_handle` to `seqh`. * Rename instances of STORAGE_ENGINE_BACKEND to `seb`. * Rename instances of STORAGE_COLLECT_HANDLE to `sch`.
vkalintiris committed
Jan 11, 2024 at 14:17 UTC
bead543ea52e51cf73f7e5b27de53197801399a7
22 files changed
+463
-463
daemon/global_statistics.c
+3
-3
@@ -2560,9 +2560,9 @@ static void dbengine2_statistics_charts(void) {
2560
/* get localhost's DB engine's statistics for each tier */
2561
for(size_t tier = 0; tier < storage_tiers ;tier++) {
2562
if(host->db[tier].mode != RRD_MEMORY_MODE_DBENGINE) continue;
2563
- if(!host->db[tier].instance) continue;
2563
+ if(!host->db[tier].si) continue;
2564
2565
- if(is_storage_engine_shared(host->db[tier].instance)) {
2565
+ if(is_storage_engine_shared(host->db[tier].si)) {
2566
if(counted_multihost_db[tier])
2567
continue;
2568
else
@@ -2570,7 +2570,7 @@ static void dbengine2_statistics_charts(void) {
2570
}
2571
2572
++dbengine_contexts;
2573
- rrdeng_get_37_statistics((struct rrdengine_instance *)host->db[tier].instance, local_stats_array);
2573
+ rrdeng_get_37_statistics((struct rrdengine_instance *)host->db[tier].si, local_stats_array);
2574
for (i = 0; i < RRDENG_NR_STATS; ++i) {
2575
/* aggregate statistics across hosts */
2576
stats_array[i] += local_stats_array[i];
daemon/service.c
+4
-4
@@ -52,13 +52,13 @@ static void svc_rrddim_obsolete_to_archive(RRDDIM *rd) {
52
53
size_t tiers_available = 0, tiers_said_no_retention = 0;
54
for(size_t tier = 0; tier < storage_tiers ;tier++) {
55
- if(rd->tiers[tier].db_collection_handle) {
55
+ if(rd->tiers[tier].sch) {
56
tiers_available++;
57
58
- if(storage_engine_store_finalize(rd->tiers[tier].db_collection_handle))
58
+ if(storage_engine_store_finalize(rd->tiers[tier].sch))
59
tiers_said_no_retention++;
60
61
- rd->tiers[tier].db_collection_handle = NULL;
61
+ rd->tiers[tier].sch = NULL;
62
}
63
}
64
@@ -275,7 +275,7 @@ restart_after_removal:
275
276
if (rrdhost_option_check(host, RRDHOST_OPTION_DELETE_ORPHAN_HOST)
277
/* don't delete multi-host DB host files */
278
- && !(host->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE && is_storage_engine_shared(host->db[0].instance))
278
+ && !(host->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE && is_storage_engine_shared(host->db[0].si))
279
) {
280
worker_is_busy(WORKER_JOB_DELETE_HOST_CHARTS);
281
rrdhost_delete_charts(host);
daemon/unit_test.c
+18
-18
@@ -1907,7 +1907,7 @@ static void test_dbengine_create_charts(RRDHOST *host, RRDSET *st[CHARTS], RRDDI
1907
// Flush pages for subsequent real values
1908
for (i = 0 ; i < CHARTS ; ++i) {
1909
for (j = 0; j < DIMS; ++j) {
1910
- rrdeng_store_metric_flush_current_page((rd[i][j])->tiers[0].db_collection_handle);
1910
+ rrdeng_store_metric_flush_current_page((rd[i][j])->tiers[0].sch);
1911
}
1912
}
1913
}
@@ -1926,7 +1926,7 @@ static time_t test_dbengine_create_metrics(RRDSET *st[CHARTS], RRDDIM *rd[CHARTS
1926
// feed it with the test data
1927
for (i = 0 ; i < CHARTS ; ++i) {
1928
for (j = 0 ; j < DIMS ; ++j) {
1929
- storage_engine_store_change_collection_frequency(rd[i][j]->tiers[0].db_collection_handle, update_every);
1929
+ storage_engine_store_change_collection_frequency(rd[i][j]->tiers[0].sch, update_every);
1930
1931
rd[i][j]->collector.last_collected_time.tv_sec =
1932
st[i]->last_collected_time.tv_sec = st[i]->last_updated.tv_sec = time_now;
@@ -1966,7 +1966,7 @@ static int test_dbengine_check_metrics(RRDSET *st[CHARTS], RRDDIM *rd[CHARTS][DI
1966
int i, j, k, c, errors, update_every;
1967
collected_number last;
1968
NETDATA_DOUBLE value, expected;
1969
- struct storage_engine_query_handle handle;
1969
+ struct storage_engine_query_handle seqh;
1970
size_t value_errors = 0, time_errors = 0;
1971
1972
update_every = REGION_UPDATE_EVERY[current_region];
@@ -1977,13 +1977,13 @@ static int test_dbengine_check_metrics(RRDSET *st[CHARTS], RRDDIM *rd[CHARTS][DI
1977
time_now = time_start + (c + 1) * update_every;
1978
for (i = 0 ; i < CHARTS ; ++i) {
1979
for (j = 0; j < DIMS; ++j) {
1980
- storage_engine_query_init(rd[i][j]->tiers[0].backend, rd[i][j]->tiers[0].db_metric_handle, &handle, time_now, time_now + QUERY_BATCH * update_every, STORAGE_PRIORITY_NORMAL);
1980
+ storage_engine_query_init(rd[i][j]->tiers[0].seb, rd[i][j]->tiers[0].smh, &seqh, time_now, time_now + QUERY_BATCH * update_every, STORAGE_PRIORITY_NORMAL);
1981
for (k = 0; k < QUERY_BATCH; ++k) {
1982
last = ((collected_number)i * DIMS) * REGION_POINTS[current_region] +
1983
j * REGION_POINTS[current_region] + c + k;
1984
expected = unpack_storage_number(pack_storage_number((NETDATA_DOUBLE)last, SN_DEFAULT_FLAGS));
1985
1986
- STORAGE_POINT sp = storage_engine_query_next_metric(&handle);
1986
+ STORAGE_POINT sp = storage_engine_query_next_metric(&seqh);
1987
value = sp.sum;
1988
time_retrieved = sp.start_time_s;
1989
end_time = sp.end_time_s;
@@ -2005,7 +2005,7 @@ static int test_dbengine_check_metrics(RRDSET *st[CHARTS], RRDDIM *rd[CHARTS][DI
2005
errors++;
2006
}
2007
}
2008
- storage_engine_query_finalize(&handle);
2008
+ storage_engine_query_finalize(&seqh);
2009
}
2010
}
2011
}
@@ -2143,7 +2143,7 @@ int test_dbengine(void)
2143
for (i = 0 ; i < CHARTS ; ++i) {
2144
st[i]->update_every = update_every;
2145
for (j = 0; j < DIMS; ++j) {
2146
- rrdeng_store_metric_flush_current_page((rd[i][j])->tiers[0].db_collection_handle);
2146
+ rrdeng_store_metric_flush_current_page((rd[i][j])->tiers[0].sch);
2147
}
2148
}
2149
@@ -2161,7 +2161,7 @@ int test_dbengine(void)
2161
for (i = 0 ; i < CHARTS ; ++i) {
2162
st[i]->update_every = update_every;
2163
for (j = 0; j < DIMS; ++j) {
2164
- rrdeng_store_metric_flush_current_page((rd[i][j])->tiers[0].db_collection_handle);
2164
+ rrdeng_store_metric_flush_current_page((rd[i][j])->tiers[0].sch);
2165
}
2166
}
2167
@@ -2237,9 +2237,9 @@ int test_dbengine(void)
2237
}
2238
2239
rrd_wrlock();
2240
- rrdeng_prepare_exit((struct rrdengine_instance *)host->db[0].instance);
2240
+ rrdeng_prepare_exit((struct rrdengine_instance *)host->db[0].si);
2241
rrdhost_delete_charts(host);
2242
- rrdeng_exit((struct rrdengine_instance *)host->db[0].instance);
2242
+ rrdeng_exit((struct rrdengine_instance *)host->db[0].si);
2243
rrdeng_enq_cmd(NULL, RRDENG_OPCODE_SHUTDOWN_EVLOOP, NULL, NULL, STORAGE_PRIORITY_BEST_EFFORT, NULL, NULL);
2244
rrd_unlock();
2245
@@ -2325,7 +2325,7 @@ static void generate_dbengine_chart(void *arg)
2325
thread_info->time_max = time_current;
2326
}
2327
for (j = 0; j < DSET_DIMS; ++j) {
2328
- rrdeng_store_metric_finalize((rd[j])->tiers[0].db_collection_handle);
2328
+ rrdeng_store_metric_finalize((rd[j])->tiers[0].sch);
2329
}
2330
}
2331
@@ -2418,7 +2418,7 @@ static void query_dbengine_chart(void *arg)
2418
time_t time_now, time_retrieved, end_time;
2419
collected_number generatedv;
2420
NETDATA_DOUBLE value, expected;
2421
- struct storage_engine_query_handle handle;
2421
+ struct storage_engine_query_handle seqh;
2422
size_t value_errors = 0, time_errors = 0;
2423
2424
do {
@@ -2445,13 +2445,13 @@ static void query_dbengine_chart(void *arg)
2445
time_before = MIN(time_after + duration, time_max); /* up to 1 hour queries */
2446
}
2447
2448
- storage_engine_query_init(rd->tiers[0].backend, rd->tiers[0].db_metric_handle, &handle, time_after, time_before, STORAGE_PRIORITY_NORMAL);
2448
+ storage_engine_query_init(rd->tiers[0].seb, rd->tiers[0].smh, &seqh, time_after, time_before, STORAGE_PRIORITY_NORMAL);
2449
++thread_info->queries_nr;
2450
for (time_now = time_after ; time_now <= time_before ; time_now += update_every) {
2451
generatedv = generate_dbengine_chart_value(i, j, time_now);
2452
expected = unpack_storage_number(pack_storage_number((NETDATA_DOUBLE) generatedv, SN_DEFAULT_FLAGS));
2453
2454
- if (unlikely(storage_engine_query_is_finished(&handle))) {
2454
+ if (unlikely(storage_engine_query_is_finished(&seqh))) {
2455
if (!thread_info->delete_old_data) { /* data validation only when we don't delete */
2456
fprintf(stderr, " DB-engine stresstest %s/%s: at %lu secs, expecting value " NETDATA_DOUBLE_FORMAT
2457
", found data gap, ### E R R O R ###\n",
@@ -2461,7 +2461,7 @@ static void query_dbengine_chart(void *arg)
2461
break;
2462
}
2463
2464
- STORAGE_POINT sp = storage_engine_query_next_metric(&handle);
2464
+ STORAGE_POINT sp = storage_engine_query_next_metric(&seqh);
2465
value = sp.sum;
2466
time_retrieved = sp.start_time_s;
2467
end_time = sp.end_time_s;
@@ -2499,7 +2499,7 @@ static void query_dbengine_chart(void *arg)
2499
}
2500
}
2501
}
2502
- storage_engine_query_finalize(&handle);
2502
+ storage_engine_query_finalize(&seqh);
2503
} while(!thread_info->done);
2504
2505
if(value_errors)
@@ -2647,9 +2647,9 @@ void dbengine_stress_test(unsigned TEST_DURATION_SEC, unsigned DSET_CHARTS, unsi
2647
}
2648
freez(query_threads);
2649
rrd_wrlock();
2650
- rrdeng_prepare_exit((struct rrdengine_instance *)host->db[0].instance);
2650
+ rrdeng_prepare_exit((struct rrdengine_instance *)host->db[0].si);
2651
rrdhost_delete_charts(host);
2652
- rrdeng_exit((struct rrdengine_instance *)host->db[0].instance);
2652
+ rrdeng_exit((struct rrdengine_instance *)host->db[0].si);
2653
rrdeng_enq_cmd(NULL, RRDENG_OPCODE_SHUTDOWN_EVLOOP, NULL, NULL, STORAGE_PRIORITY_BEST_EFFORT, NULL, NULL);
2654
rrd_unlock();
2655
}
database/contexts/api_v2.c
+4
-4
@@ -1019,10 +1019,10 @@ void buffer_json_agents_v2(BUFFER *wb, struct query_timings *timings, time_t now
1019
STORAGE_ENGINE *eng = localhost->db[tier].eng;
1020
if (!eng) continue;
1021
1022
- uint64_t max = storage_engine_disk_space_max(eng->backend, localhost->db[tier].instance);
1023
- uint64_t used = storage_engine_disk_space_used(eng->backend, localhost->db[tier].instance);
1024
- time_t first_time_s = storage_engine_global_first_time_s(eng->backend, localhost->db[tier].instance);
1025
- size_t currently_collected_metrics = storage_engine_collected_metrics(eng->backend, localhost->db[tier].instance);
1022
+ uint64_t max = storage_engine_disk_space_max(eng->seb, localhost->db[tier].si);
1023
+ uint64_t used = storage_engine_disk_space_used(eng->seb, localhost->db[tier].si);
1024
+ time_t first_time_s = storage_engine_global_first_time_s(eng->seb, localhost->db[tier].si);
1025
+ size_t currently_collected_metrics = storage_engine_collected_metrics(eng->seb, localhost->db[tier].si);
1026
1027
NETDATA_DOUBLE percent;
1028
if (used && max)
database/contexts/query_target.c
+13
-13
@@ -221,10 +221,10 @@ static inline void query_metric_release(QUERY_TARGET *qt, QUERY_METRIC *qm) {
221
222
// reset the tiers
223
for(size_t tier = 0; tier < storage_tiers ;tier++) {
224
- if(qm->tiers[tier].db_metric_handle) {
224
+ if(qm->tiers[tier].smh) {
225
STORAGE_ENGINE *eng = query_metric_storage_engine(qt, qm, tier);
226
- eng->api.metric_release(qm->tiers[tier].db_metric_handle);
227
- qm->tiers[tier].db_metric_handle = NULL;
226
+ eng->api.metric_release(qm->tiers[tier].smh);
227
+ qm->tiers[tier].smh = NULL;
228
}
229
}
230
}
@@ -241,7 +241,7 @@ static bool query_metric_add(QUERY_TARGET_LOCALS *qtl, QUERY_NODE *qn, QUERY_CON
241
242
struct {
243
STORAGE_ENGINE *eng;
244
- STORAGE_METRIC_HANDLE *db_metric_handle;
244
+ STORAGE_METRIC_HANDLE *smh;
245
time_t db_first_time_s;
246
time_t db_last_time_s;
247
time_t db_update_every_s;
@@ -252,14 +252,14 @@ static bool query_metric_add(QUERY_TARGET_LOCALS *qtl, QUERY_NODE *qn, QUERY_CON
252
tier_retention[tier].eng = eng;
253
tier_retention[tier].db_update_every_s = (time_t) (qn->rrdhost->db[tier].tier_grouping * ri->update_every_s);
254
255
- if(rm->rrddim && rm->rrddim->tiers[tier].db_metric_handle)
256
- tier_retention[tier].db_metric_handle = eng->api.metric_dup(rm->rrddim->tiers[tier].db_metric_handle);
255
+ if(rm->rrddim && rm->rrddim->tiers[tier].smh)
256
+ tier_retention[tier].smh = eng->api.metric_dup(rm->rrddim->tiers[tier].smh);
257
else
258
- tier_retention[tier].db_metric_handle = eng->api.metric_get(qn->rrdhost->db[tier].instance, &rm->uuid);
258
+ tier_retention[tier].smh = eng->api.metric_get(qn->rrdhost->db[tier].si, &rm->uuid);
259
260
- if(tier_retention[tier].db_metric_handle) {
261
- tier_retention[tier].db_first_time_s = storage_engine_oldest_time_s(tier_retention[tier].eng->backend, tier_retention[tier].db_metric_handle);
262
- tier_retention[tier].db_last_time_s = storage_engine_latest_time_s(tier_retention[tier].eng->backend, tier_retention[tier].db_metric_handle);
260
+ if(tier_retention[tier].smh) {
261
+ tier_retention[tier].db_first_time_s = storage_engine_oldest_time_s(tier_retention[tier].eng->seb, tier_retention[tier].smh);
262
+ tier_retention[tier].db_last_time_s = storage_engine_latest_time_s(tier_retention[tier].eng->seb, tier_retention[tier].smh);
263
264
if(!common_first_time_s)
265
common_first_time_s = tier_retention[tier].db_first_time_s;
@@ -331,7 +331,7 @@ static bool query_metric_add(QUERY_TARGET_LOCALS *qtl, QUERY_NODE *qn, QUERY_CON
331
332
for (size_t tier = 0; tier < storage_tiers; tier++) {
333
internal_fatal(tier_retention[tier].eng != query_metric_storage_engine(qt, qm, tier), "QUERY TARGET: storage engine mismatch");
334
- qm->tiers[tier].db_metric_handle = tier_retention[tier].db_metric_handle;
334
+ qm->tiers[tier].smh = tier_retention[tier].smh;
335
qm->tiers[tier].db_first_time_s = tier_retention[tier].db_first_time_s;
336
qm->tiers[tier].db_last_time_s = tier_retention[tier].db_last_time_s;
337
qm->tiers[tier].db_update_every_s = tier_retention[tier].db_update_every_s;
@@ -342,8 +342,8 @@ static bool query_metric_add(QUERY_TARGET_LOCALS *qtl, QUERY_NODE *qn, QUERY_CON
342
343
// cleanup anything we allocated to the retention we will not use
344
for(size_t tier = 0; tier < storage_tiers ;tier++) {
345
- if (tier_retention[tier].db_metric_handle)
346
- tier_retention[tier].eng->api.metric_release(tier_retention[tier].db_metric_handle);
345
+ if (tier_retention[tier].smh)
346
+ tier_retention[tier].eng->api.metric_release(tier_retention[tier].smh);
347
}
348
349
return false;
database/contexts/rrdcontext.h
+1
-1
@@ -210,7 +210,7 @@ typedef struct query_metric {
210
RRDR_DIMENSION_FLAGS status;
211
212
struct query_metric_tier {
213
- STORAGE_METRIC_HANDLE *db_metric_handle;
213
+ STORAGE_METRIC_HANDLE *smh;
214
time_t db_first_time_s; // the oldest timestamp available for this tier
215
time_t db_last_time_s; // the latest timestamp available for this tier
216
time_t db_update_every_s; // latest update every for this tier
database/contexts/worker.c
+1
-1
@@ -239,7 +239,7 @@ bool rrdmetric_update_retention(RRDMETRIC *rm) {
239
STORAGE_ENGINE *eng = rrdhost->db[tier].eng;
240
241
time_t first_time_t, last_time_t;
242
- if (eng->api.metric_retention_by_uuid(rrdhost->db[tier].instance, &rm->uuid, &first_time_t, &last_time_t)) {
242
+ if (eng->api.metric_retention_by_uuid(rrdhost->db[tier].si, &rm->uuid, &first_time_t, &last_time_t)) {
243
if (first_time_t < min_first_time_t)
244
min_first_time_t = first_time_t;
245
database/engine/rrdengineapi.c
+87
-87
@@ -74,14 +74,14 @@ static inline bool rrdeng_page_alignment_release(struct pg_alignment *pa) {
74
}
75
76
// charts call this
77
-STORAGE_METRICS_GROUP *rrdeng_metrics_group_get(STORAGE_INSTANCE *db_instance __maybe_unused, uuid_t *uuid __maybe_unused) {
77
+STORAGE_METRICS_GROUP *rrdeng_metrics_group_get(STORAGE_INSTANCE *si __maybe_unused, uuid_t *uuid __maybe_unused) {
78
struct pg_alignment *pa = callocz(1, sizeof(struct pg_alignment));
79
rrdeng_page_alignment_acquire(pa);
80
return (STORAGE_METRICS_GROUP *)pa;
81
}
82
83
// charts call this
84
-void rrdeng_metrics_group_release(STORAGE_INSTANCE *db_instance __maybe_unused, STORAGE_METRICS_GROUP *smg) {
84
+void rrdeng_metrics_group_release(STORAGE_INSTANCE *si __maybe_unused, STORAGE_METRICS_GROUP *smg) {
85
if(unlikely(!smg)) return;
86
87
struct pg_alignment *pa = (struct pg_alignment *)smg;
@@ -108,8 +108,8 @@ void rrdeng_generate_legacy_uuid(const char *dim_id, const char *chart_id, uuid_
108
memcpy(ret_uuid, hash_value, sizeof(uuid_t));
109
}
110
111
-static METRIC *rrdeng_metric_get_legacy(STORAGE_INSTANCE *db_instance, const char *rd_id, const char *st_id) {
112
- struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
111
+static METRIC *rrdeng_metric_get_legacy(STORAGE_INSTANCE *si, const char *rd_id, const char *st_id) {
112
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *)si;
113
uuid_t legacy_uuid;
114
rrdeng_generate_legacy_uuid(rd_id, st_id, &legacy_uuid);
115
return mrg_metric_get_and_acquire(main_mrg, &legacy_uuid, (Word_t) ctx);
@@ -118,25 +118,25 @@ static METRIC *rrdeng_metric_get_legacy(STORAGE_INSTANCE *db_instance, const cha
118
// ----------------------------------------------------------------------------
119
// metric handle
120
121
-void rrdeng_metric_release(STORAGE_METRIC_HANDLE *db_metric_handle) {
122
- METRIC *metric = (METRIC *)db_metric_handle;
121
+void rrdeng_metric_release(STORAGE_METRIC_HANDLE *smh) {
122
+ METRIC *metric = (METRIC *)smh;
123
mrg_metric_release(main_mrg, metric);
124
}
125
126
-STORAGE_METRIC_HANDLE *rrdeng_metric_dup(STORAGE_METRIC_HANDLE *db_metric_handle) {
127
- METRIC *metric = (METRIC *)db_metric_handle;
126
+STORAGE_METRIC_HANDLE *rrdeng_metric_dup(STORAGE_METRIC_HANDLE *smh) {
127
+ METRIC *metric = (METRIC *)smh;
128
return (STORAGE_METRIC_HANDLE *) mrg_metric_dup(main_mrg, metric);
129
}
130
131
-STORAGE_METRIC_HANDLE *rrdeng_metric_get(STORAGE_INSTANCE *db_instance, uuid_t *uuid) {
132
- struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
131
+STORAGE_METRIC_HANDLE *rrdeng_metric_get(STORAGE_INSTANCE *si, uuid_t *uuid) {
132
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *)si;
133
return (STORAGE_METRIC_HANDLE *) mrg_metric_get_and_acquire(main_mrg, uuid, (Word_t) ctx);
134
}
135
136
-static METRIC *rrdeng_metric_create(STORAGE_INSTANCE *db_instance, uuid_t *uuid) {
137
- internal_fatal(!db_instance, "DBENGINE: db_instance is NULL");
136
+static METRIC *rrdeng_metric_create(STORAGE_INSTANCE *si, uuid_t *uuid) {
137
+ internal_fatal(!si, "DBENGINE: STORAGE_INSTANCE is NULL");
138
139
- struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
139
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *)si;
140
MRG_ENTRY entry = {
141
.uuid = uuid,
142
.section = (Word_t)ctx,
@@ -149,8 +149,8 @@ static METRIC *rrdeng_metric_create(STORAGE_INSTANCE *db_instance, uuid_t *uuid)
149
return metric;
150
}
151
152
-STORAGE_METRIC_HANDLE *rrdeng_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE *db_instance) {
153
- struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
152
+STORAGE_METRIC_HANDLE *rrdeng_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE *si) {
153
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *)si;
154
METRIC *metric;
155
156
metric = mrg_metric_get_and_acquire(main_mrg, &rd->metric_uuid, (Word_t) ctx);
@@ -160,13 +160,13 @@ STORAGE_METRIC_HANDLE *rrdeng_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE
160
// this is a single host database
161
// generate uuid from the chart and dimensions ids
162
// and overwrite the one supplied by rrddim
163
- metric = rrdeng_metric_get_legacy(db_instance, rrddim_id(rd), rrdset_id(rd->rrdset));
163
+ metric = rrdeng_metric_get_legacy(si, rrddim_id(rd), rrdset_id(rd->rrdset));
164
if (metric)
165
uuid_copy(rd->metric_uuid, *mrg_metric_uuid(main_mrg, metric));
166
}
167
168
if(likely(!metric))
169
- metric = rrdeng_metric_create(db_instance, &rd->metric_uuid);
169
+ metric = rrdeng_metric_create(si, &rd->metric_uuid);
170
}
171
172
#ifdef NETDATA_INTERNAL_CHECKS
@@ -245,8 +245,8 @@ static inline bool check_completed_page_consistency(struct rrdeng_collect_handle
245
* Gets a handle for storing metrics to the database.
246
* The handle must be released with rrdeng_store_metric_final().
247
*/
248
-STORAGE_COLLECT_HANDLE *rrdeng_store_metric_init(STORAGE_METRIC_HANDLE *db_metric_handle, uint32_t update_every, STORAGE_METRICS_GROUP *smg) {
249
- METRIC *metric = (METRIC *)db_metric_handle;
248
+STORAGE_COLLECT_HANDLE *rrdeng_store_metric_init(STORAGE_METRIC_HANDLE *smh, uint32_t update_every, STORAGE_METRICS_GROUP *smg) {
249
+ METRIC *metric = (METRIC *)smh;
250
struct rrdengine_instance *ctx = mrg_metric_ctx(metric);
251
252
bool is_1st_metric_writer = true;
@@ -262,7 +262,7 @@ STORAGE_COLLECT_HANDLE *rrdeng_store_metric_init(STORAGE_METRIC_HANDLE *db_metri
262
struct rrdeng_collect_handle *handle;
263
264
handle = callocz(1, sizeof(struct rrdeng_collect_handle));
265
- handle->common.backend = STORAGE_ENGINE_BACKEND_DBENGINE;
265
+ handle->common.seb = STORAGE_ENGINE_BACKEND_DBENGINE;
266
handle->metric = metric;
267
268
handle->pgc_page = NULL;
@@ -295,8 +295,8 @@ STORAGE_COLLECT_HANDLE *rrdeng_store_metric_init(STORAGE_METRIC_HANDLE *db_metri
295
return (STORAGE_COLLECT_HANDLE *)handle;
296
}
297
298
-void rrdeng_store_metric_flush_current_page(STORAGE_COLLECT_HANDLE *collection_handle) {
299
- struct rrdeng_collect_handle *handle = (struct rrdeng_collect_handle *)collection_handle;
298
+void rrdeng_store_metric_flush_current_page(STORAGE_COLLECT_HANDLE *sch) {
299
+ struct rrdeng_collect_handle *handle = (struct rrdeng_collect_handle *)sch;
300
301
if (unlikely(!handle->pgc_page))
302
return;
@@ -461,7 +461,7 @@ static PGD *rrdeng_alloc_new_page_data(struct rrdeng_collect_handle *handle, siz
461
return d;
462
}
463
464
-static void rrdeng_store_metric_append_point(STORAGE_COLLECT_HANDLE *collection_handle,
464
+static void rrdeng_store_metric_append_point(STORAGE_COLLECT_HANDLE *sch,
465
const usec_t point_in_time_ut,
466
const NETDATA_DOUBLE n,
467
const NETDATA_DOUBLE min_value,
@@ -470,7 +470,7 @@ static void rrdeng_store_metric_append_point(STORAGE_COLLECT_HANDLE *collection_
470
const uint16_t anomaly_count,
471
const SN_FLAGS flags)
472
{
473
- struct rrdeng_collect_handle *handle = (struct rrdeng_collect_handle *)collection_handle;
473
+ struct rrdeng_collect_handle *handle = (struct rrdeng_collect_handle *)sch;
474
struct rrdengine_instance *ctx = mrg_metric_ctx(handle->metric);
475
476
if(unlikely(!handle->page_data))
@@ -497,7 +497,7 @@ static void rrdeng_store_metric_append_point(STORAGE_COLLECT_HANDLE *collection_
497
if(unlikely(++handle->page_position >= handle->page_entries_max)) {
498
internal_fatal(handle->page_position > handle->page_entries_max, "DBENGINE: exceeded page max number of points");
499
handle->page_flags |= RRDENG_PAGE_FULL;
500
- rrdeng_store_metric_flush_current_page(collection_handle);
500
+ rrdeng_store_metric_flush_current_page(sch);
501
}
502
}
503
@@ -543,7 +543,7 @@ static void store_metric_next_error_log(struct rrdeng_collect_handle *handle __m
543
#endif
544
}
545
546
-void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *collection_handle,
546
+void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *sch,
547
const usec_t point_in_time_ut,
548
const NETDATA_DOUBLE n,
549
const NETDATA_DOUBLE min_value,
@@ -554,7 +554,7 @@ void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *collection_handle,
554
{
555
timing_step(TIMING_STEP_RRDSET_STORE_METRIC);
556
557
- struct rrdeng_collect_handle *handle = (struct rrdeng_collect_handle *)collection_handle;
557
+ struct rrdeng_collect_handle *handle = (struct rrdeng_collect_handle *)sch;
558
559
#ifdef NETDATA_INTERNAL_CHECKS
560
if(unlikely(point_in_time_ut > (usec_t)max_acceptable_collected_time() * USEC_PER_SEC))
@@ -571,11 +571,11 @@ void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *collection_handle,
571
if(handle->pgc_page) {
572
if (unlikely(delta_ut < handle->update_every_ut)) {
573
handle->page_flags |= RRDENG_PAGE_STEP_TOO_SMALL;
574
- rrdeng_store_metric_flush_current_page(collection_handle);
574
+ rrdeng_store_metric_flush_current_page(sch);
575
}
576
else if (unlikely(delta_ut % handle->update_every_ut)) {
577
handle->page_flags |= RRDENG_PAGE_STEP_UNALIGNED;
578
- rrdeng_store_metric_flush_current_page(collection_handle);
578
+ rrdeng_store_metric_flush_current_page(sch);
579
}
580
else {
581
size_t points_gap = delta_ut / handle->update_every_ut;
@@ -583,7 +583,7 @@ void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *collection_handle,
583
584
if (points_gap >= page_remaining_points) {
585
handle->page_flags |= RRDENG_PAGE_BIG_GAP;
586
- rrdeng_store_metric_flush_current_page(collection_handle);
586
+ rrdeng_store_metric_flush_current_page(sch);
587
}
588
else {
589
// loop to fill the gap
@@ -594,7 +594,7 @@ void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *collection_handle,
594
this_ut <= stop_ut;
595
this_ut = handle->page_end_time_ut + handle->update_every_ut) {
596
rrdeng_store_metric_append_point(
597
- collection_handle,
597
+ sch,
598
this_ut,
599
NAN, NAN, NAN,
600
1, 0,
@@ -618,7 +618,7 @@ void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *collection_handle,
618
619
timing_step(TIMING_STEP_DBENGINE_FIRST_CHECK);
620
621
- rrdeng_store_metric_append_point(collection_handle,
621
+ rrdeng_store_metric_append_point(sch,
622
point_in_time_ut,
623
n, min_value, max_value,
624
count, anomaly_count,
@@ -629,12 +629,12 @@ void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *collection_handle,
629
* Releases the database reference from the handle for storing metrics.
630
* Returns 1 if it's safe to delete the dimension.
631
*/
632
-int rrdeng_store_metric_finalize(STORAGE_COLLECT_HANDLE *collection_handle) {
633
- struct rrdeng_collect_handle *handle = (struct rrdeng_collect_handle *)collection_handle;
632
+int rrdeng_store_metric_finalize(STORAGE_COLLECT_HANDLE *sch) {
633
+ struct rrdeng_collect_handle *handle = (struct rrdeng_collect_handle *)sch;
634
struct rrdengine_instance *ctx = mrg_metric_ctx(handle->metric);
635
636
handle->page_flags |= RRDENG_PAGE_COLLECT_FINALIZE;
637
- rrdeng_store_metric_flush_current_page(collection_handle);
637
+ rrdeng_store_metric_flush_current_page(sch);
638
rrdeng_page_alignment_release(handle->alignment);
639
640
__atomic_sub_fetch(&ctx->atomic.collectors_running, 1, __ATOMIC_RELAXED);
@@ -656,8 +656,8 @@ int rrdeng_store_metric_finalize(STORAGE_COLLECT_HANDLE *collection_handle) {
656
return 0;
657
}
658
659
-void rrdeng_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *collection_handle, int update_every) {
660
- struct rrdeng_collect_handle *handle = (struct rrdeng_collect_handle *)collection_handle;
659
+void rrdeng_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *sch, int update_every) {
660
+ struct rrdeng_collect_handle *handle = (struct rrdeng_collect_handle *)sch;
661
check_and_fix_mrg_update_every(handle);
662
663
METRIC *metric = handle->metric;
@@ -667,7 +667,7 @@ void rrdeng_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *col
667
return;
668
669
handle->page_flags |= RRDENG_PAGE_UPDATE_EVERY_CHANGE;
670
- rrdeng_store_metric_flush_current_page(collection_handle);
670
+ rrdeng_store_metric_flush_current_page(sch);
671
mrg_metric_set_update_every(main_mrg, metric, update_every);
672
handle->update_every_ut = update_every_ut;
673
}
@@ -704,8 +704,8 @@ static void unregister_query_handle(struct rrdeng_query_handle *handle __maybe_u
704
* Gets a handle for loading metrics from the database.
705
* The handle must be released with rrdeng_load_metric_final().
706
*/
707
-void rrdeng_load_metric_init(STORAGE_METRIC_HANDLE *db_metric_handle,
708
- struct storage_engine_query_handle *rrddim_handle,
707
+void rrdeng_load_metric_init(STORAGE_METRIC_HANDLE *smh,
708
+ struct storage_engine_query_handle *seqh,
709
time_t start_time_s,
710
time_t end_time_s,
711
STORAGE_PRIORITY priority)
@@ -714,7 +714,7 @@ void rrdeng_load_metric_init(STORAGE_METRIC_HANDLE *db_metric_handle,
714
715
netdata_thread_disable_cancelability();
716
717
- METRIC *metric = (METRIC *)db_metric_handle;
717
+ METRIC *metric = (METRIC *)smh;
718
struct rrdengine_instance *ctx = mrg_metric_ctx(metric);
719
struct rrdeng_query_handle *handle;
720
@@ -751,11 +751,11 @@ void rrdeng_load_metric_init(STORAGE_METRIC_HANDLE *db_metric_handle,
751
mrg_metric_set_update_every_s_if_zero(main_mrg, metric, default_rrd_update_every);
752
}
753
754
- rrddim_handle->handle = (STORAGE_QUERY_HANDLE *) handle;
755
- rrddim_handle->start_time_s = handle->start_time_s;
756
- rrddim_handle->end_time_s = handle->end_time_s;
757
- rrddim_handle->priority = priority;
758
- rrddim_handle->backend = STORAGE_ENGINE_BACKEND_DBENGINE;
754
+ seqh->handle = (STORAGE_QUERY_HANDLE *) handle;
755
+ seqh->start_time_s = handle->start_time_s;
756
+ seqh->end_time_s = handle->end_time_s;
757
+ seqh->priority = priority;
758
+ seqh->seb = STORAGE_ENGINE_BACKEND_DBENGINE;
759
760
pg_cache_preload(handle);
761
@@ -767,16 +767,16 @@ void rrdeng_load_metric_init(STORAGE_METRIC_HANDLE *db_metric_handle,
767
handle->now_s = start_time_s;
768
handle->dt_s = db_update_every_s;
769
770
- rrddim_handle->handle = (STORAGE_QUERY_HANDLE *) handle;
771
- rrddim_handle->start_time_s = handle->start_time_s;
772
- rrddim_handle->end_time_s = 0;
773
- rrddim_handle->priority = priority;
774
- rrddim_handle->backend = STORAGE_ENGINE_BACKEND_DBENGINE;
770
+ seqh->handle = (STORAGE_QUERY_HANDLE *) handle;
771
+ seqh->start_time_s = handle->start_time_s;
772
+ seqh->end_time_s = 0;
773
+ seqh->priority = priority;
774
+ seqh->seb = STORAGE_ENGINE_BACKEND_DBENGINE;
775
}
776
}
777
778
-static bool rrdeng_load_page_next(struct storage_engine_query_handle *rrddim_handle, bool debug_this __maybe_unused) {
779
- struct rrdeng_query_handle *handle = (struct rrdeng_query_handle *)rrddim_handle->handle;
778
+static bool rrdeng_load_page_next(struct storage_engine_query_handle *seqh, bool debug_this __maybe_unused) {
779
+ struct rrdeng_query_handle *handle = (struct rrdeng_query_handle *)seqh->handle;
780
struct rrdengine_instance *ctx = mrg_metric_ctx(handle->metric);
781
782
if (likely(handle->page)) {
@@ -786,7 +786,7 @@ static bool rrdeng_load_page_next(struct storage_engine_query_handle *rrddim_han
786
pgdc_reset(&handle->pgdc, NULL, UINT32_MAX);
787
}
788
789
- if (unlikely(handle->now_s > rrddim_handle->end_time_s))
789
+ if (unlikely(handle->now_s > seqh->end_time_s))
790
return false;
791
792
size_t entries = 0;
@@ -846,11 +846,11 @@ static bool rrdeng_load_page_next(struct storage_engine_query_handle *rrddim_han
846
// Returns the metric and sets its timestamp into current_time
847
// IT IS REQUIRED TO **ALWAYS** SET ALL RETURN VALUES (current_time, end_time, flags)
848
// IT IS REQUIRED TO **ALWAYS** KEEP TRACK OF TIME, EVEN OUTSIDE THE DATABASE BOUNDARIES
849
-STORAGE_POINT rrdeng_load_metric_next(struct storage_engine_query_handle *rrddim_handle) {
850
- struct rrdeng_query_handle *handle = (struct rrdeng_query_handle *)rrddim_handle->handle;
849
+STORAGE_POINT rrdeng_load_metric_next(struct storage_engine_query_handle *seqh) {
850
+ struct rrdeng_query_handle *handle = (struct rrdeng_query_handle *)seqh->handle;
851
STORAGE_POINT sp;
852
853
- if (unlikely(handle->now_s > rrddim_handle->end_time_s)) {
853
+ if (unlikely(handle->now_s > seqh->end_time_s)) {
854
storage_point_empty(sp, handle->now_s - handle->dt_s, handle->now_s);
855
goto prepare_for_next_iteration;
856
}
@@ -858,8 +858,8 @@ STORAGE_POINT rrdeng_load_metric_next(struct storage_engine_query_handle *rrddim
858
if (unlikely(!handle->page || handle->position >= handle->entries)) {
859
// We need to get a new page
860
861
- if (!rrdeng_load_page_next(rrddim_handle, false)) {
862
- handle->now_s = rrddim_handle->end_time_s;
861
+ if (!rrdeng_load_page_next(seqh, false)) {
862
+ handle->now_s = seqh->end_time_s;
863
storage_point_empty(sp, handle->now_s - handle->dt_s, handle->now_s);
864
goto prepare_for_next_iteration;
865
}
@@ -871,7 +871,7 @@ STORAGE_POINT rrdeng_load_metric_next(struct storage_engine_query_handle *rrddim
871
pgdc_get_next_point(&handle->pgdc, handle->position, &sp);
872
873
prepare_for_next_iteration:
874
- internal_fatal(sp.end_time_s < rrddim_handle->start_time_s, "DBENGINE: this point is too old for this query");
874
+ internal_fatal(sp.end_time_s < seqh->start_time_s, "DBENGINE: this point is too old for this query");
875
internal_fatal(sp.end_time_s < handle->now_s, "DBENGINE: this point is too old for this point in time");
876
877
handle->now_s += handle->dt_s;
@@ -880,17 +880,17 @@ prepare_for_next_iteration:
880
return sp;
881
}
882
883
-int rrdeng_load_metric_is_finished(struct storage_engine_query_handle *rrddim_handle) {
884
- struct rrdeng_query_handle *handle = (struct rrdeng_query_handle *)rrddim_handle->handle;
885
- return (handle->now_s > rrddim_handle->end_time_s);
883
+int rrdeng_load_metric_is_finished(struct storage_engine_query_handle *seqh) {
884
+ struct rrdeng_query_handle *handle = (struct rrdeng_query_handle *)seqh->handle;
885
+ return (handle->now_s > seqh->end_time_s);
886
}
887
888
/*
889
* Releases the database reference from the handle for loading metrics.
890
*/
891
-void rrdeng_load_metric_finalize(struct storage_engine_query_handle *rrddim_handle)
891
+void rrdeng_load_metric_finalize(struct storage_engine_query_handle *seqh)
892
{
893
- struct rrdeng_query_handle *handle = (struct rrdeng_query_handle *)rrddim_handle->handle;
893
+ struct rrdeng_query_handle *handle = (struct rrdeng_query_handle *)seqh->handle;
894
895
if (handle->page) {
896
pgc_page_release(main_cache, handle->page);
@@ -902,24 +902,24 @@ void rrdeng_load_metric_finalize(struct storage_engine_query_handle *rrddim_hand
902
903
unregister_query_handle(handle);
904
rrdeng_query_handle_release(handle);
905
- rrddim_handle->handle = NULL;
905
+ seqh->handle = NULL;
906
netdata_thread_enable_cancelability();
907
}
908
909
-time_t rrdeng_load_align_to_optimal_before(struct storage_engine_query_handle *rrddim_handle) {
910
- struct rrdeng_query_handle *handle = (struct rrdeng_query_handle *)rrddim_handle->handle;
909
+time_t rrdeng_load_align_to_optimal_before(struct storage_engine_query_handle *seqh) {
910
+ struct rrdeng_query_handle *handle = (struct rrdeng_query_handle *)seqh->handle;
911
912
if(handle->pdc) {
913
rrdeng_prep_wait(handle->pdc);
914
- if (handle->pdc->optimal_end_time_s > rrddim_handle->end_time_s)
915
- rrddim_handle->end_time_s = handle->pdc->optimal_end_time_s;
914
+ if (handle->pdc->optimal_end_time_s > seqh->end_time_s)
915
+ seqh->end_time_s = handle->pdc->optimal_end_time_s;
916
}
917
918
- return rrddim_handle->end_time_s;
918
+ return seqh->end_time_s;
919
}
920
921
-time_t rrdeng_metric_latest_time(STORAGE_METRIC_HANDLE *db_metric_handle) {
922
- METRIC *metric = (METRIC *)db_metric_handle;
921
+time_t rrdeng_metric_latest_time(STORAGE_METRIC_HANDLE *smh) {
922
+ METRIC *metric = (METRIC *)smh;
923
time_t latest_time_s = 0;
924
925
if (metric)
@@ -928,8 +928,8 @@ time_t rrdeng_metric_latest_time(STORAGE_METRIC_HANDLE *db_metric_handle) {
928
return latest_time_s;
929
}
930
931
-time_t rrdeng_metric_oldest_time(STORAGE_METRIC_HANDLE *db_metric_handle) {
932
- METRIC *metric = (METRIC *)db_metric_handle;
931
+time_t rrdeng_metric_oldest_time(STORAGE_METRIC_HANDLE *smh) {
932
+ METRIC *metric = (METRIC *)smh;
933
934
time_t oldest_time_s = 0;
935
if (metric)
@@ -938,9 +938,9 @@ time_t rrdeng_metric_oldest_time(STORAGE_METRIC_HANDLE *db_metric_handle) {
938
return oldest_time_s;
939
}
940
941
-bool rrdeng_metric_retention_by_uuid(STORAGE_INSTANCE *db_instance, uuid_t *dim_uuid, time_t *first_entry_s, time_t *last_entry_s)
941
+bool rrdeng_metric_retention_by_uuid(STORAGE_INSTANCE *si, uuid_t *dim_uuid, time_t *first_entry_s, time_t *last_entry_s)
942
{
943
- struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
943
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *)si;
944
if (unlikely(!ctx)) {
945
netdata_log_error("DBENGINE: invalid STORAGE INSTANCE to %s()", __FUNCTION__);
946
return false;
@@ -957,18 +957,18 @@ bool rrdeng_metric_retention_by_uuid(STORAGE_INSTANCE *db_instance, uuid_t *dim_
957
return true;
958
}
959
960
-uint64_t rrdeng_disk_space_max(STORAGE_INSTANCE *db_instance) {
961
- struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
960
+uint64_t rrdeng_disk_space_max(STORAGE_INSTANCE *si) {
961
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *)si;
962
return ctx->config.max_disk_space;
963
}
964
965
-uint64_t rrdeng_disk_space_used(STORAGE_INSTANCE *db_instance) {
966
- struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
965
+uint64_t rrdeng_disk_space_used(STORAGE_INSTANCE *si) {
966
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *)si;
967
return __atomic_load_n(&ctx->atomic.current_disk_space, __ATOMIC_RELAXED);
968
}
969
970
-time_t rrdeng_global_first_time_s(STORAGE_INSTANCE *db_instance) {
971
- struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
970
+time_t rrdeng_global_first_time_s(STORAGE_INSTANCE *si) {
971
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *)si;
972
973
time_t t = __atomic_load_n(&ctx->atomic.first_time_s, __ATOMIC_RELAXED);
974
if(t == LONG_MAX || t < 0)
@@ -977,8 +977,8 @@ time_t rrdeng_global_first_time_s(STORAGE_INSTANCE *db_instance) {
977
return t;
978
}
979
980
-size_t rrdeng_currently_collected_metrics(STORAGE_INSTANCE *db_instance) {
981
- struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
980
+size_t rrdeng_currently_collected_metrics(STORAGE_INSTANCE *si) {
981
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *)si;
982
return __atomic_load_n(&ctx->atomic.collectors_running, __ATOMIC_RELAXED);
983
}
984
@@ -1099,8 +1099,8 @@ void rrdeng_readiness_wait(struct rrdengine_instance *ctx) {
1099
netdata_log_info("DBENGINE: tier %d is ready for data collection and queries", ctx->config.tier);
1100
}
1101
1102
-bool rrdeng_is_legacy(STORAGE_INSTANCE *db_instance) {
1103
- struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
1102
+bool rrdeng_is_legacy(STORAGE_INSTANCE *si) {
1103
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *)si;
1104
return ctx->config.legacy;
1105
}
1106
database/engine/rrdengineapi.h
+23
-23
@@ -26,32 +26,32 @@ extern uint8_t tier_page_type[];
26
27
void rrdeng_generate_legacy_uuid(const char *dim_id, const char *chart_id, uuid_t *ret_uuid);
28
29
-STORAGE_METRIC_HANDLE *rrdeng_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE *db_instance);
30
-STORAGE_METRIC_HANDLE *rrdeng_metric_get(STORAGE_INSTANCE *db_instance, uuid_t *uuid);
31
-void rrdeng_metric_release(STORAGE_METRIC_HANDLE *db_metric_handle);
32
-STORAGE_METRIC_HANDLE *rrdeng_metric_dup(STORAGE_METRIC_HANDLE *db_metric_handle);
33
-
34
-STORAGE_COLLECT_HANDLE *rrdeng_store_metric_init(STORAGE_METRIC_HANDLE *db_metric_handle, uint32_t update_every, STORAGE_METRICS_GROUP *smg);
35
-void rrdeng_store_metric_flush_current_page(STORAGE_COLLECT_HANDLE *collection_handle);
36
-void rrdeng_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *collection_handle, int update_every);
37
-void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *collection_handle, usec_t point_in_time_ut, NETDATA_DOUBLE n,
29
+STORAGE_METRIC_HANDLE *rrdeng_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE *si);
30
+STORAGE_METRIC_HANDLE *rrdeng_metric_get(STORAGE_INSTANCE *si, uuid_t *uuid);
31
+void rrdeng_metric_release(STORAGE_METRIC_HANDLE *smh);
32
+STORAGE_METRIC_HANDLE *rrdeng_metric_dup(STORAGE_METRIC_HANDLE *smh);
33
+
34
+STORAGE_COLLECT_HANDLE *rrdeng_store_metric_init(STORAGE_METRIC_HANDLE *smh, uint32_t update_every, STORAGE_METRICS_GROUP *smg);
35
+void rrdeng_store_metric_flush_current_page(STORAGE_COLLECT_HANDLE *sch);
36
+void rrdeng_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *sch, int update_every);
37
+void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *sch, usec_t point_in_time_ut, NETDATA_DOUBLE n,
38
NETDATA_DOUBLE min_value,
39
NETDATA_DOUBLE max_value,
40
uint16_t count,
41
uint16_t anomaly_count,
42
SN_FLAGS flags);
43
-int rrdeng_store_metric_finalize(STORAGE_COLLECT_HANDLE *collection_handle);
43
+int rrdeng_store_metric_finalize(STORAGE_COLLECT_HANDLE *sch);
44
45
-void rrdeng_load_metric_init(STORAGE_METRIC_HANDLE *db_metric_handle, struct storage_engine_query_handle *rrddim_handle,
45
+void rrdeng_load_metric_init(STORAGE_METRIC_HANDLE *smh, struct storage_engine_query_handle *seqh,
46
time_t start_time_s, time_t end_time_s, STORAGE_PRIORITY priority);
47
-STORAGE_POINT rrdeng_load_metric_next(struct storage_engine_query_handle *rrddim_handle);
47
+STORAGE_POINT rrdeng_load_metric_next(struct storage_engine_query_handle *seqh);
48
49
50
-int rrdeng_load_metric_is_finished(struct storage_engine_query_handle *rrddim_handle);
51
-void rrdeng_load_metric_finalize(struct storage_engine_query_handle *rrddim_handle);
52
-time_t rrdeng_metric_latest_time(STORAGE_METRIC_HANDLE *db_metric_handle);
53
-time_t rrdeng_metric_oldest_time(STORAGE_METRIC_HANDLE *db_metric_handle);
54
-time_t rrdeng_load_align_to_optimal_before(struct storage_engine_query_handle *rrddim_handle);
50
+int rrdeng_load_metric_is_finished(struct storage_engine_query_handle *seqh);
51
+void rrdeng_load_metric_finalize(struct storage_engine_query_handle *seqh);
52
+time_t rrdeng_metric_latest_time(STORAGE_METRIC_HANDLE *smh);
53
+time_t rrdeng_metric_oldest_time(STORAGE_METRIC_HANDLE *smh);
54
+time_t rrdeng_load_align_to_optimal_before(struct storage_engine_query_handle *seqh);
55
56
void rrdeng_get_37_statistics(struct rrdengine_instance *ctx, unsigned long long *array);
57
@@ -64,10 +64,10 @@ void rrdeng_exit_mode(struct rrdengine_instance *ctx);
64
65
int rrdeng_exit(struct rrdengine_instance *ctx);
66
void rrdeng_prepare_exit(struct rrdengine_instance *ctx);
67
-bool rrdeng_metric_retention_by_uuid(STORAGE_INSTANCE *db_instance, uuid_t *dim_uuid, time_t *first_entry_s, time_t *last_entry_s);
67
+bool rrdeng_metric_retention_by_uuid(STORAGE_INSTANCE *si, uuid_t *dim_uuid, time_t *first_entry_s, time_t *last_entry_s);
68
69
-extern STORAGE_METRICS_GROUP *rrdeng_metrics_group_get(STORAGE_INSTANCE *db_instance, uuid_t *uuid);
70
-extern void rrdeng_metrics_group_release(STORAGE_INSTANCE *db_instance, STORAGE_METRICS_GROUP *smg);
69
+extern STORAGE_METRICS_GROUP *rrdeng_metrics_group_get(STORAGE_INSTANCE *si, uuid_t *uuid);
70
+extern void rrdeng_metrics_group_release(STORAGE_INSTANCE *si, STORAGE_METRICS_GROUP *smg);
71
72
typedef struct rrdengine_size_statistics {
73
size_t default_granularity_secs;
@@ -221,9 +221,9 @@ struct rrdeng_cache_efficiency_stats rrdeng_get_cache_efficiency_stats(void);
221
222
RRDENG_SIZE_STATS rrdeng_size_statistics(struct rrdengine_instance *ctx);
223
size_t rrdeng_collectors_running(struct rrdengine_instance *ctx);
224
-bool rrdeng_is_legacy(STORAGE_INSTANCE *db_instance);
224
+bool rrdeng_is_legacy(STORAGE_INSTANCE *si);
225
226
-uint64_t rrdeng_disk_space_max(STORAGE_INSTANCE *db_instance);
227
-uint64_t rrdeng_disk_space_used(STORAGE_INSTANCE *db_instance);
226
+uint64_t rrdeng_disk_space_max(STORAGE_INSTANCE *si);
227
+uint64_t rrdeng_disk_space_used(STORAGE_INSTANCE *si);
228
229
#endif /* NETDATA_RRDENGINEAPI_H */
database/ram/rrddim_mem.c
+73
-73
@@ -9,11 +9,11 @@ static netdata_rwlock_t rrddim_JudyHS_rwlock = NETDATA_RWLOCK_INITIALIZER;
9
// ----------------------------------------------------------------------------
10
// metrics groups
11
12
-STORAGE_METRICS_GROUP *rrddim_metrics_group_get(STORAGE_INSTANCE *db_instance __maybe_unused, uuid_t *uuid __maybe_unused) {
12
+STORAGE_METRICS_GROUP *rrddim_metrics_group_get(STORAGE_INSTANCE *si __maybe_unused, uuid_t *uuid __maybe_unused) {
13
return NULL;
14
}
15
16
-void rrddim_metrics_group_release(STORAGE_INSTANCE *db_instance __maybe_unused, STORAGE_METRICS_GROUP *smg __maybe_unused) {
16
+void rrddim_metrics_group_release(STORAGE_INSTANCE *si __maybe_unused, STORAGE_METRICS_GROUP *smg __maybe_unused) {
17
// if(!smg) return; // smg may be NULL
18
;
19
}
@@ -48,8 +48,8 @@ static void check_metric_handle_from_rrddim(struct mem_metric_handle *mh) {
48
}
49
50
STORAGE_METRIC_HANDLE *
51
-rrddim_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE *db_instance __maybe_unused) {
52
- struct mem_metric_handle *mh = (struct mem_metric_handle *)rrddim_metric_get(db_instance, &rd->metric_uuid);
51
+rrddim_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE *si __maybe_unused) {
52
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)rrddim_metric_get(si, &rd->metric_uuid);
53
while(!mh) {
54
netdata_rwlock_wrlock(&rrddim_JudyHS_rwlock);
55
Pvoid_t *PValue = JudyHSIns(&rrddim_JudyHS_array, &rd->metric_uuid, sizeof(uuid_t), PJE0);
@@ -75,7 +75,7 @@ rrddim_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE *db_instance __maybe_un
75
}
76
77
STORAGE_METRIC_HANDLE *
78
-rrddim_metric_get(STORAGE_INSTANCE *db_instance __maybe_unused, uuid_t *uuid) {
78
+rrddim_metric_get(STORAGE_INSTANCE *si __maybe_unused, uuid_t *uuid) {
79
struct mem_metric_handle *mh = NULL;
80
netdata_rwlock_rdlock(&rrddim_JudyHS_rwlock);
81
Pvoid_t *PValue = JudyHSGet(rrddim_JudyHS_array, uuid, sizeof(uuid_t));
@@ -89,14 +89,14 @@ rrddim_metric_get(STORAGE_INSTANCE *db_instance __maybe_unused, uuid_t *uuid) {
89
return (STORAGE_METRIC_HANDLE *)mh;
90
}
91
92
-STORAGE_METRIC_HANDLE *rrddim_metric_dup(STORAGE_METRIC_HANDLE *db_metric_handle) {
93
- struct mem_metric_handle *mh = (struct mem_metric_handle *)db_metric_handle;
92
+STORAGE_METRIC_HANDLE *rrddim_metric_dup(STORAGE_METRIC_HANDLE *smh) {
93
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)smh;
94
__atomic_add_fetch(&mh->refcount, 1, __ATOMIC_RELAXED);
95
- return db_metric_handle;
95
+ return smh;
96
}
97
98
-void rrddim_metric_release(STORAGE_METRIC_HANDLE *db_metric_handle __maybe_unused) {
99
- struct mem_metric_handle *mh = (struct mem_metric_handle *)db_metric_handle;
98
+void rrddim_metric_release(STORAGE_METRIC_HANDLE *smh __maybe_unused) {
99
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)smh;
100
101
if(__atomic_sub_fetch(&mh->refcount, 1, __ATOMIC_RELAXED) == 0) {
102
// we are the last one holding this
@@ -116,45 +116,45 @@ void rrddim_metric_release(STORAGE_METRIC_HANDLE *db_metric_handle __maybe_unuse
116
}
117
}
118
119
-bool rrddim_metric_retention_by_uuid(STORAGE_INSTANCE *db_instance __maybe_unused, uuid_t *uuid, time_t *first_entry_s, time_t *last_entry_s) {
120
- STORAGE_METRIC_HANDLE *db_metric_handle = rrddim_metric_get(db_instance, uuid);
121
- if(!db_metric_handle)
119
+bool rrddim_metric_retention_by_uuid(STORAGE_INSTANCE *si __maybe_unused, uuid_t *uuid, time_t *first_entry_s, time_t *last_entry_s) {
120
+ STORAGE_METRIC_HANDLE *smh = rrddim_metric_get(si, uuid);
121
+ if(!smh)
122
return false;
123
124
- *first_entry_s = rrddim_query_oldest_time_s(db_metric_handle);
125
- *last_entry_s = rrddim_query_latest_time_s(db_metric_handle);
124
+ *first_entry_s = rrddim_query_oldest_time_s(smh);
125
+ *last_entry_s = rrddim_query_latest_time_s(smh);
126
127
return true;
128
}
129
130
-void rrddim_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *collection_handle, int update_every) {
131
- struct mem_collect_handle *ch = (struct mem_collect_handle *)collection_handle;
132
- struct mem_metric_handle *mh = (struct mem_metric_handle *)ch->db_metric_handle;
130
+void rrddim_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *sch, int update_every) {
131
+ struct mem_collect_handle *ch = (struct mem_collect_handle *)sch;
132
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)ch->smh;
133
134
- rrddim_store_metric_flush(collection_handle);
134
+ rrddim_store_metric_flush(sch);
135
mh->update_every_s = update_every;
136
}
137
138
-STORAGE_COLLECT_HANDLE *rrddim_collect_init(STORAGE_METRIC_HANDLE *db_metric_handle, uint32_t update_every __maybe_unused, STORAGE_METRICS_GROUP *smg __maybe_unused) {
139
- struct mem_metric_handle *mh = (struct mem_metric_handle *)db_metric_handle;
138
+STORAGE_COLLECT_HANDLE *rrddim_collect_init(STORAGE_METRIC_HANDLE *smh, uint32_t update_every __maybe_unused, STORAGE_METRICS_GROUP *smg __maybe_unused) {
139
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)smh;
140
RRDDIM *rd = mh->rd;
141
142
update_metric_handle_from_rrddim(mh, rd);
143
internal_fatal((uint32_t)mh->update_every_s != update_every, "RRDDIM: update requested does not match the dimension");
144
145
struct mem_collect_handle *ch = callocz(1, sizeof(struct mem_collect_handle));
146
- ch->common.backend = STORAGE_ENGINE_BACKEND_RRDDIM;
146
+ ch->common.seb = STORAGE_ENGINE_BACKEND_RRDDIM;
147
ch->rd = rd;
148
- ch->db_metric_handle = db_metric_handle;
148
+ ch->smh = smh;
149
150
__atomic_add_fetch(&rrddim_db_memory_size, sizeof(struct mem_collect_handle), __ATOMIC_RELAXED);
151
152
return (STORAGE_COLLECT_HANDLE *)ch;
153
}
154
155
-void rrddim_store_metric_flush(STORAGE_COLLECT_HANDLE *collection_handle) {
156
- struct mem_collect_handle *ch = (struct mem_collect_handle *)collection_handle;
157
- struct mem_metric_handle *mh = (struct mem_metric_handle *)ch->db_metric_handle;
155
+void rrddim_store_metric_flush(STORAGE_COLLECT_HANDLE *sch) {
156
+ struct mem_collect_handle *ch = (struct mem_collect_handle *)sch;
157
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)ch->smh;
158
159
RRDDIM *rd = mh->rd;
160
size_t entries = mh->entries;
@@ -168,9 +168,9 @@ void rrddim_store_metric_flush(STORAGE_COLLECT_HANDLE *collection_handle) {
168
mh->current_entry = 0;
169
}
170
171
-static inline void rrddim_fill_the_gap(STORAGE_COLLECT_HANDLE *collection_handle, time_t now_collect_s) {
172
- struct mem_collect_handle *ch = (struct mem_collect_handle *)collection_handle;
173
- struct mem_metric_handle *mh = (struct mem_metric_handle *)ch->db_metric_handle;
171
+static inline void rrddim_fill_the_gap(STORAGE_COLLECT_HANDLE *sch, time_t now_collect_s) {
172
+ struct mem_collect_handle *ch = (struct mem_collect_handle *)sch;
173
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)ch->smh;
174
175
RRDDIM *rd = mh->rd;
176
@@ -182,7 +182,7 @@ static inline void rrddim_fill_the_gap(STORAGE_COLLECT_HANDLE *collection_handle
182
time_t last_stored_s = mh->last_updated_s;
183
size_t gap_entries = (now_collect_s - last_stored_s) / update_every_s;
184
if(gap_entries >= entries)
185
- rrddim_store_metric_flush(collection_handle);
185
+ rrddim_store_metric_flush(sch);
186
187
else {
188
storage_number empty = pack_storage_number(NAN, SN_FLAG_NONE);
@@ -203,7 +203,7 @@ static inline void rrddim_fill_the_gap(STORAGE_COLLECT_HANDLE *collection_handle
203
}
204
}
205
206
-void rrddim_collect_store_metric(STORAGE_COLLECT_HANDLE *collection_handle,
206
+void rrddim_collect_store_metric(STORAGE_COLLECT_HANDLE *sch,
207
usec_t point_in_time_ut,
208
NETDATA_DOUBLE n,
209
NETDATA_DOUBLE min_value __maybe_unused,
@@ -212,8 +212,8 @@ void rrddim_collect_store_metric(STORAGE_COLLECT_HANDLE *collection_handle,
212
uint16_t anomaly_count __maybe_unused,
213
SN_FLAGS flags)
214
{
215
- struct mem_collect_handle *ch = (struct mem_collect_handle *)collection_handle;
216
- struct mem_metric_handle *mh = (struct mem_metric_handle *)ch->db_metric_handle;
215
+ struct mem_collect_handle *ch = (struct mem_collect_handle *)sch;
216
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)ch->smh;
217
218
RRDDIM *rd = ch->rd;
219
time_t point_in_time_s = (time_t)(point_in_time_ut / USEC_PER_SEC);
@@ -225,7 +225,7 @@ void rrddim_collect_store_metric(STORAGE_COLLECT_HANDLE *collection_handle,
225
return;
226
227
if(unlikely(mh->last_updated_s && point_in_time_s - mh->update_every_s > mh->last_updated_s))
228
- rrddim_fill_the_gap(collection_handle, point_in_time_s);
228
+ rrddim_fill_the_gap(sch, point_in_time_s);
229
230
rd->db.data[mh->current_entry] = pack_storage_number(n, flags);
231
mh->counter++;
@@ -233,8 +233,8 @@ void rrddim_collect_store_metric(STORAGE_COLLECT_HANDLE *collection_handle,
233
mh->last_updated_s = point_in_time_s;
234
}
235
236
-int rrddim_collect_finalize(STORAGE_COLLECT_HANDLE *collection_handle) {
237
- freez(collection_handle);
236
+int rrddim_collect_finalize(STORAGE_COLLECT_HANDLE *sch) {
237
+ freez(sch);
238
__atomic_sub_fetch(&rrddim_db_memory_size, sizeof(struct mem_collect_handle), __ATOMIC_RELAXED);
239
return 0;
240
}
@@ -253,13 +253,13 @@ int rrddim_collect_finalize(STORAGE_COLLECT_HANDLE *collection_handle) {
253
// get the slot of the round-robin database, for the given timestamp (t)
254
// it always returns a valid slot, although it may not be for the time requested if the time is outside the round-robin database
255
// only valid when not using dbengine
256
-static inline size_t rrddim_time2slot(STORAGE_METRIC_HANDLE *db_metric_handle, time_t t) {
257
- struct mem_metric_handle *mh = (struct mem_metric_handle *)db_metric_handle;
256
+static inline size_t rrddim_time2slot(STORAGE_METRIC_HANDLE *smh, time_t t) {
257
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)smh;
258
RRDDIM *rd = mh->rd;
259
260
size_t ret = 0;
261
- time_t last_entry_s = rrddim_query_latest_time_s(db_metric_handle);
262
- time_t first_entry_s = rrddim_query_oldest_time_s(db_metric_handle);
261
+ time_t last_entry_s = rrddim_query_latest_time_s(smh);
262
+ time_t first_entry_s = rrddim_query_oldest_time_s(smh);
263
size_t entries = mh->entries;
264
size_t first_slot = rrddim_first_slot(mh);
265
size_t last_slot = rrddim_last_slot(mh);
@@ -292,13 +292,13 @@ static inline size_t rrddim_time2slot(STORAGE_METRIC_HANDLE *db_metric_handle, t
292
293
// get the timestamp of a specific slot in the round-robin database
294
// only valid when not using dbengine
295
-static inline time_t rrddim_slot2time(STORAGE_METRIC_HANDLE *db_metric_handle, size_t slot) {
296
- struct mem_metric_handle *mh = (struct mem_metric_handle *)db_metric_handle;
295
+static inline time_t rrddim_slot2time(STORAGE_METRIC_HANDLE *smh, size_t slot) {
296
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)smh;
297
RRDDIM *rd = mh->rd;
298
299
time_t ret;
300
- time_t last_entry_s = rrddim_query_latest_time_s(db_metric_handle);
301
- time_t first_entry_s = rrddim_query_oldest_time_s(db_metric_handle);
300
+ time_t last_entry_s = rrddim_query_latest_time_s(smh);
301
+ time_t first_entry_s = rrddim_query_oldest_time_s(smh);
302
size_t entries = mh->entries;
303
size_t last_slot = rrddim_last_slot(mh);
304
size_t update_every = mh->update_every_s;
@@ -333,38 +333,38 @@ static inline time_t rrddim_slot2time(STORAGE_METRIC_HANDLE *db_metric_handle, s
333
// ----------------------------------------------------------------------------
334
// RRDDIM legacy database query functions
335
336
-void rrddim_query_init(STORAGE_METRIC_HANDLE *db_metric_handle, struct storage_engine_query_handle *handle, time_t start_time_s, time_t end_time_s, STORAGE_PRIORITY priority __maybe_unused) {
337
- struct mem_metric_handle *mh = (struct mem_metric_handle *)db_metric_handle;
336
+void rrddim_query_init(STORAGE_METRIC_HANDLE *smh, struct storage_engine_query_handle *seqh, time_t start_time_s, time_t end_time_s, STORAGE_PRIORITY priority __maybe_unused) {
337
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)smh;
338
339
check_metric_handle_from_rrddim(mh);
340
341
- handle->start_time_s = start_time_s;
342
- handle->end_time_s = end_time_s;
343
- handle->priority = priority;
344
- handle->backend = STORAGE_ENGINE_BACKEND_RRDDIM;
341
+ seqh->start_time_s = start_time_s;
342
+ seqh->end_time_s = end_time_s;
343
+ seqh->priority = priority;
344
+ seqh->seb = STORAGE_ENGINE_BACKEND_RRDDIM;
345
struct mem_query_handle* h = mallocz(sizeof(struct mem_query_handle));
346
- h->db_metric_handle = db_metric_handle;
346
+ h->smh = smh;
347
348
- h->slot = rrddim_time2slot(db_metric_handle, start_time_s);
349
- h->last_slot = rrddim_time2slot(db_metric_handle, end_time_s);
348
+ h->slot = rrddim_time2slot(smh, start_time_s);
349
+ h->last_slot = rrddim_time2slot(smh, end_time_s);
350
h->dt = mh->update_every_s;
351
352
h->next_timestamp = start_time_s;
353
- h->slot_timestamp = rrddim_slot2time(db_metric_handle, h->slot);
354
- h->last_timestamp = rrddim_slot2time(db_metric_handle, h->last_slot);
353
+ h->slot_timestamp = rrddim_slot2time(smh, h->slot);
354
+ h->last_timestamp = rrddim_slot2time(smh, h->last_slot);
355
356
// netdata_log_info("RRDDIM QUERY INIT: start %ld, end %ld, next %ld, first %ld, last %ld, dt %ld", start_time, end_time, h->next_timestamp, h->slot_timestamp, h->last_timestamp, h->dt);
357
358
__atomic_add_fetch(&rrddim_db_memory_size, sizeof(struct mem_query_handle), __ATOMIC_RELAXED);
359
- handle->handle = (STORAGE_QUERY_HANDLE *)h;
359
+ seqh->handle = (STORAGE_QUERY_HANDLE *)h;
360
}
361
362
// Returns the metric and sets its timestamp into current_time
363
// IT IS REQUIRED TO **ALWAYS** SET ALL RETURN VALUES (current_time, end_time, flags)
364
// IT IS REQUIRED TO **ALWAYS** KEEP TRACK OF TIME, EVEN OUTSIDE THE DATABASE BOUNDARIES
365
-STORAGE_POINT rrddim_query_next_metric(struct storage_engine_query_handle *handle) {
366
- struct mem_query_handle* h = (struct mem_query_handle*)handle->handle;
367
- struct mem_metric_handle *mh = (struct mem_metric_handle *)h->db_metric_handle;
365
+STORAGE_POINT rrddim_query_next_metric(struct storage_engine_query_handle *seqh) {
366
+ struct mem_query_handle* h = (struct mem_query_handle*)seqh->handle;
367
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)h->smh;
368
RRDDIM *rd = mh->rd;
369
370
size_t entries = mh->entries;
@@ -403,35 +403,35 @@ STORAGE_POINT rrddim_query_next_metric(struct storage_engine_query_handle *handl
403
return sp;
404
}
405
406
-int rrddim_query_is_finished(struct storage_engine_query_handle *handle) {
407
- struct mem_query_handle *h = (struct mem_query_handle*)handle->handle;
408
- return (h->next_timestamp > handle->end_time_s);
406
+int rrddim_query_is_finished(struct storage_engine_query_handle *seqh) {
407
+ struct mem_query_handle *h = (struct mem_query_handle*)seqh->handle;
408
+ return (h->next_timestamp > seqh->end_time_s);
409
}
410
411
-void rrddim_query_finalize(struct storage_engine_query_handle *handle) {
411
+void rrddim_query_finalize(struct storage_engine_query_handle *seqh) {
412
#ifdef NETDATA_INTERNAL_CHECKS
413
- struct mem_query_handle *h = (struct mem_query_handle*)handle->handle;
414
- struct mem_metric_handle *mh = (struct mem_metric_handle *)h->db_metric_handle;
413
+ struct mem_query_handle *h = (struct mem_query_handle*)seqh->handle;
414
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)h->smh;
415
416
- internal_error(!rrddim_query_is_finished(handle),
416
+ internal_error(!rrddim_query_is_finished(seqh),
417
"QUERY: query for chart '%s' dimension '%s' has been stopped unfinished",
418
rrdset_id(mh->rd->rrdset), rrddim_name(mh->rd));
419
420
#endif
421
- freez(handle->handle);
421
+ freez(seqh->handle);
422
__atomic_sub_fetch(&rrddim_db_memory_size, sizeof(struct mem_query_handle), __ATOMIC_RELAXED);
423
}
424
425
-time_t rrddim_query_align_to_optimal_before(struct storage_engine_query_handle *rrddim_handle) {
426
- return rrddim_handle->end_time_s;
425
+time_t rrddim_query_align_to_optimal_before(struct storage_engine_query_handle *seqh) {
426
+ return seqh->end_time_s;
427
}
428
429
-time_t rrddim_query_latest_time_s(STORAGE_METRIC_HANDLE *db_metric_handle) {
430
- struct mem_metric_handle *mh = (struct mem_metric_handle *)db_metric_handle;
429
+time_t rrddim_query_latest_time_s(STORAGE_METRIC_HANDLE *smh) {
430
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)smh;
431
return mh->last_updated_s;
432
}
433
434
-time_t rrddim_query_oldest_time_s(STORAGE_METRIC_HANDLE *db_metric_handle) {
435
- struct mem_metric_handle *mh = (struct mem_metric_handle *)db_metric_handle;
434
+time_t rrddim_query_oldest_time_s(STORAGE_METRIC_HANDLE *smh) {
435
+ struct mem_metric_handle *mh = (struct mem_metric_handle *)smh;
436
return (time_t)(mh->last_updated_s - metric_duration(mh));
437
}
database/ram/rrddim_mem.h
+22
-22
@@ -8,12 +8,12 @@
8
struct mem_collect_handle {
9
struct storage_collect_handle common; // has to be first item
10
11
- STORAGE_METRIC_HANDLE *db_metric_handle;
11
+ STORAGE_METRIC_HANDLE *smh;
12
RRDDIM *rd;
13
};
14
15
struct mem_query_handle {
16
- STORAGE_METRIC_HANDLE *db_metric_handle;
16
+ STORAGE_METRIC_HANDLE *smh;
17
time_t dt;
18
time_t next_timestamp;
19
time_t last_timestamp;
@@ -22,33 +22,33 @@ struct mem_query_handle {
22
size_t last_slot;
23
};
24
25
-STORAGE_METRIC_HANDLE *rrddim_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE *db_instance);
26
-STORAGE_METRIC_HANDLE *rrddim_metric_get(STORAGE_INSTANCE *db_instance, uuid_t *uuid);
27
-STORAGE_METRIC_HANDLE *rrddim_metric_dup(STORAGE_METRIC_HANDLE *db_metric_handle);
28
-void rrddim_metric_release(STORAGE_METRIC_HANDLE *db_metric_handle);
25
+STORAGE_METRIC_HANDLE *rrddim_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE *si);
26
+STORAGE_METRIC_HANDLE *rrddim_metric_get(STORAGE_INSTANCE *si, uuid_t *uuid);
27
+STORAGE_METRIC_HANDLE *rrddim_metric_dup(STORAGE_METRIC_HANDLE *smh);
28
+void rrddim_metric_release(STORAGE_METRIC_HANDLE *smh);
29
30
-bool rrddim_metric_retention_by_uuid(STORAGE_INSTANCE *db_instance, uuid_t *uuid, time_t *first_entry_s, time_t *last_entry_s);
30
+bool rrddim_metric_retention_by_uuid(STORAGE_INSTANCE *si, uuid_t *uuid, time_t *first_entry_s, time_t *last_entry_s);
31
32
-STORAGE_METRICS_GROUP *rrddim_metrics_group_get(STORAGE_INSTANCE *db_instance, uuid_t *uuid);
33
-void rrddim_metrics_group_release(STORAGE_INSTANCE *db_instance, STORAGE_METRICS_GROUP *smg);
32
+STORAGE_METRICS_GROUP *rrddim_metrics_group_get(STORAGE_INSTANCE *si, uuid_t *uuid);
33
+void rrddim_metrics_group_release(STORAGE_INSTANCE *si, STORAGE_METRICS_GROUP *smg);
34
35
-STORAGE_COLLECT_HANDLE *rrddim_collect_init(STORAGE_METRIC_HANDLE *db_metric_handle, uint32_t update_every, STORAGE_METRICS_GROUP *smg);
36
-void rrddim_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *collection_handle, int update_every);
37
-void rrddim_collect_store_metric(STORAGE_COLLECT_HANDLE *collection_handle, usec_t point_in_time_ut, NETDATA_DOUBLE n,
35
+STORAGE_COLLECT_HANDLE *rrddim_collect_init(STORAGE_METRIC_HANDLE *smh, uint32_t update_every, STORAGE_METRICS_GROUP *smg);
36
+void rrddim_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *sch, int update_every);
37
+void rrddim_collect_store_metric(STORAGE_COLLECT_HANDLE *sch, usec_t point_in_time_ut, NETDATA_DOUBLE n,
38
NETDATA_DOUBLE min_value,
39
NETDATA_DOUBLE max_value,
40
uint16_t count,
41
uint16_t anomaly_count,
42
SN_FLAGS flags);
43
-void rrddim_store_metric_flush(STORAGE_COLLECT_HANDLE *collection_handle);
44
-int rrddim_collect_finalize(STORAGE_COLLECT_HANDLE *collection_handle);
45
-
46
-void rrddim_query_init(STORAGE_METRIC_HANDLE *db_metric_handle, struct storage_engine_query_handle *handle, time_t start_time_s, time_t end_time_s, STORAGE_PRIORITY priority);
47
-STORAGE_POINT rrddim_query_next_metric(struct storage_engine_query_handle *handle);
48
-int rrddim_query_is_finished(struct storage_engine_query_handle *handle);
49
-void rrddim_query_finalize(struct storage_engine_query_handle *handle);
50
-time_t rrddim_query_latest_time_s(STORAGE_METRIC_HANDLE *db_metric_handle);
51
-time_t rrddim_query_oldest_time_s(STORAGE_METRIC_HANDLE *db_metric_handle);
52
-time_t rrddim_query_align_to_optimal_before(struct storage_engine_query_handle *rrddim_handle);
43
+void rrddim_store_metric_flush(STORAGE_COLLECT_HANDLE *sch);
44
+int rrddim_collect_finalize(STORAGE_COLLECT_HANDLE *sch);
45
+
46
+void rrddim_query_init(STORAGE_METRIC_HANDLE *smh, struct storage_engine_query_handle *seqh, time_t start_time_s, time_t end_time_s, STORAGE_PRIORITY priority);
47
+STORAGE_POINT rrddim_query_next_metric(struct storage_engine_query_handle *seqh);
48
+int rrddim_query_is_finished(struct storage_engine_query_handle *seqh);
49
+void rrddim_query_finalize(struct storage_engine_query_handle *seqh);
50
+time_t rrddim_query_latest_time_s(STORAGE_METRIC_HANDLE *smh);
51
+time_t rrddim_query_oldest_time_s(STORAGE_METRIC_HANDLE *smh);
52
+time_t rrddim_query_align_to_optimal_before(struct storage_engine_query_handle *seqh);
53
54
#endif
database/rrd.h
+128
-128
@@ -134,7 +134,7 @@ struct storage_engine_query_handle {
134
time_t start_time_s;
135
time_t end_time_s;
136
STORAGE_PRIORITY priority;
137
- STORAGE_ENGINE_BACKEND backend;
137
+ STORAGE_ENGINE_BACKEND seb;
138
STORAGE_QUERY_HANDLE *handle;
139
};
140
@@ -271,7 +271,7 @@ typedef enum __attribute__ ((__packed__)) rrddim_flags {
271
// ----------------------------------------------------------------------------
272
// engine-specific iterator state for dimension data collection
273
typedef struct storage_collect_handle {
274
- STORAGE_ENGINE_BACKEND backend;
274
+ STORAGE_ENGINE_BACKEND seb;
275
} STORAGE_COLLECT_HANDLE;
276
277
// ----------------------------------------------------------------------------
@@ -279,11 +279,11 @@ typedef struct storage_collect_handle {
279
280
struct rrddim_tier {
281
STORAGE_POINT virtual_point;
282
- STORAGE_ENGINE_BACKEND backend;
282
+ STORAGE_ENGINE_BACKEND seb;
283
uint32_t tier_grouping;
284
time_t next_point_end_time_s;
285
- STORAGE_METRIC_HANDLE *db_metric_handle; // the metric handle inside the database
286
- STORAGE_COLLECT_HANDLE *db_collection_handle; // the data collection handle
285
+ STORAGE_METRIC_HANDLE *smh; // the metric handle inside the database
286
+ STORAGE_COLLECT_HANDLE *sch; // the data collection handle
287
};
288
289
void rrdr_fill_tier_gap_from_smaller_tiers(RRDDIM *rd, size_t tier, time_t now_s);
@@ -400,268 +400,268 @@ void rrddim_memory_file_save(RRDDIM *rd);
400
// ------------------------------------------------------------------------
401
// DATA COLLECTION STORAGE OPS
402
403
-STORAGE_METRICS_GROUP *rrdeng_metrics_group_get(STORAGE_INSTANCE *db_instance, uuid_t *uuid);
404
-STORAGE_METRICS_GROUP *rrddim_metrics_group_get(STORAGE_INSTANCE *db_instance, uuid_t *uuid);
405
-static inline STORAGE_METRICS_GROUP *storage_engine_metrics_group_get(STORAGE_ENGINE_BACKEND backend __maybe_unused, STORAGE_INSTANCE *db_instance, uuid_t *uuid) {
406
- internal_fatal(!is_valid_backend(backend), "STORAGE: invalid backend");
403
+STORAGE_METRICS_GROUP *rrdeng_metrics_group_get(STORAGE_INSTANCE *si, uuid_t *uuid);
404
+STORAGE_METRICS_GROUP *rrddim_metrics_group_get(STORAGE_INSTANCE *si, uuid_t *uuid);
405
+static inline STORAGE_METRICS_GROUP *storage_engine_metrics_group_get(STORAGE_ENGINE_BACKEND seb __maybe_unused, STORAGE_INSTANCE *si, uuid_t *uuid) {
406
+ internal_fatal(!is_valid_backend(seb), "STORAGE: invalid backend");
407
408
#ifdef ENABLE_DBENGINE
409
- if(likely(backend == STORAGE_ENGINE_BACKEND_DBENGINE))
410
- return rrdeng_metrics_group_get(db_instance, uuid);
409
+ if(likely(seb == STORAGE_ENGINE_BACKEND_DBENGINE))
410
+ return rrdeng_metrics_group_get(si, uuid);
411
#endif
412
- return rrddim_metrics_group_get(db_instance, uuid);
412
+ return rrddim_metrics_group_get(si, uuid);
413
}
414
415
-void rrdeng_metrics_group_release(STORAGE_INSTANCE *db_instance, STORAGE_METRICS_GROUP *smg);
416
-void rrddim_metrics_group_release(STORAGE_INSTANCE *db_instance, STORAGE_METRICS_GROUP *smg);
417
-static inline void storage_engine_metrics_group_release(STORAGE_ENGINE_BACKEND backend __maybe_unused, STORAGE_INSTANCE *db_instance, STORAGE_METRICS_GROUP *smg) {
418
- internal_fatal(!is_valid_backend(backend), "STORAGE: invalid backend");
415
+void rrdeng_metrics_group_release(STORAGE_INSTANCE *si, STORAGE_METRICS_GROUP *smg);
416
+void rrddim_metrics_group_release(STORAGE_INSTANCE *si, STORAGE_METRICS_GROUP *smg);
417
+static inline void storage_engine_metrics_group_release(STORAGE_ENGINE_BACKEND seb __maybe_unused, STORAGE_INSTANCE *si, STORAGE_METRICS_GROUP *smg) {
418
+ internal_fatal(!is_valid_backend(seb), "STORAGE: invalid backend");
419
420
#ifdef ENABLE_DBENGINE
421
- if(likely(backend == STORAGE_ENGINE_BACKEND_DBENGINE))
422
- rrdeng_metrics_group_release(db_instance, smg);
421
+ if(likely(seb == STORAGE_ENGINE_BACKEND_DBENGINE))
422
+ rrdeng_metrics_group_release(si, smg);
423
else
424
#endif
425
- rrddim_metrics_group_release(db_instance, smg);
425
+ rrddim_metrics_group_release(si, smg);
426
}
427
428
-STORAGE_COLLECT_HANDLE *rrdeng_store_metric_init(STORAGE_METRIC_HANDLE *db_metric_handle, uint32_t update_every, STORAGE_METRICS_GROUP *smg);
429
-STORAGE_COLLECT_HANDLE *rrddim_collect_init(STORAGE_METRIC_HANDLE *db_metric_handle, uint32_t update_every, STORAGE_METRICS_GROUP *smg);
430
-static inline STORAGE_COLLECT_HANDLE *storage_metric_store_init(STORAGE_ENGINE_BACKEND backend __maybe_unused, STORAGE_METRIC_HANDLE *db_metric_handle, uint32_t update_every, STORAGE_METRICS_GROUP *smg) {
431
- internal_fatal(!is_valid_backend(backend), "STORAGE: invalid backend");
428
+STORAGE_COLLECT_HANDLE *rrdeng_store_metric_init(STORAGE_METRIC_HANDLE *smh, uint32_t update_every, STORAGE_METRICS_GROUP *smg);
429
+STORAGE_COLLECT_HANDLE *rrddim_collect_init(STORAGE_METRIC_HANDLE *smh, uint32_t update_every, STORAGE_METRICS_GROUP *smg);
430
+static inline STORAGE_COLLECT_HANDLE *storage_metric_store_init(STORAGE_ENGINE_BACKEND seb __maybe_unused, STORAGE_METRIC_HANDLE *smh, uint32_t update_every, STORAGE_METRICS_GROUP *smg) {
431
+ internal_fatal(!is_valid_backend(seb), "STORAGE: invalid backend");
432
433
#ifdef ENABLE_DBENGINE
434
- if(likely(backend == STORAGE_ENGINE_BACKEND_DBENGINE))
435
- return rrdeng_store_metric_init(db_metric_handle, update_every, smg);
434
+ if(likely(seb == STORAGE_ENGINE_BACKEND_DBENGINE))
435
+ return rrdeng_store_metric_init(smh, update_every, smg);
436
#endif
437
- return rrddim_collect_init(db_metric_handle, update_every, smg);
437
+ return rrddim_collect_init(smh, update_every, smg);
438
}
439
440
void rrdeng_store_metric_next(
441
- STORAGE_COLLECT_HANDLE *collection_handle, usec_t point_in_time_ut,
441
+ STORAGE_COLLECT_HANDLE *sch, usec_t point_in_time_ut,
442
NETDATA_DOUBLE n, NETDATA_DOUBLE min_value, NETDATA_DOUBLE max_value,
443
uint16_t count, uint16_t anomaly_count, SN_FLAGS flags);
444
445
void rrddim_collect_store_metric(
446
- STORAGE_COLLECT_HANDLE *collection_handle, usec_t point_in_time_ut,
446
+ STORAGE_COLLECT_HANDLE *sch, usec_t point_in_time_ut,
447
NETDATA_DOUBLE n, NETDATA_DOUBLE min_value, NETDATA_DOUBLE max_value,
448
uint16_t count, uint16_t anomaly_count, SN_FLAGS flags);
449
450
static inline void storage_engine_store_metric(
451
- STORAGE_COLLECT_HANDLE *collection_handle, usec_t point_in_time_ut,
451
+ STORAGE_COLLECT_HANDLE *sch, usec_t point_in_time_ut,
452
NETDATA_DOUBLE n, NETDATA_DOUBLE min_value, NETDATA_DOUBLE max_value,
453
uint16_t count, uint16_t anomaly_count, SN_FLAGS flags) {
454
- internal_fatal(!is_valid_backend(collection_handle->backend), "STORAGE: invalid backend");
454
+ internal_fatal(!is_valid_backend(sch->seb), "STORAGE: invalid backend");
455
456
#ifdef ENABLE_DBENGINE
457
- if(likely(collection_handle->backend == STORAGE_ENGINE_BACKEND_DBENGINE))
458
- return rrdeng_store_metric_next(collection_handle, point_in_time_ut,
457
+ if(likely(sch->seb == STORAGE_ENGINE_BACKEND_DBENGINE))
458
+ return rrdeng_store_metric_next(sch, point_in_time_ut,
459
n, min_value, max_value,
460
count, anomaly_count, flags);
461
#endif
462
- return rrddim_collect_store_metric(collection_handle, point_in_time_ut,
462
+ return rrddim_collect_store_metric(sch, point_in_time_ut,
463
n, min_value, max_value,
464
count, anomaly_count, flags);
465
}
466
467
-uint64_t rrdeng_disk_space_max(STORAGE_INSTANCE *db_instance);
468
-static inline uint64_t storage_engine_disk_space_max(STORAGE_ENGINE_BACKEND backend __maybe_unused, STORAGE_INSTANCE *db_instance __maybe_unused) {
467
+uint64_t rrdeng_disk_space_max(STORAGE_INSTANCE *si);
468
+static inline uint64_t storage_engine_disk_space_max(STORAGE_ENGINE_BACKEND seb __maybe_unused, STORAGE_INSTANCE *si __maybe_unused) {
469
#ifdef ENABLE_DBENGINE
470
- if(likely(backend == STORAGE_ENGINE_BACKEND_DBENGINE))
471
- return rrdeng_disk_space_max(db_instance);
470
+ if(likely(seb == STORAGE_ENGINE_BACKEND_DBENGINE))
471
+ return rrdeng_disk_space_max(si);
472
#endif
473
474
return 0;
475
}
476
477
-uint64_t rrdeng_disk_space_used(STORAGE_INSTANCE *db_instance);
478
-static inline uint64_t storage_engine_disk_space_used(STORAGE_ENGINE_BACKEND backend __maybe_unused, STORAGE_INSTANCE *db_instance __maybe_unused) {
477
+uint64_t rrdeng_disk_space_used(STORAGE_INSTANCE *si);
478
+static inline uint64_t storage_engine_disk_space_used(STORAGE_ENGINE_BACKEND seb __maybe_unused, STORAGE_INSTANCE *si __maybe_unused) {
479
#ifdef ENABLE_DBENGINE
480
- if(likely(backend == STORAGE_ENGINE_BACKEND_DBENGINE))
481
- return rrdeng_disk_space_used(db_instance);
480
+ if(likely(seb == STORAGE_ENGINE_BACKEND_DBENGINE))
481
+ return rrdeng_disk_space_used(si);
482
#endif
483
484
// TODO - calculate the total host disk space for memory mode save and map
485
return 0;
486
}
487
488
-time_t rrdeng_global_first_time_s(STORAGE_INSTANCE *db_instance);
489
-static inline time_t storage_engine_global_first_time_s(STORAGE_ENGINE_BACKEND backend __maybe_unused, STORAGE_INSTANCE *db_instance __maybe_unused) {
488
+time_t rrdeng_global_first_time_s(STORAGE_INSTANCE *si);
489
+static inline time_t storage_engine_global_first_time_s(STORAGE_ENGINE_BACKEND seb __maybe_unused, STORAGE_INSTANCE *si __maybe_unused) {
490
#ifdef ENABLE_DBENGINE
491
- if(likely(backend == STORAGE_ENGINE_BACKEND_DBENGINE))
492
- return rrdeng_global_first_time_s(db_instance);
491
+ if(likely(seb == STORAGE_ENGINE_BACKEND_DBENGINE))
492
+ return rrdeng_global_first_time_s(si);
493
#endif
494
495
return now_realtime_sec() - (time_t)(default_rrd_history_entries * default_rrd_update_every);
496
}
497
498
-size_t rrdeng_currently_collected_metrics(STORAGE_INSTANCE *db_instance);
499
-static inline size_t storage_engine_collected_metrics(STORAGE_ENGINE_BACKEND backend __maybe_unused, STORAGE_INSTANCE *db_instance __maybe_unused) {
498
+size_t rrdeng_currently_collected_metrics(STORAGE_INSTANCE *si);
499
+static inline size_t storage_engine_collected_metrics(STORAGE_ENGINE_BACKEND seb __maybe_unused, STORAGE_INSTANCE *si __maybe_unused) {
500
#ifdef ENABLE_DBENGINE
501
- if(likely(backend == STORAGE_ENGINE_BACKEND_DBENGINE))
502
- return rrdeng_currently_collected_metrics(db_instance);
501
+ if(likely(seb == STORAGE_ENGINE_BACKEND_DBENGINE))
502
+ return rrdeng_currently_collected_metrics(si);
503
#endif
504
505
// TODO - calculate the total host disk space for memory mode save and map
506
return 0;
507
}
508
509
-void rrdeng_store_metric_flush_current_page(STORAGE_COLLECT_HANDLE *collection_handle);
510
-void rrddim_store_metric_flush(STORAGE_COLLECT_HANDLE *collection_handle);
511
-static inline void storage_engine_store_flush(STORAGE_COLLECT_HANDLE *collection_handle) {
512
- if(unlikely(!collection_handle))
509
+void rrdeng_store_metric_flush_current_page(STORAGE_COLLECT_HANDLE *sch);
510
+void rrddim_store_metric_flush(STORAGE_COLLECT_HANDLE *sch);
511
+static inline void storage_engine_store_flush(STORAGE_COLLECT_HANDLE *sch) {
512
+ if(unlikely(!sch))
513
return;
514
515
- internal_fatal(!is_valid_backend(collection_handle->backend), "STORAGE: invalid backend");
515
+ internal_fatal(!is_valid_backend(sch->seb), "STORAGE: invalid backend");
516
517
#ifdef ENABLE_DBENGINE
518
- if(likely(collection_handle->backend == STORAGE_ENGINE_BACKEND_DBENGINE))
519
- rrdeng_store_metric_flush_current_page(collection_handle);
518
+ if(likely(sch->seb == STORAGE_ENGINE_BACKEND_DBENGINE))
519
+ rrdeng_store_metric_flush_current_page(sch);
520
else
521
#endif
522
- rrddim_store_metric_flush(collection_handle);
522
+ rrddim_store_metric_flush(sch);
523
}
524
525
-int rrdeng_store_metric_finalize(STORAGE_COLLECT_HANDLE *collection_handle);
526
-int rrddim_collect_finalize(STORAGE_COLLECT_HANDLE *collection_handle);
525
+int rrdeng_store_metric_finalize(STORAGE_COLLECT_HANDLE *sch);
526
+int rrddim_collect_finalize(STORAGE_COLLECT_HANDLE *sch);
527
// a finalization function to run after collection is over
528
// returns 1 if it's safe to delete the dimension
529
-static inline int storage_engine_store_finalize(STORAGE_COLLECT_HANDLE *collection_handle) {
530
- internal_fatal(!is_valid_backend(collection_handle->backend), "STORAGE: invalid backend");
529
+static inline int storage_engine_store_finalize(STORAGE_COLLECT_HANDLE *sch) {
530
+ internal_fatal(!is_valid_backend(sch->seb), "STORAGE: invalid backend");
531
532
#ifdef ENABLE_DBENGINE
533
- if(likely(collection_handle->backend == STORAGE_ENGINE_BACKEND_DBENGINE))
534
- return rrdeng_store_metric_finalize(collection_handle);
533
+ if(likely(sch->seb == STORAGE_ENGINE_BACKEND_DBENGINE))
534
+ return rrdeng_store_metric_finalize(sch);
535
#endif
536
537
- return rrddim_collect_finalize(collection_handle);
537
+ return rrddim_collect_finalize(sch);
538
}
539
540
-void rrdeng_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *collection_handle, int update_every);
541
-void rrddim_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *collection_handle, int update_every);
542
-static inline void storage_engine_store_change_collection_frequency(STORAGE_COLLECT_HANDLE *collection_handle, int update_every) {
543
- internal_fatal(!is_valid_backend(collection_handle->backend), "STORAGE: invalid backend");
540
+void rrdeng_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *sch, int update_every);
541
+void rrddim_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *sch, int update_every);
542
+static inline void storage_engine_store_change_collection_frequency(STORAGE_COLLECT_HANDLE *sch, int update_every) {
543
+ internal_fatal(!is_valid_backend(sch->seb), "STORAGE: invalid backend");
544
545
#ifdef ENABLE_DBENGINE
546
- if(likely(collection_handle->backend == STORAGE_ENGINE_BACKEND_DBENGINE))
547
- rrdeng_store_metric_change_collection_frequency(collection_handle, update_every);
546
+ if(likely(sch->seb == STORAGE_ENGINE_BACKEND_DBENGINE))
547
+ rrdeng_store_metric_change_collection_frequency(sch, update_every);
548
else
549
#endif
550
- rrddim_store_metric_change_collection_frequency(collection_handle, update_every);
550
+ rrddim_store_metric_change_collection_frequency(sch, update_every);
551
}
552
553
554
// ----------------------------------------------------------------------------
555
// STORAGE ENGINE QUERY OPS
556
557
-time_t rrdeng_metric_oldest_time(STORAGE_METRIC_HANDLE *db_metric_handle);
558
-time_t rrddim_query_oldest_time_s(STORAGE_METRIC_HANDLE *db_metric_handle);
559
-static inline time_t storage_engine_oldest_time_s(STORAGE_ENGINE_BACKEND backend __maybe_unused, STORAGE_METRIC_HANDLE *db_metric_handle) {
560
- internal_fatal(!is_valid_backend(backend), "STORAGE: invalid backend");
557
+time_t rrdeng_metric_oldest_time(STORAGE_METRIC_HANDLE *smh);
558
+time_t rrddim_query_oldest_time_s(STORAGE_METRIC_HANDLE *smh);
559
+static inline time_t storage_engine_oldest_time_s(STORAGE_ENGINE_BACKEND seb __maybe_unused, STORAGE_METRIC_HANDLE *smh) {
560
+ internal_fatal(!is_valid_backend(seb), "STORAGE: invalid backend");
561
562
#ifdef ENABLE_DBENGINE
563
- if(likely(backend == STORAGE_ENGINE_BACKEND_DBENGINE))
564
- return rrdeng_metric_oldest_time(db_metric_handle);
563
+ if(likely(seb == STORAGE_ENGINE_BACKEND_DBENGINE))
564
+ return rrdeng_metric_oldest_time(smh);
565
#endif
566
- return rrddim_query_oldest_time_s(db_metric_handle);
566
+ return rrddim_query_oldest_time_s(smh);
567
}
568
569
-time_t rrdeng_metric_latest_time(STORAGE_METRIC_HANDLE *db_metric_handle);
570
-time_t rrddim_query_latest_time_s(STORAGE_METRIC_HANDLE *db_metric_handle);
571
-static inline time_t storage_engine_latest_time_s(STORAGE_ENGINE_BACKEND backend __maybe_unused, STORAGE_METRIC_HANDLE *db_metric_handle) {
572
- internal_fatal(!is_valid_backend(backend), "STORAGE: invalid backend");
569
+time_t rrdeng_metric_latest_time(STORAGE_METRIC_HANDLE *smh);
570
+time_t rrddim_query_latest_time_s(STORAGE_METRIC_HANDLE *smh);
571
+static inline time_t storage_engine_latest_time_s(STORAGE_ENGINE_BACKEND seb __maybe_unused, STORAGE_METRIC_HANDLE *smh) {
572
+ internal_fatal(!is_valid_backend(seb), "STORAGE: invalid backend");
573
574
#ifdef ENABLE_DBENGINE
575
- if(likely(backend == STORAGE_ENGINE_BACKEND_DBENGINE))
576
- return rrdeng_metric_latest_time(db_metric_handle);
575
+ if(likely(seb == STORAGE_ENGINE_BACKEND_DBENGINE))
576
+ return rrdeng_metric_latest_time(smh);
577
#endif
578
- return rrddim_query_latest_time_s(db_metric_handle);
578
+ return rrddim_query_latest_time_s(smh);
579
}
580
581
void rrdeng_load_metric_init(
582
- STORAGE_METRIC_HANDLE *db_metric_handle, struct storage_engine_query_handle *rrddim_handle,
582
+ STORAGE_METRIC_HANDLE *smh, struct storage_engine_query_handle *seqh,
583
time_t start_time_s, time_t end_time_s, STORAGE_PRIORITY priority);
584
585
void rrddim_query_init(
586
- STORAGE_METRIC_HANDLE *db_metric_handle, struct storage_engine_query_handle *handle,
586
+ STORAGE_METRIC_HANDLE *smh, struct storage_engine_query_handle *seqh,
587
time_t start_time_s, time_t end_time_s, STORAGE_PRIORITY priority);
588
589
static inline void storage_engine_query_init(
590
- STORAGE_ENGINE_BACKEND backend __maybe_unused,
591
- STORAGE_METRIC_HANDLE *db_metric_handle, struct storage_engine_query_handle *handle,
590
+ STORAGE_ENGINE_BACKEND seb __maybe_unused,
591
+ STORAGE_METRIC_HANDLE *smh, struct storage_engine_query_handle *seqh,
592
time_t start_time_s, time_t end_time_s, STORAGE_PRIORITY priority) {
593
- internal_fatal(!is_valid_backend(backend), "STORAGE: invalid backend");
593
+ internal_fatal(!is_valid_backend(seb), "STORAGE: invalid backend");
594
595
#ifdef ENABLE_DBENGINE
596
- if(likely(backend == STORAGE_ENGINE_BACKEND_DBENGINE))
597
- rrdeng_load_metric_init(db_metric_handle, handle, start_time_s, end_time_s, priority);
596
+ if(likely(seb == STORAGE_ENGINE_BACKEND_DBENGINE))
597
+ rrdeng_load_metric_init(smh, seqh, start_time_s, end_time_s, priority);
598
else
599
#endif
600
- rrddim_query_init(db_metric_handle, handle, start_time_s, end_time_s, priority);
600
+ rrddim_query_init(smh, seqh, start_time_s, end_time_s, priority);
601
}
602
603
-STORAGE_POINT rrdeng_load_metric_next(struct storage_engine_query_handle *rrddim_handle);
604
-STORAGE_POINT rrddim_query_next_metric(struct storage_engine_query_handle *handle);
605
-static inline STORAGE_POINT storage_engine_query_next_metric(struct storage_engine_query_handle *handle) {
606
- internal_fatal(!is_valid_backend(handle->backend), "STORAGE: invalid backend");
603
+STORAGE_POINT rrdeng_load_metric_next(struct storage_engine_query_handle *seqh);
604
+STORAGE_POINT rrddim_query_next_metric(struct storage_engine_query_handle *seqh);
605
+static inline STORAGE_POINT storage_engine_query_next_metric(struct storage_engine_query_handle *seqh) {
606
+ internal_fatal(!is_valid_backend(seqh->seb), "STORAGE: invalid backend");
607
608
#ifdef ENABLE_DBENGINE
609
- if(likely(handle->backend == STORAGE_ENGINE_BACKEND_DBENGINE))
610
- return rrdeng_load_metric_next(handle);
609
+ if(likely(seqh->seb == STORAGE_ENGINE_BACKEND_DBENGINE))
610
+ return rrdeng_load_metric_next(seqh);
611
#endif
612
- return rrddim_query_next_metric(handle);
612
+ return rrddim_query_next_metric(seqh);
613
}
614
615
-int rrdeng_load_metric_is_finished(struct storage_engine_query_handle *rrddim_handle);
616
-int rrddim_query_is_finished(struct storage_engine_query_handle *handle);
617
-static inline int storage_engine_query_is_finished(struct storage_engine_query_handle *handle) {
618
- internal_fatal(!is_valid_backend(handle->backend), "STORAGE: invalid backend");
615
+int rrdeng_load_metric_is_finished(struct storage_engine_query_handle *seqh);
616
+int rrddim_query_is_finished(struct storage_engine_query_handle *seqh);
617
+static inline int storage_engine_query_is_finished(struct storage_engine_query_handle *seqh) {
618
+ internal_fatal(!is_valid_backend(seqh->seb), "STORAGE: invalid backend");
619
620
#ifdef ENABLE_DBENGINE
621
- if(likely(handle->backend == STORAGE_ENGINE_BACKEND_DBENGINE))
622
- return rrdeng_load_metric_is_finished(handle);
621
+ if(likely(seqh->seb == STORAGE_ENGINE_BACKEND_DBENGINE))
622
+ return rrdeng_load_metric_is_finished(seqh);
623
#endif
624
- return rrddim_query_is_finished(handle);
624
+ return rrddim_query_is_finished(seqh);
625
}
626
627
-void rrdeng_load_metric_finalize(struct storage_engine_query_handle *rrddim_handle);
628
-void rrddim_query_finalize(struct storage_engine_query_handle *handle);
629
-static inline void storage_engine_query_finalize(struct storage_engine_query_handle *handle) {
630
- internal_fatal(!is_valid_backend(handle->backend), "STORAGE: invalid backend");
627
+void rrdeng_load_metric_finalize(struct storage_engine_query_handle *seqh);
628
+void rrddim_query_finalize(struct storage_engine_query_handle *seqh);
629
+static inline void storage_engine_query_finalize(struct storage_engine_query_handle *seqh) {
630
+ internal_fatal(!is_valid_backend(seqh->seb), "STORAGE: invalid backend");
631
632
#ifdef ENABLE_DBENGINE
633
- if(likely(handle->backend == STORAGE_ENGINE_BACKEND_DBENGINE))
634
- rrdeng_load_metric_finalize(handle);
633
+ if(likely(seqh->seb == STORAGE_ENGINE_BACKEND_DBENGINE))
634
+ rrdeng_load_metric_finalize(seqh);
635
else
636
#endif
637
- rrddim_query_finalize(handle);
637
+ rrddim_query_finalize(seqh);
638
}
639
640
-time_t rrdeng_load_align_to_optimal_before(struct storage_engine_query_handle *rrddim_handle);
641
-time_t rrddim_query_align_to_optimal_before(struct storage_engine_query_handle *rrddim_handle);
642
-static inline time_t storage_engine_align_to_optimal_before(struct storage_engine_query_handle *handle) {
643
- internal_fatal(!is_valid_backend(handle->backend), "STORAGE: invalid backend");
640
+time_t rrdeng_load_align_to_optimal_before(struct storage_engine_query_handle *seqh);
641
+time_t rrddim_query_align_to_optimal_before(struct storage_engine_query_handle *seqh);
642
+static inline time_t storage_engine_align_to_optimal_before(struct storage_engine_query_handle *seqh) {
643
+ internal_fatal(!is_valid_backend(seqh->seb), "STORAGE: invalid backend");
644
645
#ifdef ENABLE_DBENGINE
646
- if(likely(handle->backend == STORAGE_ENGINE_BACKEND_DBENGINE))
647
- return rrdeng_load_align_to_optimal_before(handle);
646
+ if(likely(seqh->seb == STORAGE_ENGINE_BACKEND_DBENGINE))
647
+ return rrdeng_load_align_to_optimal_before(seqh);
648
#endif
649
- return rrddim_query_align_to_optimal_before(handle);
649
+ return rrddim_query_align_to_optimal_before(seqh);
650
}
651
652
// ------------------------------------------------------------------------
653
// function pointers for all APIs provided by a storage engine
654
typedef struct storage_engine_api {
655
// metric management
656
- STORAGE_METRIC_HANDLE *(*metric_get)(STORAGE_INSTANCE *instance, uuid_t *uuid);
657
- STORAGE_METRIC_HANDLE *(*metric_get_or_create)(RRDDIM *rd, STORAGE_INSTANCE *instance);
656
+ STORAGE_METRIC_HANDLE *(*metric_get)(STORAGE_INSTANCE *si, uuid_t *uuid);
657
+ STORAGE_METRIC_HANDLE *(*metric_get_or_create)(RRDDIM *rd, STORAGE_INSTANCE *si);
658
void (*metric_release)(STORAGE_METRIC_HANDLE *);
659
STORAGE_METRIC_HANDLE *(*metric_dup)(STORAGE_METRIC_HANDLE *);
660
- bool (*metric_retention_by_uuid)(STORAGE_INSTANCE *db_instance, uuid_t *uuid, time_t *first_entry_s, time_t *last_entry_s);
660
+ bool (*metric_retention_by_uuid)(STORAGE_INSTANCE *si, uuid_t *uuid, time_t *first_entry_s, time_t *last_entry_s);
661
} STORAGE_ENGINE_API;
662
663
typedef struct storage_engine {
664
- STORAGE_ENGINE_BACKEND backend;
664
+ STORAGE_ENGINE_BACKEND seb;
665
RRD_MEMORY_MODE id;
666
const char* name;
667
STORAGE_ENGINE_API api;
@@ -779,7 +779,7 @@ struct rrdset {
779
780
rrd_ml_chart_t *ml_chart;
781
782
- STORAGE_METRICS_GROUP *storage_metrics_groups[RRD_STORAGE_TIERS];
782
+ STORAGE_METRICS_GROUP *smg[RRD_STORAGE_TIERS];
783
784
// ------------------------------------------------------------------------
785
// linking to siblings and parents
@@ -1223,7 +1223,7 @@ struct rrdhost {
1223
struct {
1224
RRD_MEMORY_MODE mode; // the db mode for this tier
1225
STORAGE_ENGINE *eng; // the storage engine API for this tier
1226
- STORAGE_INSTANCE *instance; // the db instance for this tier
1226
+ STORAGE_INSTANCE *si; // the db instance for this tier
1227
uint32_t tier_grouping; // tier 0 iterations aggregated on this tier
1228
} db[RRD_STORAGE_TIERS];
1229
@@ -1417,7 +1417,7 @@ extern netdata_rwlock_t rrd_rwlock;
1417
1418
// ----------------------------------------------------------------------------
1419
1420
-bool is_storage_engine_shared(STORAGE_INSTANCE *engine);
1420
+bool is_storage_engine_shared(STORAGE_INSTANCE *si);
1421
void rrdset_index_init(RRDHOST *host);
1422
void rrdset_index_destroy(RRDHOST *host);
1423
database/rrddim.c
+20
-20
@@ -99,9 +99,9 @@ static void rrddim_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, v
99
size_t initialized = 0;
100
for(size_t tier = 0; tier < storage_tiers ; tier++) {
101
STORAGE_ENGINE *eng = host->db[tier].eng;
102
- rd->tiers[tier].backend = eng->backend;
102
+ rd->tiers[tier].seb = eng->seb;
103
rd->tiers[tier].tier_grouping = host->db[tier].tier_grouping;
104
- rd->tiers[tier].db_metric_handle = eng->api.metric_get_or_create(rd, host->db[tier].instance);
104
+ rd->tiers[tier].smh = eng->api.metric_get_or_create(rd, host->db[tier].si);
105
storage_point_unset(rd->tiers[tier].virtual_point);
106
initialized++;
107
@@ -111,7 +111,7 @@ static void rrddim_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, v
111
if(!initialized)
112
netdata_log_error("Failed to initialize all db tiers for chart '%s', dimension '%s", rrdset_name(st), rrddim_name(rd));
113
114
- if(!rd->tiers[0].db_metric_handle)
114
+ if(!rd->tiers[0].smh)
115
netdata_log_error("Failed to initialize the first db tier for chart '%s', dimension '%s", rrdset_name(st), rrddim_name(rd));
116
}
117
@@ -119,9 +119,9 @@ static void rrddim_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, v
119
{
120
size_t initialized = 0;
121
for (size_t tier = 0; tier < storage_tiers; tier++) {
122
- if (rd->tiers[tier].db_metric_handle) {
123
- rd->tiers[tier].db_collection_handle =
124
- storage_metric_store_init(rd->tiers[tier].backend, rd->tiers[tier].db_metric_handle, st->rrdhost->db[tier].tier_grouping * st->update_every, rd->rrdset->storage_metrics_groups[tier]);
122
+ if (rd->tiers[tier].smh) {
123
+ rd->tiers[tier].sch =
124
+ storage_metric_store_init(rd->tiers[tier].seb, rd->tiers[tier].smh, st->rrdhost->db[tier].tier_grouping * st->update_every, rd->rrdset->smg[tier]);
125
initialized++;
126
}
127
}
@@ -176,15 +176,15 @@ bool rrddim_finalize_collection_and_check_retention(RRDDIM *rd) {
176
size_t tiers_available = 0, tiers_said_no_retention = 0;
177
178
for(size_t tier = 0; tier < storage_tiers ;tier++) {
179
- if(!rd->tiers[tier].db_collection_handle)
179
+ if(!rd->tiers[tier].sch)
180
continue;
181
182
tiers_available++;
183
184
- if(storage_engine_store_finalize(rd->tiers[tier].db_collection_handle))
184
+ if(storage_engine_store_finalize(rd->tiers[tier].sch))
185
tiers_said_no_retention++;
186
187
- rd->tiers[tier].db_collection_handle = NULL;
187
+ rd->tiers[tier].sch = NULL;
188
}
189
190
// return true if the dimension has retention in the db
@@ -222,11 +222,11 @@ static void rrddim_delete_callback(const DICTIONARY_ITEM *item __maybe_unused, v
222
rrddim_memory_file_free(rd);
223
224
for(size_t tier = 0; tier < storage_tiers ;tier++) {
225
- if(!rd->tiers[tier].db_metric_handle) continue;
225
+ if(!rd->tiers[tier].smh) continue;
226
227
STORAGE_ENGINE* eng = host->db[tier].eng;
228
- eng->api.metric_release(rd->tiers[tier].db_metric_handle);
229
- rd->tiers[tier].db_metric_handle = NULL;
228
+ eng->api.metric_release(rd->tiers[tier].smh);
229
+ rd->tiers[tier].smh = NULL;
230
}
231
232
if(rd->db.data) {
@@ -257,9 +257,9 @@ static bool rrddim_conflict_callback(const DICTIONARY_ITEM *item __maybe_unused,
257
rc += rrddim_set_divisor(st, rd, ctr->divisor);
258
259
for(size_t tier = 0; tier < storage_tiers ;tier++) {
260
- if (!rd->tiers[tier].db_collection_handle)
261
- rd->tiers[tier].db_collection_handle =
262
- storage_metric_store_init(rd->tiers[tier].backend, rd->tiers[tier].db_metric_handle, st->rrdhost->db[tier].tier_grouping * st->update_every, rd->rrdset->storage_metrics_groups[tier]);
260
+ if (!rd->tiers[tier].sch)
261
+ rd->tiers[tier].sch =
262
+ storage_metric_store_init(rd->tiers[tier].seb, rd->tiers[tier].smh, st->rrdhost->db[tier].tier_grouping * st->update_every, rd->rrdset->smg[tier]);
263
}
264
265
if(rrddim_flag_check(rd, RRDDIM_FLAG_ARCHIVED)) {
@@ -420,10 +420,10 @@ inline int rrddim_set_divisor(RRDSET *st, RRDDIM *rd, int32_t divisor) {
420
// ----------------------------------------------------------------------------
421
422
time_t rrddim_last_entry_s_of_tier(RRDDIM *rd, size_t tier) {
423
- if(unlikely(tier > storage_tiers || !rd->tiers[tier].db_metric_handle))
423
+ if(unlikely(tier > storage_tiers || !rd->tiers[tier].smh))
424
return 0;
425
426
- return storage_engine_latest_time_s(rd->tiers[tier].backend, rd->tiers[tier].db_metric_handle);
426
+ return storage_engine_latest_time_s(rd->tiers[tier].seb, rd->tiers[tier].smh);
427
}
428
429
// get the timestamp of the last entry in the round-robin database
@@ -431,7 +431,7 @@ time_t rrddim_last_entry_s(RRDDIM *rd) {
431
time_t latest_time_s = rrddim_last_entry_s_of_tier(rd, 0);
432
433
for(size_t tier = 1; tier < storage_tiers ;tier++) {
434
- if(unlikely(!rd->tiers[tier].db_metric_handle)) continue;
434
+ if(unlikely(!rd->tiers[tier].smh)) continue;
435
436
time_t t = rrddim_last_entry_s_of_tier(rd, tier);
437
if(t > latest_time_s)
@@ -442,10 +442,10 @@ time_t rrddim_last_entry_s(RRDDIM *rd) {
442
}
443
444
time_t rrddim_first_entry_s_of_tier(RRDDIM *rd, size_t tier) {
445
- if(unlikely(tier > storage_tiers || !rd->tiers[tier].db_metric_handle))
445
+ if(unlikely(tier > storage_tiers || !rd->tiers[tier].smh))
446
return 0;
447
448
- return storage_engine_oldest_time_s(rd->tiers[tier].backend, rd->tiers[tier].db_metric_handle);
448
+ return storage_engine_oldest_time_s(rd->tiers[tier].seb, rd->tiers[tier].smh);
449
}
450
451
time_t rrddim_first_entry_s(RRDDIM *rd) {
database/rrdhost.c
+15
-15
@@ -33,9 +33,9 @@ time_t rrdset_free_obsolete_time_s = 3600;
33
time_t rrdhost_free_orphan_time_s = 3600;
34
time_t rrdhost_free_ephemeral_time_s = 86400;
35
36
-bool is_storage_engine_shared(STORAGE_INSTANCE *engine __maybe_unused) {
36
+bool is_storage_engine_shared(STORAGE_INSTANCE *si __maybe_unused) {
37
#ifdef ENABLE_DBENGINE
38
- if(!rrdeng_is_legacy(engine))
38
+ if(!rrdeng_is_legacy(si))
39
return true;
40
#endif
41
@@ -436,13 +436,13 @@ int is_legacy = 1;
436
host->db[0].tier_grouping = get_tier_grouping(0);
437
438
ret = rrdeng_init(
439
- (struct rrdengine_instance **)&host->db[0].instance,
439
+ (struct rrdengine_instance **)&host->db[0].si,
440
dbenginepath,
441
default_rrdeng_disk_quota_mb,
442
0); // may fail here for legacy dbengine initialization
443
444
if(ret == 0) {
445
- rrdeng_readiness_wait((struct rrdengine_instance *)host->db[0].instance);
445
+ rrdeng_readiness_wait((struct rrdengine_instance *)host->db[0].si);
446
447
// assign the rest of the shared storage instances to it
448
// to allow them collect its metrics too
@@ -450,7 +450,7 @@ int is_legacy = 1;
450
for(size_t tier = 1; tier < storage_tiers ; tier++) {
451
host->db[tier].mode = RRD_MEMORY_MODE_DBENGINE;
452
host->db[tier].eng = storage_engine_get(host->db[tier].mode);
453
- host->db[tier].instance = (STORAGE_INSTANCE *) multidb_ctx[tier];
453
+ host->db[tier].si = (STORAGE_INSTANCE *) multidb_ctx[tier];
454
host->db[tier].tier_grouping = get_tier_grouping(tier);
455
}
456
}
@@ -459,7 +459,7 @@ int is_legacy = 1;
459
for(size_t tier = 0; tier < storage_tiers ; tier++) {
460
host->db[tier].mode = RRD_MEMORY_MODE_DBENGINE;
461
host->db[tier].eng = storage_engine_get(host->db[tier].mode);
462
- host->db[tier].instance = (STORAGE_INSTANCE *)multidb_ctx[tier];
462
+ host->db[tier].si = (STORAGE_INSTANCE *)multidb_ctx[tier];
463
host->db[tier].tier_grouping = get_tier_grouping(tier);
464
}
465
}
@@ -483,7 +483,7 @@ int is_legacy = 1;
483
else {
484
host->db[0].mode = host->rrd_memory_mode;
485
host->db[0].eng = storage_engine_get(host->db[0].mode);
486
- host->db[0].instance = NULL;
486
+ host->db[0].si = NULL;
487
host->db[0].tier_grouping = get_tier_grouping(0);
488
489
#ifdef ENABLE_DBENGINE
@@ -491,7 +491,7 @@ int is_legacy = 1;
491
for(size_t tier = 1; tier < storage_tiers ; tier++) {
492
host->db[tier].mode = RRD_MEMORY_MODE_DBENGINE;
493
host->db[tier].eng = storage_engine_get(host->db[tier].mode);
494
- host->db[tier].instance = (STORAGE_INSTANCE *) multidb_ctx[tier];
494
+ host->db[tier].si = (STORAGE_INSTANCE *) multidb_ctx[tier];
495
host->db[tier].tier_grouping = get_tier_grouping(tier);
496
}
497
#endif
@@ -1267,9 +1267,9 @@ void rrdhost_free___while_having_rrd_wrlock(RRDHOST *host, bool force) {
1267
#ifdef ENABLE_DBENGINE
1268
for(size_t tier = 0; tier < storage_tiers ;tier++) {
1269
if(host->db[tier].mode == RRD_MEMORY_MODE_DBENGINE
1270
- && host->db[tier].instance
1271
- && !is_storage_engine_shared(host->db[tier].instance))
1272
- rrdeng_prepare_exit((struct rrdengine_instance *)host->db[tier].instance);
1270
+ && host->db[tier].si
1271
+ && !is_storage_engine_shared(host->db[tier].si))
1272
+ rrdeng_prepare_exit((struct rrdengine_instance *)host->db[tier].si);
1273
}
1274
#endif
1275
@@ -1288,9 +1288,9 @@ void rrdhost_free___while_having_rrd_wrlock(RRDHOST *host, bool force) {
1288
#ifdef ENABLE_DBENGINE
1289
for(size_t tier = 0; tier < storage_tiers ;tier++) {
1290
if(host->db[tier].mode == RRD_MEMORY_MODE_DBENGINE
1291
- && host->db[tier].instance
1292
- && !is_storage_engine_shared(host->db[tier].instance))
1293
- rrdeng_exit((struct rrdengine_instance *)host->db[tier].instance);
1291
+ && host->db[tier].si
1292
+ && !is_storage_engine_shared(host->db[tier].si))
1293
+ rrdeng_exit((struct rrdengine_instance *)host->db[tier].si);
1294
}
1295
#endif
1296
@@ -1666,7 +1666,7 @@ void rrdhost_cleanup_all(void) {
1666
rrdhost_foreach_read(host) {
1667
if (host != localhost && rrdhost_option_check(host, RRDHOST_OPTION_DELETE_ORPHAN_HOST) && !host->receiver
1668
/* don't delete multi-host DB host files */
1669
- && !(host->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE && is_storage_engine_shared(host->db[0].instance))
1669
+ && !(host->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE && is_storage_engine_shared(host->db[0].si))
1670
)
1671
rrdhost_delete_charts(host);
1672
else
database/rrdset.c
+11
-11
@@ -283,7 +283,7 @@ static void rrdset_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, v
283
STORAGE_ENGINE *eng = st->rrdhost->db[tier].eng;
284
if(!eng) continue;
285
286
- st->storage_metrics_groups[tier] = storage_engine_metrics_group_get(eng->backend, host->db[tier].instance, &st->chart_uuid);
286
+ st->smg[tier] = storage_engine_metrics_group_get(eng->seb, host->db[tier].si, &st->chart_uuid);
287
}
288
}
289
@@ -327,9 +327,9 @@ void rrdset_finalize_collection(RRDSET *st, bool dimensions_too) {
327
STORAGE_ENGINE *eng = st->rrdhost->db[tier].eng;
328
if(!eng) continue;
329
330
- if(st->storage_metrics_groups[tier]) {
331
- storage_engine_metrics_group_release(eng->backend, host->db[tier].instance, st->storage_metrics_groups[tier]);
332
- st->storage_metrics_groups[tier] = NULL;
330
+ if(st->smg[tier]) {
331
+ storage_engine_metrics_group_release(eng->seb, host->db[tier].si, st->smg[tier]);
332
+ st->smg[tier] = NULL;
333
}
334
}
335
@@ -888,7 +888,7 @@ void rrdset_reset(RRDSET *st) {
888
889
if(!rrddim_flag_check(rd, RRDDIM_FLAG_ARCHIVED)) {
890
for(size_t tier = 0; tier < storage_tiers ;tier++)
891
- storage_engine_store_flush(rd->tiers[tier].db_collection_handle);
891
+ storage_engine_store_flush(rd->tiers[tier].sch);
892
}
893
}
894
rrddim_foreach_done(rd);
@@ -1267,7 +1267,7 @@ void store_metric_at_tier(RRDDIM *rd, size_t tier, struct rrddim_tier *t, STORAG
1267
if (likely(!storage_point_is_unset(t->virtual_point))) {
1268
1269
storage_engine_store_metric(
1270
- t->db_collection_handle,
1270
+ t->sch,
1271
t->next_point_end_time_s * USEC_PER_SEC,
1272
t->virtual_point.sum,
1273
t->virtual_point.min,
@@ -1278,7 +1278,7 @@ void store_metric_at_tier(RRDDIM *rd, size_t tier, struct rrddim_tier *t, STORAG
1278
}
1279
else {
1280
storage_engine_store_metric(
1281
- t->db_collection_handle,
1281
+ t->sch,
1282
t->next_point_end_time_s * USEC_PER_SEC,
1283
NAN,
1284
NAN,
@@ -1357,7 +1357,7 @@ void rrddim_store_metric(RRDDIM *rd, usec_t point_end_time_ut, NETDATA_DOUBLE n,
1357
#endif // NETDATA_LOG_COLLECTION_ERRORS
1358
1359
// store the metric on tier 0
1360
- storage_engine_store_metric(rd->tiers[0].db_collection_handle, point_end_time_ut,
1360
+ storage_engine_store_metric(rd->tiers[0].sch, point_end_time_ut,
1361
n, 0, 0,
1362
1, 0, flags);
1363
@@ -1377,7 +1377,7 @@ void rrddim_store_metric(RRDDIM *rd, usec_t point_end_time_ut, NETDATA_DOUBLE n,
1377
};
1378
1379
for(size_t tier = 1; tier < storage_tiers ;tier++) {
1380
- if(unlikely(!rd->tiers[tier].db_metric_handle)) continue;
1380
+ if(unlikely(!rd->tiers[tier].smh)) continue;
1381
1382
struct rrddim_tier *t = &rd->tiers[tier];
1383
@@ -2140,9 +2140,9 @@ time_t rrdset_set_update_every_s(RRDSET *st, time_t update_every_s) {
2140
RRDDIM *rd;
2141
rrddim_foreach_read(rd, st) {
2142
for (size_t tier = 0; tier < storage_tiers; tier++) {
2143
- if (rd->tiers[tier].db_collection_handle)
2143
+ if (rd->tiers[tier].sch)
2144
storage_engine_store_change_collection_frequency(
2145
- rd->tiers[tier].db_collection_handle,
2145
+ rd->tiers[tier].sch,
2146
(int)(st->rrdhost->db[tier].tier_grouping * st->update_every));
2147
}
2148
}
database/storage_engine.c
+6
-6
@@ -10,7 +10,7 @@ static STORAGE_ENGINE engines[] = {
10
{
11
.id = RRD_MEMORY_MODE_NONE,
12
.name = RRD_MEMORY_MODE_NONE_NAME,
13
- .backend = STORAGE_ENGINE_BACKEND_RRDDIM,
13
+ .seb = STORAGE_ENGINE_BACKEND_RRDDIM,
14
.api = {
15
.metric_get = rrddim_metric_get,
16
.metric_get_or_create = rrddim_metric_get_or_create,
@@ -22,7 +22,7 @@ static STORAGE_ENGINE engines[] = {
22
{
23
.id = RRD_MEMORY_MODE_RAM,
24
.name = RRD_MEMORY_MODE_RAM_NAME,
25
- .backend = STORAGE_ENGINE_BACKEND_RRDDIM,
25
+ .seb = STORAGE_ENGINE_BACKEND_RRDDIM,
26
.api = {
27
.metric_get = rrddim_metric_get,
28
.metric_get_or_create = rrddim_metric_get_or_create,
@@ -34,7 +34,7 @@ static STORAGE_ENGINE engines[] = {
34
{
35
.id = RRD_MEMORY_MODE_MAP,
36
.name = RRD_MEMORY_MODE_MAP_NAME,
37
- .backend = STORAGE_ENGINE_BACKEND_RRDDIM,
37
+ .seb = STORAGE_ENGINE_BACKEND_RRDDIM,
38
.api = {
39
.metric_get = rrddim_metric_get,
40
.metric_get_or_create = rrddim_metric_get_or_create,
@@ -46,7 +46,7 @@ static STORAGE_ENGINE engines[] = {
46
{
47
.id = RRD_MEMORY_MODE_SAVE,
48
.name = RRD_MEMORY_MODE_SAVE_NAME,
49
- .backend = STORAGE_ENGINE_BACKEND_RRDDIM,
49
+ .seb = STORAGE_ENGINE_BACKEND_RRDDIM,
50
.api = {
51
.metric_get = rrddim_metric_get,
52
.metric_get_or_create = rrddim_metric_get_or_create,
@@ -58,7 +58,7 @@ static STORAGE_ENGINE engines[] = {
58
{
59
.id = RRD_MEMORY_MODE_ALLOC,
60
.name = RRD_MEMORY_MODE_ALLOC_NAME,
61
- .backend = STORAGE_ENGINE_BACKEND_RRDDIM,
61
+ .seb = STORAGE_ENGINE_BACKEND_RRDDIM,
62
.api = {
63
.metric_get = rrddim_metric_get,
64
.metric_get_or_create = rrddim_metric_get_or_create,
@@ -71,7 +71,7 @@ static STORAGE_ENGINE engines[] = {
71
{
72
.id = RRD_MEMORY_MODE_DBENGINE,
73
.name = RRD_MEMORY_MODE_DBENGINE_NAME,
74
- .backend = STORAGE_ENGINE_BACKEND_DBENGINE,
74
+ .seb = STORAGE_ENGINE_BACKEND_DBENGINE,
75
.api = {
76
.metric_get = rrdeng_metric_get,
77
.metric_get_or_create = rrdeng_metric_get_or_create,
exporting/process_data.c
+3
-3
@@ -77,8 +77,8 @@ NETDATA_DOUBLE exporting_calculate_value_from_stored_data(
77
time_t before = instance->before;
78
79
// find the edges of the rrd database for this chart
80
- time_t first_t = storage_engine_oldest_time_s(rd->tiers[0].backend, rd->tiers[0].db_metric_handle);
81
- time_t last_t = storage_engine_latest_time_s(rd->tiers[0].backend, rd->tiers[0].db_metric_handle);
80
+ time_t first_t = storage_engine_oldest_time_s(rd->tiers[0].seb, rd->tiers[0].smh);
81
+ time_t last_t = storage_engine_latest_time_s(rd->tiers[0].seb, rd->tiers[0].smh);
82
time_t update_every = st->update_every;
83
struct storage_engine_query_handle handle;
84
@@ -126,7 +126,7 @@ NETDATA_DOUBLE exporting_calculate_value_from_stored_data(
126
size_t counter = 0;
127
NETDATA_DOUBLE sum = 0;
128
129
- for (storage_engine_query_init(rd->tiers[0].backend, rd->tiers[0].db_metric_handle, &handle, after, before, STORAGE_PRIORITY_SYNCHRONOUS); !storage_engine_query_is_finished(&handle);) {
129
+ for (storage_engine_query_init(rd->tiers[0].seb, rd->tiers[0].smh, &handle, after, before, STORAGE_PRIORITY_SYNCHRONOUS); !storage_engine_query_is_finished(&handle);) {
130
STORAGE_POINT sp = storage_engine_query_next_metric(&handle);
131
points_read++;
132
exporting/tests/netdata_doubles.c
+6
-6
@@ -182,25 +182,25 @@ void rrdset_update_heterogeneous_flag(RRDSET *st)
182
(void)st;
183
}
184
185
-time_t __mock_rrddim_query_oldest_time(STORAGE_METRIC_HANDLE *db_metric_handle)
185
+time_t __mock_rrddim_query_oldest_time(STORAGE_METRIC_HANDLE *smh)
186
{
187
- (void)db_metric_handle;
187
+ (void)smh;
188
189
function_called();
190
return mock_type(time_t);
191
}
192
193
-time_t __mock_rrddim_query_latest_time(STORAGE_METRIC_HANDLE *db_metric_handle)
193
+time_t __mock_rrddim_query_latest_time(STORAGE_METRIC_HANDLE *smh)
194
{
195
- (void)db_metric_handle;
195
+ (void)smh;
196
197
function_called();
198
return mock_type(time_t);
199
}
200
201
-void __mock_rrddim_query_init(STORAGE_METRIC_HANDLE *db_metric_handle, struct rrddim_query_handle *handle, time_t start_time, time_t end_time)
201
+void __mock_rrddim_query_init(STORAGE_METRIC_HANDLE *smh, struct rrddim_query_handle *handle, time_t start_time, time_t end_time)
202
{
203
- (void)db_metric_handle;
203
+ (void)smh;
204
(void)handle;
205
206
function_called();
exporting/tests/test_exporting_engine.h
+3
-3
@@ -55,9 +55,9 @@ int __wrap_connect_to_one_of(
55
size_t *reconnects_counter,
56
char *connected_to,
57
size_t connected_to_size);
58
-time_t __mock_rrddim_query_oldest_time(STORAGE_METRIC_HANDLE *db_metric_handle);
59
-time_t __mock_rrddim_query_latest_time(STORAGE_METRIC_HANDLE *db_metric_handle);
60
-void __mock_rrddim_query_init(STORAGE_METRIC_HANDLE *db_metric_handle, struct rrddim_query_handle *handle, time_t start_time, time_t end_time);
58
+time_t __mock_rrddim_query_oldest_time(STORAGE_METRIC_HANDLE *smh);
59
+time_t __mock_rrddim_query_latest_time(STORAGE_METRIC_HANDLE *smh);
60
+void __mock_rrddim_query_init(STORAGE_METRIC_HANDLE *smh, struct rrddim_query_handle *handle, time_t start_time, time_t end_time);
61
int __mock_rrddim_query_is_finished(struct rrddim_query_handle *handle);
62
STORAGE_POINT __mock_rrddim_query_next_metric(struct rrddim_query_handle *handle);
63
void __mock_rrddim_query_finalize(struct rrddim_query_handle *handle);
ml/ml.cc
+1
-1
@@ -358,7 +358,7 @@ ml_dimension_calculated_numbers(ml_training_thread_t *training_thread, ml_dimens
358
*/
359
struct storage_engine_query_handle handle;
360
361
- storage_engine_query_init(dim->rd->tiers[0].backend, dim->rd->tiers[0].db_metric_handle, &handle,
361
+ storage_engine_query_init(dim->rd->tiers[0].seb, dim->rd->tiers[0].smh, &handle,
362
training_response.query_after_t, training_response.query_before_t,
363
STORAGE_PRIORITY_BEST_EFFORT);
364
streaming/replication.c
+2
-2
@@ -162,7 +162,7 @@ static struct replication_query *replication_query_prepare(
162
}
163
}
164
165
- q->backend = st->rrdhost->db[0].eng->backend;
165
+ q->backend = st->rrdhost->db[0].eng->seb;
166
167
// prepare our array of dimensions
168
size_t count = 0;
@@ -184,7 +184,7 @@ static struct replication_query *replication_query_prepare(
184
d->rda = dictionary_acquired_item_dup(rd_dfe.dict, rd_dfe.item);
185
d->rd = rd;
186
187
- storage_engine_query_init(q->backend, rd->tiers[0].db_metric_handle, &d->handle, q->query.after, q->query.before,
187
+ storage_engine_query_init(q->backend, rd->tiers[0].smh, &d->handle, q->query.after, q->query.before,
188
q->query.locked_data_collection ? STORAGE_PRIORITY_HIGH : STORAGE_PRIORITY_LOW);
189
d->enabled = true;
190
d->skip = false;
web/api/queries/query.c
+19
-19
@@ -939,7 +939,7 @@ static inline long rrdr_line_init(RRDR *r __maybe_unused, time_t t __maybe_unuse
939
// tier management
940
941
static bool query_metric_is_valid_tier(QUERY_METRIC *qm, size_t tier) {
942
- if(!qm->tiers[tier].db_metric_handle || !qm->tiers[tier].db_first_time_s || !qm->tiers[tier].db_last_time_s || !qm->tiers[tier].db_update_every_s)
942
+ if(!qm->tiers[tier].smh || !qm->tiers[tier].db_first_time_s || !qm->tiers[tier].db_last_time_s || !qm->tiers[tier].db_update_every_s)
943
return false;
944
945
return true;
@@ -949,12 +949,12 @@ static size_t query_metric_first_working_tier(QUERY_METRIC *qm) {
949
for(size_t tier = 0; tier < storage_tiers ; tier++) {
950
951
// find the db time-range for this tier for all metrics
952
- STORAGE_METRIC_HANDLE *db_metric_handle = qm->tiers[tier].db_metric_handle;
952
+ STORAGE_METRIC_HANDLE *smh = qm->tiers[tier].smh;
953
time_t first_time_s = qm->tiers[tier].db_first_time_s;
954
time_t last_time_s = qm->tiers[tier].db_last_time_s;
955
time_t update_every_s = qm->tiers[tier].db_update_every_s;
956
957
- if(!db_metric_handle || !first_time_s || !last_time_s || !update_every_s)
957
+ if(!smh || !first_time_s || !last_time_s || !update_every_s)
958
continue;
959
960
return tier;
@@ -1018,12 +1018,12 @@ static size_t query_metric_best_tier_for_timeframe(QUERY_METRIC *qm, time_t afte
1018
for(size_t tier = 0; tier < storage_tiers ; tier++) {
1019
1020
// find the db time-range for this tier for all metrics
1021
- STORAGE_METRIC_HANDLE *db_metric_handle = qm->tiers[tier].db_metric_handle;
1021
+ STORAGE_METRIC_HANDLE *smh = qm->tiers[tier].smh;
1022
time_t first_time_s = qm->tiers[tier].db_first_time_s;
1023
time_t last_time_s = qm->tiers[tier].db_last_time_s;
1024
time_t update_every_s = qm->tiers[tier].db_update_every_s;
1025
1026
- if( !db_metric_handle ||
1026
+ if( !smh ||
1027
!first_time_s ||
1028
!last_time_s ||
1029
!update_every_s ||
@@ -1176,7 +1176,7 @@ typedef struct query_engine_ops {
1176
// storage queries
1177
size_t tier;
1178
struct query_metric_tier *tier_ptr;
1179
- struct storage_engine_query_handle *handle;
1179
+ struct storage_engine_query_handle *seqh;
1180
1181
// aggregating points over time
1182
size_t group_points_non_zero;
@@ -1261,7 +1261,7 @@ static void query_planer_initialize_plans(QUERY_ENGINE_OPS *ops) {
1261
1262
struct query_metric_tier *tier_ptr = &qm->tiers[tier];
1263
STORAGE_ENGINE *eng = query_metric_storage_engine(ops->r->internal.qt, qm, tier);
1264
- storage_engine_query_init(eng->backend, tier_ptr->db_metric_handle, &ops->plans[p].handle,
1264
+ storage_engine_query_init(eng->seb, tier_ptr->smh, &ops->plans[p].handle,
1265
after, before, ops->r->internal.qt->request.priority);
1266
1267
ops->plans[p].initialized = true;
@@ -1297,7 +1297,7 @@ static void query_planer_activate_plan(QUERY_ENGINE_OPS *ops, size_t plan_id, ti
1297
1298
ops->tier = qm->plan.array[plan_id].tier;
1299
ops->tier_ptr = &qm->tiers[ops->tier];
1300
- ops->handle = &ops->plans[plan_id].handle;
1300
+ ops->seqh = &ops->plans[plan_id].handle;
1301
ops->current_plan = plan_id;
1302
1303
if(plan_id + 1 < qm->plan.used && qm->plan.array[plan_id + 1].after < qm->plan.array[plan_id].before)
@@ -1625,7 +1625,7 @@ static void rrd2rrdr_query_execute(RRDR *r, size_t dim_id_in_rrdr, QUERY_ENGINE_
1625
last1_point = new_point;
1626
}
1627
1628
- if(unlikely(storage_engine_query_is_finished(ops->handle))) {
1628
+ if(unlikely(storage_engine_query_is_finished(ops->seqh))) {
1629
query_is_finished_counter++;
1630
1631
if(count_same_end_time != 0) {
@@ -1648,7 +1648,7 @@ static void rrd2rrdr_query_execute(RRDR *r, size_t dim_id_in_rrdr, QUERY_ENGINE_
1648
STORAGE_POINT sp;
1649
if(likely(storage_point_is_unset(next1_point))) {
1650
db_points_read_since_plan_switch++;
1651
- sp = storage_engine_query_next_metric(ops->handle);
1651
+ sp = storage_engine_query_next_metric(ops->seqh);
1652
ops->db_points_read_per_tier[ops->tier]++;
1653
ops->db_total_points_read++;
1654
@@ -1674,7 +1674,7 @@ static void rrd2rrdr_query_execute(RRDR *r, size_t dim_id_in_rrdr, QUERY_ENGINE_
1674
// A. the entire point of the previous plan is to the future of point from the next plan
1675
// B. part of the point of the previous plan overlaps with the point from the next plan
1676
1677
- STORAGE_POINT sp2 = storage_engine_query_next_metric(ops->handle);
1677
+ STORAGE_POINT sp2 = storage_engine_query_next_metric(ops->seqh);
1678
ops->db_points_read_per_tier[ops->tier]++;
1679
ops->db_total_points_read++;
1680
@@ -1960,7 +1960,7 @@ void rrdr_fill_tier_gap_from_smaller_tiers(RRDDIM *rd, size_t tier, time_t now_s
1960
struct rrddim_tier *t = &rd->tiers[tier];
1961
if(unlikely(!t)) return;
1962
1963
- time_t latest_time_s = storage_engine_latest_time_s(t->backend, t->db_metric_handle);
1963
+ time_t latest_time_s = storage_engine_latest_time_s(t->seb, t->smh);
1964
time_t granularity = (time_t)t->tier_grouping * (time_t)rd->rrdset->update_every;
1965
time_t time_diff = now_s - latest_time_s;
1966
@@ -1970,25 +1970,25 @@ void rrdr_fill_tier_gap_from_smaller_tiers(RRDDIM *rd, size_t tier, time_t now_s
1970
// there is really nothing we can do
1971
if(now_s <= latest_time_s || time_diff < granularity) return;
1972
1973
- struct storage_engine_query_handle handle;
1973
+ struct storage_engine_query_handle seqh;
1974
1975
// for each lower tier
1976
for(int read_tier = (int)tier - 1; read_tier >= 0 ; read_tier--){
1977
- time_t smaller_tier_first_time = storage_engine_oldest_time_s(rd->tiers[read_tier].backend, rd->tiers[read_tier].db_metric_handle);
1978
- time_t smaller_tier_last_time = storage_engine_latest_time_s(rd->tiers[read_tier].backend, rd->tiers[read_tier].db_metric_handle);
1977
+ time_t smaller_tier_first_time = storage_engine_oldest_time_s(rd->tiers[read_tier].seb, rd->tiers[read_tier].smh);
1978
+ time_t smaller_tier_last_time = storage_engine_latest_time_s(rd->tiers[read_tier].seb, rd->tiers[read_tier].smh);
1979
if(smaller_tier_last_time <= latest_time_s) continue; // it is as bad as we are
1980
1981
long after_wanted = (latest_time_s < smaller_tier_first_time) ? smaller_tier_first_time : latest_time_s;
1982
long before_wanted = smaller_tier_last_time;
1983
1984
struct rrddim_tier *tmp = &rd->tiers[read_tier];
1985
- storage_engine_query_init(tmp->backend, tmp->db_metric_handle, &handle, after_wanted, before_wanted, STORAGE_PRIORITY_HIGH);
1985
+ storage_engine_query_init(tmp->seb, tmp->smh, &seqh, after_wanted, before_wanted, STORAGE_PRIORITY_HIGH);
1986
1987
size_t points_read = 0;
1988
1989
- while(!storage_engine_query_is_finished(&handle)) {
1989
+ while(!storage_engine_query_is_finished(&seqh)) {
1990
1991
- STORAGE_POINT sp = storage_engine_query_next_metric(&handle);
1991
+ STORAGE_POINT sp = storage_engine_query_next_metric(&seqh);
1992
points_read++;
1993
1994
if(sp.end_time_s > latest_time_s) {
@@ -1997,7 +1997,7 @@ void rrdr_fill_tier_gap_from_smaller_tiers(RRDDIM *rd, size_t tier, time_t now_s
1997
}
1998
}
1999
2000
- storage_engine_query_finalize(&handle);
2000
+ storage_engine_query_finalize(&seqh);
2001
store_metric_collection_completed();
2002
global_statistics_backfill_query_completed(points_read);
2003