summaryrefslogtreecommitdiffstats
path: root/database/engine
diff options
context:
space:
mode:
authorMarkos Fountoulakis <44345837+mfundul@users.noreply.github.com>2020-06-16 21:57:46 +0300
committerGitHub <noreply@github.com>2020-06-16 21:57:46 +0300
commited2d5542cc6000d80a7d4377435cc175cfd519e4 (patch)
tree4f823c068cc87f10b00c64d02e3b56de1255b84c /database/engine
parent36d5e40dca91a93963e4d96f07af3e38803615d0 (diff)
Replace assert calls (#9349)
* Replace all assert() calls with the new fatal_assert() for proper logging.
Diffstat (limited to 'database/engine')
-rw-r--r--database/engine/datafile.c10
-rw-r--r--database/engine/global_uuid_map/global_uuid_map.c6
-rw-r--r--database/engine/journalfile.c12
-rw-r--r--database/engine/metadata_log/compaction.c14
-rw-r--r--database/engine/metadata_log/logfile.c12
-rw-r--r--database/engine/metadata_log/metadatalog.c20
-rwxr-xr-xdatabase/engine/metadata_log/metadatalogapi.c20
-rwxr-xr-xdatabase/engine/metadata_log/metalogpluginsd.c12
-rw-r--r--database/engine/pagecache.c30
-rw-r--r--database/engine/pagecache.h2
-rw-r--r--database/engine/rrdengine.c36
-rwxr-xr-xdatabase/engine/rrdengineapi.c30
-rw-r--r--database/engine/rrdenginelib.c6
-rw-r--r--database/engine/rrdenginelib.h6
-rw-r--r--database/engine/rrdenglocking.c26
15 files changed, 121 insertions, 121 deletions
diff --git a/database/engine/datafile.c b/database/engine/datafile.c
index 8ef4ed5990..01f6863d55 100644
--- a/database/engine/datafile.c
+++ b/database/engine/datafile.c
@@ -30,7 +30,7 @@ void datafile_list_delete(struct rrdengine_instance *ctx, struct rrdengine_dataf
struct rrdengine_datafile *next;
next = datafile->next;
- assert((NULL != next) && (ctx->datafiles.first == datafile) && (ctx->datafiles.last != datafile));
+ fatal_assert((NULL != next) && (ctx->datafiles.first == datafile) && (ctx->datafiles.last != datafile));
ctx->datafiles.first = next;
}
@@ -38,7 +38,7 @@ void datafile_list_delete(struct rrdengine_instance *ctx, struct rrdengine_dataf
static void datafile_init(struct rrdengine_datafile *datafile, struct rrdengine_instance *ctx,
unsigned tier, unsigned fileno)
{
- assert(tier == 1);
+ fatal_assert(tier == 1);
datafile->tier = tier;
datafile->fileno = fileno;
datafile->file = (uv_file)0;
@@ -146,7 +146,7 @@ int create_data_file(struct rrdengine_datafile *datafile)
ret = uv_fs_write(NULL, &req, file, &iov, 1, 0, NULL);
if (ret < 0) {
- assert(req.result < 0);
+ fatal_assert(req.result < 0);
error("uv_fs_write: %s", uv_strerror(ret));
++ctx->stats.io_errors;
rrd_stat_atomic_add(&global_io_errors, 1);
@@ -184,7 +184,7 @@ static int check_data_file_superblock(uv_file file)
uv_fs_req_cleanup(&req);
goto error;
}
- assert(req.result >= 0);
+ fatal_assert(req.result >= 0);
uv_fs_req_cleanup(&req);
if (strncmp(superblock->magic_number, RRDENG_DF_MAGIC, RRDENG_MAGIC_SZ) ||
@@ -271,7 +271,7 @@ static int scan_data_files(struct rrdengine_instance *ctx)
ret = uv_fs_scandir(NULL, &req, ctx->dbfiles_path, 0, NULL);
if (ret < 0) {
- assert(req.result < 0);
+ fatal_assert(req.result < 0);
uv_fs_req_cleanup(&req);
error("uv_fs_scandir(%s): %s", ctx->dbfiles_path, uv_strerror(ret));
++ctx->stats.fs_errors;
diff --git a/database/engine/global_uuid_map/global_uuid_map.c b/database/engine/global_uuid_map/global_uuid_map.c
index 340a353528..f55ea5d7ad 100644
--- a/database/engine/global_uuid_map/global_uuid_map.c
+++ b/database/engine/global_uuid_map/global_uuid_map.c
@@ -254,9 +254,9 @@ void init_global_guid_map()
init = 1;
info("Configuring locking mechanism for global GUID map");
- assert(0 == uv_rwlock_init(&guid_lock));
- assert(0 == uv_rwlock_init(&object_lock));
- assert(0 == uv_rwlock_init(&global_lock));
+ fatal_assert(0 == uv_rwlock_init(&guid_lock));
+ fatal_assert(0 == uv_rwlock_init(&object_lock));
+ fatal_assert(0 == uv_rwlock_init(&global_lock));
// int rc = guid_bulk_load("6fc56a64-05d7-47a7-bc82-7f3235d8cbda","d6b37186-74db-11ea-88b2-0bf5095b1f9e/cgroup_qemu_ubuntu18.04.cpu_per_core/cpu3");
// rc = guid_bulk_load("75c6fa02-97cc-40c1-aacd-a0132190472e","d6b37186-74db-11ea-88b2-0bf5095b1f9e/services.throttle_io_ops_write/system.slice_setvtrgb.service");
diff --git a/database/engine/journalfile.c b/database/engine/journalfile.c
index fac680aa0e..97109ec969 100644
--- a/database/engine/journalfile.c
+++ b/database/engine/journalfile.c
@@ -52,7 +52,7 @@ void wal_flush_transaction_buffer(struct rrdengine_worker_config* wc)
io_descr->iov = uv_buf_init((void *)io_descr->buf, size);
ret = uv_fs_write(wc->loop, &io_descr->req, journalfile->file, &io_descr->iov, 1,
journalfile->pos, flush_transaction_buffer_cb);
- assert (-1 != ret);
+ fatal_assert(-1 != ret);
journalfile->pos += RRDENG_BLOCK_SIZE;
ctx->disk_space += RRDENG_BLOCK_SIZE;
ctx->commit_log.buf = NULL;
@@ -66,7 +66,7 @@ void * wal_get_transaction_buffer(struct rrdengine_worker_config* wc, unsigned s
int ret;
unsigned buf_pos, buf_size;
- assert(size);
+ fatal_assert(size);
if (ctx->commit_log.buf) {
unsigned remaining;
@@ -194,7 +194,7 @@ int create_journal_file(struct rrdengine_journalfile *journalfile, struct rrdeng
ret = uv_fs_write(NULL, &req, file, &iov, 1, 0, NULL);
if (ret < 0) {
- assert(req.result < 0);
+ fatal_assert(req.result < 0);
error("uv_fs_write: %s", uv_strerror(ret));
++ctx->stats.io_errors;
rrd_stat_atomic_add(&global_io_errors, 1);
@@ -232,7 +232,7 @@ static int check_journal_file_superblock(uv_file file)
uv_fs_req_cleanup(&req);
goto error;
}
- assert(req.result >= 0);
+ fatal_assert(req.result >= 0);
uv_fs_req_cleanup(&req);
if (strncmp(superblock->magic_number, RRDENG_JF_MAGIC, RRDENG_MAGIC_SZ) ||
@@ -293,7 +293,7 @@ static void restore_extent_metadata(struct rrdengine_instance *ctx, struct rrden
/* First time we see the UUID */
uv_rwlock_wrlock(&pg_cache->metrics_index.lock);
PValue = JudyHSIns(&pg_cache->metrics_index.JudyHS_array, temp_id, sizeof(uuid_t), PJE0);
- assert(NULL == *PValue); /* TODO: figure out concurrency model */
+ fatal_assert(NULL == *PValue); /* TODO: figure out concurrency model */
*PValue = page_index = create_page_index(temp_id);
page_index->prev = pg_cache->metrics_index.last_page_index;
pg_cache->metrics_index.last_page_index = page_index;
@@ -408,7 +408,7 @@ static uint64_t iterate_transactions(struct rrdengine_instance *ctx, struct rrde
fatal("uv_fs_read: %s", uv_strerror(ret));
/*uv_fs_req_cleanup(&req);*/
}
- assert(req.result >= 0);
+ fatal_assert(req.result >= 0);
uv_fs_req_cleanup(&req);
ctx->stats.io_read_bytes += size_bytes;
++ctx->stats.io_read_requests;
diff --git a/database/engine/metadata_log/compaction.c b/database/engine/metadata_log/compaction.c
index 9113fdd940..951cebdc04 100644
--- a/database/engine/metadata_log/compaction.c
+++ b/database/engine/metadata_log/compaction.c
@@ -87,7 +87,7 @@ static void compact_record_by_uuid(struct metalog_instance *ctx, uuid_t *uuid)
ret = find_object_by_guid(uuid, NULL, 0);
switch (ret) {
case GUID_TYPE_CHAR:
- assert(0);
+ fatal_assert(0);
break;
case GUID_TYPE_CHART:
st = metalog_get_chart_from_uuid(ctx, uuid);
@@ -130,7 +130,7 @@ static void compact_record_by_uuid(struct metalog_instance *ctx, uuid_t *uuid)
debug(D_METADATALOG, "Ignoring nonexistent metadata record.");
break;
default:
- assert(0);
+ fatal_assert(0);
break;
}
}
@@ -221,7 +221,7 @@ static void compact_old_records(void *arg)
break;
}
}
- assert(nextmetalogfile); /* There are always more than 1 metadata log files during compaction */
+ fatal_assert(nextmetalogfile); /* There are always more than 1 metadata log files during compaction */
newmetalogfile = compaction_state->new_metadata_logfiles.last;
if (newmetalogfile->starting_fileno != 0) { /* Must rename the last compacted file */
@@ -237,7 +237,7 @@ static void compact_old_records(void *arg)
wc->cleanup_thread_compacting_files = 1;
/* wake up event loop */
- assert(0 == uv_async_send(&wc->async));
+ fatal_assert(0 == uv_async_send(&wc->async));
}
/* Returns 0 on success. */
@@ -262,7 +262,7 @@ static int init_compaction_state(struct metalog_instance *ctx)
return ret;
}
newmetalogfile = compaction_state->new_metadata_logfiles.first;
- assert(newmetalogfile == compaction_state->new_metadata_logfiles.last);
+ fatal_assert(newmetalogfile == compaction_state->new_metadata_logfiles.last);
init_metadata_record_log(&compaction_state->records_log);
return 0;
@@ -329,7 +329,7 @@ int compaction_failure_recovery(struct metalog_instance *ctx, struct metadata_lo
for (j = 0, recovered_files = 0 ; j < i ; ++j) {
metalogfile = metalogfiles[j];
- assert(0 == metalogfile->starting_fileno);
+ fatal_assert(0 == metalogfile->starting_fileno);
if (metalogfile->fileno < starting_fileno) {
tmp_metalogfiles[recovered_files++] = metalogfile;
continue;
@@ -352,7 +352,7 @@ int compaction_failure_recovery(struct metalog_instance *ctx, struct metadata_lo
for ( ; j < i ; ++j) { /* continue iterating through normal metadata log files */
metalogfile = metalogfiles[j];
- assert(0 == metalogfile->starting_fileno);
+ fatal_assert(0 == metalogfile->starting_fileno);
if (metalogfile->fileno < fileno) { /* It has already been compacted */
error("Deleting invalid metadata log file \"%s/"METALOG_PREFIX METALOG_FILE_NUMBER_PRINT_TMPL
METALOG_EXTENSION"\"", dbfiles_path, 0U, metalogfile->fileno);
diff --git a/database/engine/metadata_log/logfile.c b/database/engine/metadata_log/logfile.c
index 9ae2866298..117c5e5eee 100644
--- a/database/engine/metadata_log/logfile.c
+++ b/database/engine/metadata_log/logfile.c
@@ -118,7 +118,7 @@ void mlf_flush_records_buffer(struct metalog_worker_config *wc, struct metadata_
io_descr->iov = uv_buf_init((void *)io_descr->buf, size);
ret = uv_fs_write(wc->loop, &io_descr->req, metalogfile->file, &io_descr->iov, 1,
metalogfile->pos, flush_records_buffer_cb);
- assert (-1 != ret);
+ fatal_assert(-1 != ret);
metalogfile->pos += size;
rrd_atomic_fetch_add(&ctx->disk_space, size);
records_log->buf = NULL;
@@ -132,7 +132,7 @@ void *mlf_get_records_buffer(struct metalog_worker_config *wc, struct metadata_r
int ret;
unsigned buf_pos, buf_size;
- assert(size);
+ fatal_assert(size);
if (records_log->buf) {
unsigned remaining;
@@ -175,7 +175,7 @@ void metadata_logfile_list_delete(struct metadata_logfile_list *metadata_logfile
struct metadata_logfile *next;
next = metalogfile->next;
- assert((NULL != next) && (metadata_logfiles->first == metalogfile) &&
+ fatal_assert((NULL != next) && (metadata_logfiles->first == metalogfile) &&
(metadata_logfiles->last != metalogfile));
metadata_logfiles->first = next;
}
@@ -337,7 +337,7 @@ int create_metadata_logfile(struct metadata_logfile *metalogfile)
ret = uv_fs_write(NULL, &req, file, &iov, 1, 0, NULL);
if (ret < 0) {
- assert(req.result < 0);
+ fatal_assert(req.result < 0);
error("uv_fs_write: %s", uv_strerror(ret));
++ctx->stats.io_errors;
rrd_stat_atomic_add(&global_io_errors, 1);
@@ -375,7 +375,7 @@ static int check_metadata_logfile_superblock(uv_file file)
uv_fs_req_cleanup(&req);
goto error;
}
- assert(req.result >= 0);
+ fatal_assert(req.result >= 0);
uv_fs_req_cleanup(&req);
if (strncmp(superblock->magic_number, RRDENG_METALOG_MAGIC, RRDENG_MAGIC_SZ)) {
@@ -614,7 +614,7 @@ static int scan_metalog_files(struct metalog_instance *ctx)
ret = uv_fs_scandir(NULL, &req, dbfiles_path, 0, NULL);
if (ret < 0) {
- assert(req.result < 0);
+ fatal_assert(req.result < 0);
uv_fs_req_cleanup(&req);
error("uv_fs_scandir(%s): %s", dbfiles_path, uv_strerror(ret));
++ctx->stats.fs_errors;
diff --git a/database/engine/metadata_log/metadatalog.c b/database/engine/metadata_log/metadatalog.c
index b068f85c6a..6ebc2185ea 100644
--- a/database/engine/metadata_log/metadatalog.c
+++ b/database/engine/metadata_log/metadatalog.c
@@ -52,8 +52,8 @@ void metalog_commit_record(struct metalog_instance *ctx, BUFFER *buffer, enum me
{
struct metalog_cmd cmd;
- assert(buffer_strlen(buffer));
- assert(opcode == METALOG_COMMIT_CREATION_RECORD || opcode == METALOG_COMMIT_DELETION_RECORD);
+ fatal_assert(buffer_strlen(buffer));
+ fatal_assert(opcode == METALOG_COMMIT_CREATION_RECORD || opcode == METALOG_COMMIT_DELETION_RECORD);
cmd.opcode = opcode;
cmd.record_io_descr.buffer = buffer;
@@ -191,8 +191,8 @@ static void metalog_init_cmd_queue(struct metalog_worker_config *wc)
{
wc->cmd_queue.head = wc->cmd_queue.tail = 0;
wc->queue_size = 0;
- assert(0 == uv_cond_init(&wc->cmd_cond));
- assert(0 == uv_mutex_init(&wc->cmd_mutex));
+ fatal_assert(0 == uv_cond_init(&wc->cmd_cond));
+ fatal_assert(0 == uv_mutex_init(&wc->cmd_mutex));
}
void metalog_enq_cmd(struct metalog_worker_config *wc, struct metalog_cmd *cmd)
@@ -204,7 +204,7 @@ void metalog_enq_cmd(struct metalog_worker_config *wc, struct metalog_cmd *cmd)
while ((queue_size = wc->queue_size) == METALOG_CMD_Q_MAX_SIZE) {
uv_cond_wait(&wc->cmd_cond, &wc->cmd_mutex);
}
- assert(queue_size < METALOG_CMD_Q_MAX_SIZE);
+ fatal_assert(queue_size < METALOG_CMD_Q_MAX_SIZE);
/* enqueue command */
wc->cmd_queue.cmd_array[wc->cmd_queue.tail] = *cmd;
wc->cmd_queue.tail = wc->cmd_queue.tail != METALOG_CMD_Q_MAX_SIZE - 1 ?
@@ -213,7 +213,7 @@ void metalog_enq_cmd(struct metalog_worker_config *wc, struct metalog_cmd *cmd)
uv_mutex_unlock(&wc->cmd_mutex);
/* wake up event loop */
- assert(0 == uv_async_send(&wc->async));
+ fatal_assert(0 == uv_async_send(&wc->async));
}
struct metalog_cmd metalog_deq_cmd(struct metalog_worker_config *wc)
@@ -318,7 +318,7 @@ void metalog_worker(void* arg)
/* wake up initialization thread */
complete(&ctx->metalog_completion);
- assert(0 == uv_timer_start(&timer_req, timer_cb, TIMER_PERIOD_MS, TIMER_PERIOD_MS));
+ fatal_assert(0 == uv_timer_start(&timer_req, timer_cb, TIMER_PERIOD_MS, TIMER_PERIOD_MS));
shutdown = 0;
while (likely(shutdown == 0 || metalog_threads_alive(wc))) {
uv_run(loop, UV_RUN_DEFAULT);
@@ -347,7 +347,7 @@ void metalog_worker(void* arg)
break;
case METALOG_QUIESCE:
ctx->quiesce = SET_QUIESCE;
- assert(0 == uv_timer_stop(&timer_req));
+ fatal_assert(0 == uv_timer_stop(&timer_req));
uv_close((uv_handle_t *)&timer_req, NULL);
mlf_flush_records_buffer(wc, &ctx->records_log, &ctx->metadata_logfiles);
if (!metalog_threads_alive(wc)) {
@@ -390,7 +390,7 @@ void metalog_worker(void* arg)
/* TODO: don't let the API block by waiting to enqueue commands */
uv_cond_destroy(&wc->cmd_cond);
/* uv_mutex_destroy(&wc->cmd_mutex); */
- assert(0 == uv_loop_close(loop));
+ fatal_assert(0 == uv_loop_close(loop));
freez(loop);
return;
@@ -398,7 +398,7 @@ void metalog_worker(void* arg)
error_after_timer_init:
uv_close((uv_handle_t *)&wc->async, NULL);
error_after_async_init:
- assert(0 == uv_loop_close(loop));
+ fatal_assert(0 == uv_loop_close(loop));
error_after_loop_init:
freez(loop);
diff --git a/database/engine/metadata_log/metadatalogapi.c b/database/engine/metadata_log/metadatalogapi.c
index 6bd09b4d9e..e8a5d27442 100755
--- a/database/engine/metadata_log/metadatalogapi.c
+++ b/database/engine/metadata_log/metadatalogapi.c
@@ -273,16 +273,16 @@ RRDSET *metalog_get_chart_from_uuid(struct metalog_instance *ctx, uuid_t *chart_
uuid_t *machine_guid, *chart_char_guid;
ret = find_object_by_guid(chart_uuid, chart_object, 33);
- assert(GUID_TYPE_CHART == ret);
+ fatal_assert(GUID_TYPE_CHART == ret);
machine_guid = (uuid_t *)chart_object;
RRDHOST *host = ctx->rrdeng_ctx->host;
- assert(!uuid_compare(host->host_uuid, *machine_guid));
+ fatal_assert(!uuid_compare(host->host_uuid, *machine_guid));
chart_char_guid = (uuid_t *)(chart_object + 16);
ret = find_object_by_guid(chart_char_guid, chart_fullid, RRD_ID_LENGTH_MAX + 1);
- assert(GUID_TYPE_CHAR == ret);
+ fatal_assert(GUID_TYPE_CHAR == ret);
RRDSET *st = rrdset_find(host, chart_fullid);
return st;
@@ -300,22 +300,22 @@ RRDDIM *metalog_get_dimension_from_uuid(struct metalog_instance *ctx, uuid_t *me
machine_guid = (uuid_t *)dim_object;
RRDHOST *host = ctx->rrdeng_ctx->host;
- assert(!uuid_compare(host->host_uuid, *machine_guid));
+ fatal_assert(!uuid_compare(host->host_uuid, *machine_guid));
chart_guid = (uuid_t *)(dim_object + 16);
dim_char_guid = (uuid_t *)(dim_object + 16 + 16);
ret = find_object_by_guid(dim_char_guid, id_str, sizeof(id_str));
- assert(GUID_TYPE_CHAR == ret);
+ fatal_assert(GUID_TYPE_CHAR == ret);
ret = find_object_by_guid(chart_guid, chart_object, sizeof(chart_object));
- assert(GUID_TYPE_CHART == ret);
+ fatal_assert(GUID_TYPE_CHART == ret);
chart_char_guid = (uuid_t *)(chart_object + 16);
ret = find_object_by_guid(chart_char_guid, chart_fullid, RRD_ID_LENGTH_MAX + 1);
- assert(GUID_TYPE_CHAR == ret);
+ fatal_assert(GUID_TYPE_CHAR == ret);
RRDSET *st = rrdset_find(host, chart_fullid);
- assert(st);
+ fatal_assert(st);
RRDDIM *rd = rrddim_find(st, id_str);
@@ -386,7 +386,7 @@ int metalog_init(struct rrdengine_instance *rrdeng_parent_ctx)
}
init_completion(&ctx->metalog_completion);
- assert(0 == uv_thread_create(&ctx->worker_config.thread, metalog_worker, &ctx->worker_config));
+ fatal_assert(0 == uv_thread_create(&ctx->worker_config.thread, metalog_worker, &ctx->worker_config));
/* wait for worker thread to initialize */
wait_for_completion(&ctx->metalog_completion);
destroy_completion(&ctx->metalog_completion);
@@ -418,7 +418,7 @@ int metalog_exit(struct metalog_instance *ctx)
cmd.opcode = METALOG_SHUTDOWN;
metalog_enq_cmd(&ctx->worker_config, &cmd);
- assert(0 == uv_thread_join(&ctx->worker_config.thread));
+ fatal_assert(0 == uv_thread_join(&ctx->worker_config.thread));
finalize_metalog_files(ctx);
freez(ctx);
diff --git a/database/engine/metadata_log/metalogpluginsd.c b/database/engine/metadata_log/metalogpluginsd.c
index 23027af7b2..da7e19377f 100755
--- a/database/engine/metadata_log/metalogpluginsd.c
+++ b/database/engine/metadata_log/metalogpluginsd.c
@@ -117,7 +117,7 @@ PARSER_RC metalog_pluginsd_context_action(void *user, uuid_t *uuid)
ret = find_object_by_guid(uuid, object, 49);
switch (ret) {
case GUID_TYPE_CHAR:
- assert(0);
+ fatal_assert(0);
break;
case GUID_TYPE_CHART:
case GUID_TYPE_DIMENSION:
@@ -127,22 +127,22 @@ PARSER_RC metalog_pluginsd_context_action(void *user, uuid_t *uuid)
chart_char_guid = (uuid_t *)(object + 16);
ret = find_object_by_guid(chart_char_guid, id_str, RRD_ID_LENGTH_MAX + 1);
- assert(GUID_TYPE_CHAR == ret);
+ fatal_assert(GUID_TYPE_CHAR == ret);
((PARSER_USER_OBJECT *) user)->st = rrdset_find(host, id_str);
break;
case GUID_TYPE_DIMENSION:
chart_guid = (uuid_t *)(object + 16);
ret = find_object_by_guid(chart_guid, chart_object, 33);
- assert(GUID_TYPE_CHART == ret);
+ fatal_assert(GUID_TYPE_CHART == ret);
chart_char_guid = (uuid_t *)(chart_object + 16);
ret = find_object_by_guid(chart_char_guid, id_str, RRD_ID_LENGTH_MAX + 1);
- assert(GUID_TYPE_CHAR == ret);
+ fatal_assert(GUID_TYPE_CHAR == ret);
((PARSER_USER_OBJECT *) user)->st = rrdset_find(host, id_str);
break;
default:
- assert(0);
+ fatal_assert(0);
break;
}
break;
@@ -168,7 +168,7 @@ PARSER_RC metalog_pluginsd_tombstone_action(void *user, uuid_t *uuid)
ret = find_object_by_guid(uuid, NULL, 0);
switch (ret) {
case GUID_TYPE_CHAR:
- assert(0);
+ fatal_assert(0);
break;
case GUID_TYPE_CHART:
st = metalog_get_chart_from_uuid(ctx, uuid);
diff --git a/database/engine/pagecache.c b/database/engine/pagecache.c
index f1f3a5be85..f37257c425 100644
--- a/database/engine/pagecache.c
+++ b/database/engine/pagecache.c
@@ -406,7 +406,7 @@ uint8_t pg_cache_punch_hole(struct rrdengine_instance *ctx, struct rrdeng_page_d
uv_rwlock_rdlock(&pg_cache->metrics_index.lock);
PValue = JudyHSGet(pg_cache->metrics_index.JudyHS_array, descr->id, sizeof(uuid_t));
- assert(NULL != PValue);
+ fatal_assert(NULL != PValue);
page_index = *PValue;
uv_rwlock_rdunlock(&pg_cache->metrics_index.lock);
@@ -428,7 +428,7 @@ uint8_t pg_cache_punch_hole(struct rrdengine_instance *ctx, struct rrdeng_page_d
}
}
uv_rwlock_wrunlock(&page_index->lock);
- assert(1 == ret);
+ fatal_assert(1 == ret);
uv_rwlock_wrlock(&pg_cache->pg_cache_rwlock);
++ctx->stats.pg_cache_deletions;
@@ -565,7 +565,7 @@ void pg_cache_update_metric_times(struct pg_cache_page_index *page_index)
uv_rwlock_rdunlock(&page_index->lock);
if (unlikely(NULL == firstPValue)) {
- assert(NULL == lastPValue);
+ fatal_assert(NULL == lastPValue);
page_index->oldest_time = page_index->latest_time = INVALID_TIME;
return;
}
@@ -586,7 +586,7 @@ void pg_cache_insert(struct rrdengine_instance *ctx, struct pg_cache_page_index
/* there is page cache descriptor pre-allocated state */
struct page_cache_descr *pg_cache_descr = descr->pg_cache_descr;
- assert(pg_cache_descr_state & PG_CACHE_DESCR_ALLOCATED);
+ fatal_assert(pg_cache_descr_state & PG_CACHE_DESCR_ALLOCATED);
if (pg_cache_descr->flags & RRD_PAGE_POPULATED) {
pg_cache_reserve_pages(ctx, 1);
if (!(pg_cache_descr->flags & RRD_PAGE_DIRTY))
@@ -597,7 +597,7 @@ void pg_cache_insert(struct rrdengine_instance *ctx, struct pg_cache_page_index
if (unlikely(NULL == index)) {
uv_rwlock_rdlock(&pg_cache->metrics_index.lock);
PValue = JudyHSGet(pg_cache->metrics_index.JudyHS_array, descr->id, sizeof(uuid_t));
- assert(NULL != PValue);
+ fatal_assert(NULL != PValue);
page_index = *PValue;
uv_rwlock_rdunlock(&pg_cache->metrics_index.lock);
} else {
@@ -662,7 +662,7 @@ void pg_cache_get_filtered_info_prev(struct rrdengine_instance *ctx, struct pg_c
Word_t Index;
(void)pg_cache;
- assert(NULL != page_index);
+ fatal_assert(NULL != page_index);
Index = (Word_t)(point_in_time / USEC_PER_SEC);
uv_rwlock_rdlock(&page_index->lock);
@@ -707,7 +707,7 @@ unsigned pg_cache_preload(struct rrdengine_instance *ctx, uuid_t *id, usec_t sta
Word_t Index;
uint8_t failed_to_reserve;
- assert(NULL != ret_page_indexp);
+ fatal_assert(NULL != ret_page_indexp);
uv_rwlock_rdlock(&pg_cache->metrics_index.lock);
PValue = JudyHSGet(pg_cache->metrics_index.JudyHS_array, id, sizeof(uuid_t));
@@ -1048,7 +1048,7 @@ struct pg_cache_page_index *create_page_index(uuid_t *id)
page_index = mallocz(sizeof(*page_index));
page_index->JudyL_array = (Pvoid_t) NULL;
uuid_copy(page_index->id, *id);
- assert(0 == uv_rwlock_init(&page_index->lock));
+ fatal_assert(0 == uv_rwlock_init(&page_index->lock));
page_index->oldest_time = INVALID_TIME;
page_index->latest_time = INVALID_TIME;
page_index->prev = NULL;
@@ -1064,7 +1064,7 @@ static void init_metrics_index(struct rrdengine_instance *ctx)
pg_cache->metrics_index.JudyHS_array = (Pvoid_t) NULL;
pg_cache->metrics_index.last_page_index = NULL;
- assert(0 == uv_rwlock_init(&pg_cache->metrics_index.lock));
+ fatal_assert(0 == uv_rwlock_init(&pg_cache->metrics_index.lock));
}
static void init_replaceQ(struct rrdengine_instance *ctx)
@@ -1073,7 +1073,7 @@ static void init_replaceQ(struct rrdengine_instance *ctx)
pg_cache->replaceQ.head = NULL;
pg_cache->replaceQ.tail = NULL;
- assert(0 == uv_rwlock_init(&pg_cache->replaceQ.lock));
+ fatal_assert(0 == uv_rwlock_init(&pg_cache->replaceQ.lock));
}
static void init_committed_page_index(struct rrdengine_instance *ctx)
@@ -1081,7 +1081,7 @@ static void init_committed_page_index(struct rrdengine_instance *ctx)
struct page_cache *pg_cache = &ctx->pg_cache;
pg_cache->committed_page_index.JudyL_array = (Pvoid_t) NULL;
- assert(0 == uv_rwlock_init(&pg_cache->committed_page_index.lock));
+ fatal_assert(0 == uv_rwlock_init(&pg_cache->committed_page_index.lock));
pg_cache->committed_page_index.latest_corr_id = 0;
pg_cache->committed_page_index.nr_committed_pages = 0;
}
@@ -1092,7 +1092,7 @@ void init_page_cache(struct rrdengine_instance *ctx)
pg_cache->page_descriptors = 0;
pg_cache->populated_pages = 0;
- assert(0 == uv_rwlock_init(&pg_cache->pg_cache_rwlock));
+ fatal_assert(0 == uv_rwlock_init(&pg_cache->pg_cache_rwlock));
init_metrics_index(ctx);
init_replaceQ(ctx);
@@ -1111,7 +1111,7 @@ void free_page_cache(struct rrdengine_instance *ctx)
/* Free committed page index */
ret_Judy = JudyLFreeArray(&pg_cache->committed_page_index.JudyL_array, PJE0);
- assert(NULL == pg_cache->committed_page_index.JudyL_array);
+ fatal_assert(NULL == pg_cache->committed_page_index.JudyL_array);
bytes_freed += ret_Judy;
for (page_index = pg_cache->metrics_index.last_page_index ;
@@ -1146,14 +1146,14 @@ void free_page_cache(struct rrdengine_instance *ctx)
/* Free page index */
ret_Judy = JudyLFreeArray(&page_index->JudyL_array, PJE0);
- assert(NULL == page_index->JudyL_array);
+ fatal_assert(NULL == page_index->JudyL_array);
bytes_freed += ret_Judy;
freez(page_index);
bytes_freed += sizeof(*page_index);
}
/* Free metrics index */
ret_Judy = JudyHSFreeArray(&pg_cache->metrics_index.JudyHS_array, PJE0);
- assert(NULL == pg_cache->metrics_index.JudyHS_array);
+ fatal_assert(NULL == pg_cache->metrics_index.JudyHS_array);
bytes_freed += ret_Judy;
info("Freed %lu bytes of memory from page cache.", bytes_freed);
diff --git a/database/engine/pagecache.h b/database/engine/pagecache.h
index 4ca57cd667..31e9739da6 100644
--- a/database/engine/pagecache.h
+++ b/database/engine/pagecache.h
@@ -219,7 +219,7 @@ static inline void
/* The caller must hold a reference to the page and must have already set the new data */
static inline void pg_cache_atomic_set_pg_info(struct rrdeng_page_descr *descr, usec_t end_time, uint32_t page_length)
{
- assert(!(end_time & 1));
+ fatal_assert(!(end_time & 1));
__sync_synchronize();
descr->end_time |= 1; /* mark start of uncertainty period by adding 1 microsecond */
__sync_synchronize();
diff --git a/database/engine/rrdengine.c b/database/engine/rrdengine.c
index bf59242711..000bf88a6a 100644
--- a/database/engine/rrdengine.c
+++ b/database/engine/rrdengine.c
@@ -191,7 +191,7 @@ static void do_read_extent(struct rrdengine_worker_config* wc,
real_io_size = ALIGN_BYTES_CEILING(size_bytes);
xt_io_descr->iov = uv_buf_init((void *)xt_io_descr->buf, real_io_size);
ret = uv_fs_read(wc->loop, &xt_io_descr->req, datafile->file, &xt_io_descr->iov, 1, pos, read_extent_cb);
- assert (-1 != ret);
+ fatal_assert(-1 != ret);
ctx->stats.io_read_bytes += real_io_size;
++ctx->stats.io_read_requests;
ctx->stats.io_read_extent_bytes += real_io_size;
@@ -244,7 +244,7 @@ static void do_commit_transaction(struct rrdengine_worker_config* wc, uint8_t ty
commit_data_extent(wc, (struct extent_io_descriptor *)data);
break;
default:
- assert(type == STORE_DATA);
+ fatal_assert(type == STORE_DATA);
break;
}
}
@@ -284,7 +284,7 @@ static void invalidate_oldest_committed(void *arg)
PValue = JudyLNext(pg_cache->committed_page_index.JudyL_array, &Index, PJE0),
descr = unlikely(NULL == PValue) ? NULL : *PValue) {
- assert(0 != descr->page_length);
+ fatal_assert(0 != descr->page_length);
rrdeng_page_descr_mutex_lock(ctx, descr);
pg_cache_descr = descr->pg_cache_descr;
@@ -292,7 +292,7 @@ static void invalidate_oldest_committed(void *arg)
rrdeng_page_descr_mutex_unlock(ctx, descr);
ret = JudyLDel(&pg_cache->committed_page_index.JudyL_array, Index, PJE0);
- assert(1 == ret);
+ fatal_assert(1 == ret);
break;
}
rrdeng_page_descr_mutex_unlock(ctx, descr);
@@ -316,7 +316,7 @@ static void invalidate_oldest_committed(void *arg)
out:
wc->cleanup_thread_invalidating_dirty_pages = 1;
/* wake up event loop */
- assert(0 == uv_async_send(&wc->async));
+ fatal_assert(0 == uv_async_send(&wc->async));
}
void rrdeng_invalidate_oldest_committed(struct rrdengine_worker_config* wc)
@@ -446,7 +446,7 @@ static int do_flush_pages(struct rrdengine_worker_config* wc, int force, struct
descr = unlikely(NULL == PValue) ? NULL : *PValue) {
uint8_t page_write_pending;
- assert(0 != descr->page_length);
+ fatal_assert(0 != descr->page_length);
page_write_pending = 0;
rrdeng_page_descr_mutex_lock(ctx, descr);
@@ -463,7 +463,7 @@ static int do_flush_pages(struct rrdengine_worker_config* wc, int force, struct
if (page_write_pending) {
ret = JudyLDel(&pg_cache->committed_page_index.JudyL_array, Index, PJE0);
- assert(1 == ret);
+ fatal_assert(1 == ret);
}
}
uv_rwlock_wrunlock(&pg_cache->committed_page_index.lock);
@@ -483,7 +483,7 @@ static int do_flush_pages(struct rrdengine_worker_config* wc, int force, struct
size_bytes = payload_offset + uncompressed_payload_length + sizeof(*trailer);
break;
default: /* Compress */
- assert(uncompressed_payload_length < LZ4_MAX_INPUT_SIZE);
+ fatal_assert(uncompressed_payload_length < LZ4_MAX_INPUT_SIZE);
max_compressed_size = LZ4_compressBound(uncompressed_payload_length);
compressed_buf = mallocz(max_compressed_size);
size_bytes = payload_offset + MAX(uncompressed_payload_length, (unsigned)max_compressed_size) + sizeof(*trailer);
@@ -563,7 +563,7 @@ static int do_flush_pages(struct rrdengine_worker_config* wc, int force, struct
real_io_size = ALIGN_BYTES_CEILING(size_bytes);
xt_io_descr->iov = uv_buf_init((void *)xt_io_descr->buf, real_io_size);
ret = uv_fs_write(wc->loop, &xt_io_descr->req, datafile->file, &xt_io_descr->iov, 1, datafile->pos, flush_pages_cb);
- assert (-1 != ret);
+ fatal_assert(-1 != ret);
ctx->stats.io_write_bytes += real_io_size;
++ctx->stats.io_write_requests;
ctx->stats.io_write_extent_bytes += real_io_size;
@@ -657,7 +657,7 @@ static void delete_old_data(void *arg)
}
wc->cleanup_thread_deleting_files = 1;
/* wake up event loop */
- assert(0 == uv_async_send(&wc->async));
+ fatal_assert(0 == uv_async_send(&wc->async));
}
void rrdeng_test_quota(struct rrdengine_worker_config* wc)
@@ -751,8 +751,8 @@ void rrdeng_init_cmd_queue(struct rrdengine_worker_config* wc)
{
wc->cmd_queue.head