Skip to content
Snippets Groups Projects
Commit bc637527 authored by Jan Kadlec's avatar Jan Kadlec
Browse files

Merge branch 'journal_size_entrylimit' into 'master'

Journal Size Entrylimit

Should also be backported to 1.4
parents 98451f56 bac2310a
No related branches found
No related tags found
No related merge requests found
......@@ -403,9 +403,11 @@ int journal_write_in(journal_t *j, journal_node_t **rn, uint64_t id, size_t len)
}
}
/* Count node visits to prevent looping. */
uint16_t visit_count = 0;
/* Evict occupied nodes if necessary. */
while (j->free.len < len ||
j->nodes[jnext].flags > JOURNAL_FREE) {
while (j->free.len < len || j->nodes[jnext].flags > JOURNAL_FREE) {
/* Evict least recent node if not empty. */
journal_node_t *head = j->nodes + j->qhead;
......@@ -435,6 +437,12 @@ int journal_write_in(journal_t *j, journal_node_t **rn, uint64_t id, size_t len)
/* Increase free segment. */
j->free.len += head->len;
/* Update node visit count. */
visit_count += 1;
if (visit_count >= j->max_nodes) {
return KNOT_ESPACE;
}
}
/* Invalidate node and write back. */
......
......@@ -275,17 +275,20 @@ static zone_t* update_zone(zone_t *old_zone, conf_zone_t *conf, server_t *server
result = zones_journal_apply(new_zone);
if (result != KNOT_EOK && result != KNOT_ERANGE && result != KNOT_ENOENT) {
log_zone_error("Zone '%s', failed to apply changes from journal: %s\n",
log_zone_error("Zone '%s' failed to apply changes from journal - %s\n",
conf->name, knot_strerror(result));
goto fail;
}
result = zones_do_diff_and_sign(new_zone, old_zone, new_content);
if (result != KNOT_EOK) {
log_zone_error("Zone '%s', failed to create diff and/or sign "
"the zone: %s. The server will continue to serve"
" the old zone.\n",
conf->name, knot_strerror(result));
if (result == KNOT_ESPACE) {
log_zone_error("Zone '%s' journal size is too small to fit the changes.\n",
conf->name);
} else {
log_zone_error("Zone '%s' failed to store changes in the journal - %s\n",
conf->name, knot_strerror(result));
}
goto fail;
}
......
......@@ -2095,10 +2095,7 @@ static int store_chgsets_after_load(zone_t *old_zone, zone_t *zone,
int ret = zones_store_changesets_begin_and_store(zone, diff_chs,
&transaction);
if (ret != KNOT_EOK) {
log_zone_error("Zone %s: Could not save new entry to journal "
"(%s)!\n", zone->conf->name, knot_strerror(ret));
return ret;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment