summaryrefslogtreecommitdiffstats
path: root/database/engine
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-12-01 06:15:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-12-01 06:15:04 +0000
commite970e0b37b8bd7f246feb3f70c4136418225e434 (patch)
tree0b67c0ca45f56f2f9d9c5c2e725279ecdf52d2eb /database/engine
parentAdding upstream version 1.31.0. (diff)
downloadnetdata-e970e0b37b8bd7f246feb3f70c4136418225e434.tar.xz
netdata-e970e0b37b8bd7f246feb3f70c4136418225e434.zip
Adding upstream version 1.32.0.upstream/1.32.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'database/engine')
-rw-r--r--database/engine/datafile.c4
-rw-r--r--database/engine/journalfile.c11
-rw-r--r--database/engine/metadata_log/logfile.c2
-rw-r--r--database/engine/metadata_log/metalogpluginsd.h6
-rw-r--r--database/engine/pagecache.c11
-rw-r--r--database/engine/rrdengine.c3
-rw-r--r--database/engine/rrdengine.h2
-rwxr-xr-xdatabase/engine/rrdengineapi.c21
-rw-r--r--database/engine/rrdengineapi.h2
-rw-r--r--database/engine/rrdenginelib.h8
10 files changed, 34 insertions, 36 deletions
diff --git a/database/engine/datafile.c b/database/engine/datafile.c
index 7a052f963..d42311079 100644
--- a/database/engine/datafile.c
+++ b/database/engine/datafile.c
@@ -51,7 +51,7 @@ static void datafile_init(struct rrdengine_datafile *datafile, struct rrdengine_
void generate_datafilepath(struct rrdengine_datafile *datafile, char *str, size_t maxlen)
{
- (void) snprintf(str, maxlen, "%s/" DATAFILE_PREFIX RRDENG_FILE_NUMBER_PRINT_TMPL DATAFILE_EXTENSION,
+ (void) snprintfz(str, maxlen, "%s/" DATAFILE_PREFIX RRDENG_FILE_NUMBER_PRINT_TMPL DATAFILE_EXTENSION,
datafile->ctx->dbfiles_path, datafile->tier, datafile->fileno);
}
@@ -457,4 +457,4 @@ void finalize_data_files(struct rrdengine_instance *ctx)
freez(datafile);
}
-} \ No newline at end of file
+}
diff --git a/database/engine/journalfile.c b/database/engine/journalfile.c
index 9fecc48ff..640656161 100644
--- a/database/engine/journalfile.c
+++ b/database/engine/journalfile.c
@@ -94,7 +94,7 @@ void * wal_get_transaction_buffer(struct rrdengine_worker_config* wc, unsigned s
void generate_journalfilepath(struct rrdengine_datafile *datafile, char *str, size_t maxlen)
{
- (void) snprintf(str, maxlen, "%s/" WALFILE_PREFIX RRDENG_FILE_NUMBER_PRINT_TMPL WALFILE_EXTENSION,
+ (void) snprintfz(str, maxlen, "%s/" WALFILE_PREFIX RRDENG_FILE_NUMBER_PRINT_TMPL WALFILE_EXTENSION,
datafile->ctx->dbfiles_path, datafile->tier, datafile->fileno);
}
@@ -428,8 +428,9 @@ static uint64_t iterate_transactions(struct rrdengine_instance *ctx, struct rrde
iov = uv_buf_init(buf, size_bytes);
ret = uv_fs_read(NULL, &req, file, &iov, 1, pos, NULL);
if (ret < 0) {
- fatal("uv_fs_read: %s", uv_strerror(ret));
- /*uv_fs_req_cleanup(&req);*/
+ error("uv_fs_read: pos=%lu, %s", pos, uv_strerror(ret));
+ uv_fs_req_cleanup(&req);
+ goto skip_file;
}
fatal_assert(req.result >= 0);
uv_fs_req_cleanup(&req);
@@ -451,7 +452,7 @@ static uint64_t iterate_transactions(struct rrdengine_instance *ctx, struct rrde
max_id = MAX(max_id, id);
}
}
-
+skip_file:
free(buf);
return max_id;
}
@@ -512,4 +513,4 @@ void init_commit_log(struct rrdengine_instance *ctx)
ctx->commit_log.buf = NULL;
ctx->commit_log.buf_pos = 0;
ctx->commit_log.transaction_id = 1;
-} \ No newline at end of file
+}
diff --git a/database/engine/metadata_log/logfile.c b/database/engine/metadata_log/logfile.c
index b7c5c0618..f5bd9b2d2 100644
--- a/database/engine/metadata_log/logfile.c
+++ b/database/engine/metadata_log/logfile.c
@@ -6,7 +6,7 @@
void generate_metadata_logfile_path(struct metadata_logfile *metalogfile, char *str, size_t maxlen)
{
- (void) snprintf(str, maxlen, "%s/" METALOG_PREFIX METALOG_FILE_NUMBER_PRINT_TMPL METALOG_EXTENSION,
+ (void) snprintfz(str, maxlen, "%s/" METALOG_PREFIX METALOG_FILE_NUMBER_PRINT_TMPL METALOG_EXTENSION,
metalogfile->ctx->rrdeng_ctx->dbfiles_path, metalogfile->starting_fileno, metalogfile->fileno);
}
diff --git a/database/engine/metadata_log/metalogpluginsd.h b/database/engine/metadata_log/metalogpluginsd.h
index 96808aaa2..4fd8c3900 100644
--- a/database/engine/metadata_log/metalogpluginsd.h
+++ b/database/engine/metadata_log/metalogpluginsd.h
@@ -3,9 +3,9 @@
#ifndef NETDATA_METALOGPLUGINSD_H
#define NETDATA_METALOGPLUGINSD_H
-#include "../../../collectors/plugins.d/pluginsd_parser.h"
-#include "../../../collectors/plugins.d/plugins_d.h"
-#include "../../../parser/parser.h"
+#include "collectors/plugins.d/pluginsd_parser.h"
+#include "collectors/plugins.d/plugins_d.h"
+#include "parser/parser.h"
struct metalog_pluginsd_state {
struct metalog_instance *ctx;
diff --git a/database/engine/pagecache.c b/database/engine/pagecache.c
index f17afc22b..90423176c 100644
--- a/database/engine/pagecache.c
+++ b/database/engine/pagecache.c
@@ -299,10 +299,15 @@ static void pg_cache_reserve_pages(struct rrdengine_instance *ctx, unsigned numb
destroy_completion(&compl);
if (unlikely(failures > 1)) {
- unsigned long slots;
+ unsigned long slots, usecs_to_sleep;
/* exponential backoff */
slots = random() % (2LU << MIN(failures, FAILURES_CEILING));
- (void)sleep_usec(slots * exp_backoff_slot_usec);
+ usecs_to_sleep = slots * exp_backoff_slot_usec;
+
+ if (usecs_to_sleep >= USEC_PER_SEC)
+ error("Page cache is full. Sleeping for %llu second(s).", usecs_to_sleep / USEC_PER_SEC);
+
+ (void)sleep_usec(usecs_to_sleep);
}
uv_rwlock_wrlock(&pg_cache->pg_cache_rwlock);
}
@@ -1243,4 +1248,4 @@ void free_page_cache(struct rrdengine_instance *ctx)
bytes_freed += ret_Judy;
info("Freed %lu bytes of memory from page cache.", bytes_freed);
-} \ No newline at end of file
+}
diff --git a/database/engine/rrdengine.c b/database/engine/rrdengine.c
index 0c4a401cb..54a9cdf8d 100644
--- a/database/engine/rrdengine.c
+++ b/database/engine/rrdengine.c
@@ -336,7 +336,7 @@ after_crc_check:
/* care, we don't hold the descriptor mutex */
if (have_read_error) {
/* Applications should make sure NULL values match 0 as does SN_EMPTY_SLOT */
- memset(page, 0, descr->page_length);
+ memset(page, SN_EMPTY_SLOT, descr->page_length);
} else if (RRD_NO_COMPRESSION == header->compression_algorithm) {
(void) memcpy(page, xt_io_descr->buf + payload_offset + page_offset, descr->page_length);
} else {
@@ -861,6 +861,7 @@ static void after_delete_old_data(struct rrdengine_worker_config* wc)
wc->now_deleting_files = NULL;
wc->cleanup_thread_deleting_files = 0;
+ aclk_data_rotated();
/* interrupt event loop */
uv_stop(wc->loop);
diff --git a/database/engine/rrdengine.h b/database/engine/rrdengine.h
index 07cc1479d..b0c8e4d02 100644
--- a/database/engine/rrdengine.h
+++ b/database/engine/rrdengine.h
@@ -11,7 +11,7 @@
#include <Judy.h>
#include <openssl/sha.h>
#include <openssl/evp.h>
-#include "../../daemon/common.h"
+#include "daemon/common.h"
#include "../rrd.h"
#include "rrddiskprotocol.h"
#include "rrdenginelib.h"
diff --git a/database/engine/rrdengineapi.c b/database/engine/rrdengineapi.c
index d847969e8..d81b95805 100755
--- a/database/engine/rrdengineapi.c
+++ b/database/engine/rrdengineapi.c
@@ -49,7 +49,7 @@ void rrdeng_convert_legacy_uuid_to_multihost(char machine_guid[GUID_LEN + 1], uu
memcpy(ret_uuid, hash_value, sizeof(uuid_t));
}
-void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid)
+void rrdeng_metric_init(RRDDIM *rd)
{
struct page_cache *pg_cache;
struct rrdengine_instance *ctx;
@@ -68,7 +68,6 @@ void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid)
pg_cache = &ctx->pg_cache;
rrdeng_generate_legacy_uuid(rd->id, rd->rrdset->id, &legacy_uuid);
- rd->state->metric_uuid = dim_uuid;
if (host != localhost && host->rrdeng_ctx == &multidb_ctx)
is_multihost_child = 1;
@@ -82,20 +81,17 @@ void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid)
/* First time we see the legacy UUID or metric belongs to child host in multi-host DB.
* Drop legacy support, normal path */
- if (unlikely(!rd->state->metric_uuid))
- rd->state->metric_uuid = create_dimension_uuid(rd->rrdset, rd);
-
uv_rwlock_rdlock(&pg_cache->metrics_index.lock);
- PValue = JudyHSGet(pg_cache->metrics_index.JudyHS_array, rd->state->metric_uuid, sizeof(uuid_t));
+ PValue = JudyHSGet(pg_cache->metrics_index.JudyHS_array, &rd->state->metric_uuid, sizeof(uuid_t));
if (likely(NULL != PValue)) {
page_index = *PValue;
}
uv_rwlock_rdunlock(&pg_cache->metrics_index.lock);
if (NULL == PValue) {
uv_rwlock_wrlock(&pg_cache->metrics_index.lock);
- PValue = JudyHSIns(&pg_cache->metrics_index.JudyHS_array, rd->state->metric_uuid, sizeof(uuid_t), PJE0);
+ PValue = JudyHSIns(&pg_cache->metrics_index.JudyHS_array, &rd->state->metric_uuid, sizeof(uuid_t), PJE0);
fatal_assert(NULL == *PValue); /* TODO: figure out concurrency model */
- *PValue = page_index = create_page_index(rd->state->metric_uuid);
+ *PValue = page_index = create_page_index(&rd->state->metric_uuid);
page_index->prev = pg_cache->metrics_index.last_page_index;
pg_cache->metrics_index.last_page_index = page_index;
uv_rwlock_wrunlock(&pg_cache->metrics_index.lock);
@@ -106,15 +102,12 @@ void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid)
rrdeng_convert_legacy_uuid_to_multihost(rd->rrdset->rrdhost->machine_guid, &legacy_uuid,
&multihost_legacy_uuid);
- if (unlikely(!rd->state->metric_uuid))
- rd->state->metric_uuid = mallocz(sizeof(uuid_t));
-
- int need_to_store = (dim_uuid == NULL || uuid_compare(*rd->state->metric_uuid, multihost_legacy_uuid));
+ int need_to_store = uuid_compare(rd->state->metric_uuid, multihost_legacy_uuid);
- uuid_copy(*rd->state->metric_uuid, multihost_legacy_uuid);
+ uuid_copy(rd->state->metric_uuid, multihost_legacy_uuid);
if (unlikely(need_to_store))
- (void)sql_store_dimension(rd->state->metric_uuid, rd->rrdset->chart_uuid, rd->id, rd->name, rd->multiplier, rd->divisor,
+ (void)sql_store_dimension(&rd->state->metric_uuid, rd->rrdset->chart_uuid, rd->id, rd->name, rd->multiplier, rd->divisor,
rd->algorithm);
}
diff --git a/database/engine/rrdengineapi.h b/database/engine/rrdengineapi.h
index 00e55e662..d263259b6 100644
--- a/database/engine/rrdengineapi.h
+++ b/database/engine/rrdengineapi.h
@@ -36,7 +36,7 @@ extern void rrdeng_convert_legacy_uuid_to_multihost(char machine_guid[GUID_LEN +
uuid_t *ret_uuid);
-extern void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid);
+extern void rrdeng_metric_init(RRDDIM *rd);
extern void rrdeng_store_metric_init(RRDDIM *rd);
extern void rrdeng_store_metric_flush_current_page(RRDDIM *rd);
extern void rrdeng_store_metric_next(RRDDIM *rd, usec_t point_in_time, storage_number number);
diff --git a/database/engine/rrdenginelib.h b/database/engine/rrdenginelib.h
index ebab93c8f..8b6751f00 100644
--- a/database/engine/rrdenginelib.h
+++ b/database/engine/rrdenginelib.h
@@ -3,6 +3,8 @@
#ifndef NETDATA_RRDENGINELIB_H
#define NETDATA_RRDENGINELIB_H
+#include "libnetdata/libnetdata.h"
+
/* Forward declarations */
struct rrdeng_page_descr;
struct rrdengine_instance;
@@ -12,10 +14,6 @@ struct rrdengine_instance;
#define BITS_PER_ULONG (sizeof(unsigned long) * 8)
-#ifndef UUID_STR_LEN
-#define UUID_STR_LEN (37)
-#endif
-
/* Taken from linux kernel */
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
@@ -141,4 +139,4 @@ extern char *get_rrdeng_statistics(struct rrdengine_instance *ctx, char *str, si
extern int compute_multidb_diskspace();
extern int is_legacy_child(const char *machine_guid);
-#endif /* NETDATA_RRDENGINELIB_H */ \ No newline at end of file
+#endif /* NETDATA_RRDENGINELIB_H */