Proper locking when searching for datafile (#21302)
* Proper locking when searching for datafile * Allow update_metrics_first_time_s to handle NULL first datafile
Stelios Fragkakis committed
Nov 18, 2025 at 20:08 UTC
746cc02077813abd67f08df599b798e259ab1de9
1 file changed
+6
-3
src/database/engine/rrdengine.c
+6
-3
@@ -1371,8 +1371,11 @@ static void update_metrics_first_time_s(struct rrdengine_instance *ctx, struct r
1371
added++;
1372
}
1373
1374
- netdata_log_info("DBENGINE: recalculating tier %d retention for %zu metrics starting with datafile %u",
1375
- ctx->config.tier, count, first_datafile_remaining->fileno);
1374
+ netdata_log_info(
1375
+ "DBENGINE: recalculating tier %d retention for %zu metrics starting with datafile %u",
1376
+ ctx->config.tier,
1377
+ count,
1378
+ first_datafile_remaining ? first_datafile_remaining->fileno : 0);
1379
1380
journalfile_v2_data_release(journalfile);
1381
@@ -1499,7 +1502,7 @@ void datafile_delete(
1502
ctx->config.dbfiles_path, datafile->tier, datafile->fileno);
1503
1504
if (update_retention)
1502
- update_metrics_first_time_s(ctx, datafile, get_next_datafile(datafile, NULL, true), worker);
1505
+ update_metrics_first_time_s(ctx, datafile, get_next_datafile(datafile, NULL, false), worker);
1506
1507
// if (!ctx_is_available_for_queries(ctx)) {
1508
// // agent is shutting down, we cannot continue