Commit 1d820a44 authored by Ondřej Surý's avatar Ondřej Surý

Merge branch 'conf_never_flush' into 'master'

conf: add zone.zonefile_sync value -1 to never flush

See merge request !394
parents a2742f94 47712a78
......@@ -599,7 +599,8 @@ on the disk (see \fI\%file\fP). The server will serve the latest
zone even after restart using zone journal, but the zone file on the disk will
only be synced after \fBzonefile\-sync\fP time has expired (or after manual zone
flush) This is applicable when the zone is updated via IXFR, DDNS or automatic
DNSSEC signing.
DNSSEC signing. In order to disable automatic zonefile synchronization, \-1 value
can be used.
.sp
\fICaution:\fP If you are serving large zones with frequent updates where
the immediate sync to zone file is not desirable, increase the default value.
......
......@@ -702,7 +702,8 @@ on the disk (see :ref:`file<zone_file>`). The server will serve the latest
zone even after restart using zone journal, but the zone file on the disk will
only be synced after ``zonefile-sync`` time has expired (or after manual zone
flush) This is applicable when the zone is updated via IXFR, DDNS or automatic
DNSSEC signing.
DNSSEC signing. In order to disable automatic zonefile synchronization, -1 value
can be used.
*Caution:* If you are serving large zones with frequent updates where
the immediate sync to zone file is not desirable, increase the default value.
......
......@@ -141,7 +141,7 @@ static const yp_item_t desc_remote[] = {
{ C_ACL, YP_TREF, YP_VREF = { C_ACL }, YP_FMULTI, { check_ref } }, \
{ C_SEM_CHECKS, YP_TBOOL, YP_VNONE }, \
{ C_DISABLE_ANY, YP_TBOOL, YP_VNONE }, \
{ C_ZONEFILE_SYNC, YP_TINT, YP_VINT = { 0, INT32_MAX, 0, YP_STIME } }, \
{ C_ZONEFILE_SYNC, YP_TINT, YP_VINT = { -1, INT32_MAX, 0, YP_STIME } }, \
{ C_IXFR_DIFF, YP_TBOOL, YP_VNONE }, \
{ C_MAX_JOURNAL_SIZE, YP_TINT, YP_VINT = { 0, INT64_MAX, INT64_MAX, YP_SSIZE } }, \
{ C_DNSSEC_SIGNING, YP_TBOOL, YP_VNONE }, \
......
......@@ -217,6 +217,7 @@ static int remote_zone_flush(zone_t *zone, remote_cmdargs_t *a)
{
UNUSED(a);
zone->flags |= ZONE_FORCE_FLUSH;
zone_events_schedule(zone, ZONE_EVENT_FLUSH, ZONE_EVENT_NOW);
return KNOT_EOK;
}
......
......@@ -305,7 +305,10 @@ int event_reload(zone_t *zone)
/* Periodic execution. */
val = conf_zone_get(conf(), C_ZONEFILE_SYNC, zone->name);
zone_events_schedule(zone, ZONE_EVENT_FLUSH, conf_int(&val));
int64_t sync_timeout = conf_int(&val);
if (sync_timeout >= 0) {
zone_events_schedule(zone, ZONE_EVENT_FLUSH, sync_timeout);
}
uint32_t current_serial = zone_contents_serial(zone->contents);
log_zone_info(zone->name, "loaded, serial %u -> %u",
......@@ -426,11 +429,12 @@ int event_xfer(zone_t *zone)
zone_events_schedule(zone, ZONE_EVENT_NOTIFY, ZONE_EVENT_NOW);
zone_events_cancel(zone, ZONE_EVENT_EXPIRE);
conf_val_t val = conf_zone_get(conf(), C_ZONEFILE_SYNC, zone->name);
int64_t dbsync_timeout = conf_int(&val);
if (dbsync_timeout == 0) {
int64_t sync_timeout = conf_int(&val);
if (sync_timeout == 0) {
zone_events_schedule(zone, ZONE_EVENT_FLUSH, ZONE_EVENT_NOW);
} else if (!zone_events_is_scheduled(zone, ZONE_EVENT_FLUSH)) {
zone_events_schedule(zone, ZONE_EVENT_FLUSH, dbsync_timeout);
} else if (sync_timeout > 0 &&
!zone_events_is_scheduled(zone, ZONE_EVENT_FLUSH)) {
zone_events_schedule(zone, ZONE_EVENT_FLUSH, sync_timeout);
}
/* Transfer cleanup. */
......@@ -496,9 +500,9 @@ int event_flush(zone_t *zone)
/* Reschedule. */
conf_val_t val = conf_zone_get(conf(), C_ZONEFILE_SYNC, zone->name);
int64_t next_timeout = conf_int(&val);
if (next_timeout > 0) {
zone_events_schedule(zone, ZONE_EVENT_FLUSH, next_timeout);
int64_t sync_timeout = conf_int(&val);
if (sync_timeout > 0) {
zone_events_schedule(zone, ZONE_EVENT_FLUSH, sync_timeout);
}
/* Check zone contents. */
......
......@@ -77,8 +77,8 @@ static void replan_xfer(zone_t *zone, const zone_t *old_zone)
static void replan_flush(zone_t *zone, const zone_t *old_zone)
{
conf_val_t val = conf_zone_get(conf(), C_ZONEFILE_SYNC, zone->name);
int64_t dbsync_timeout = conf_int(&val);
if (dbsync_timeout <= 0) {
int64_t sync_timeout = conf_int(&val);
if (sync_timeout <= 0) {
// Immediate sync scheduled after events.
return;
}
......@@ -86,12 +86,12 @@ static void replan_flush(zone_t *zone, const zone_t *old_zone)
const time_t flush_time = zone_events_get_time(old_zone, ZONE_EVENT_FLUSH);
if (flush_time <= ZONE_EVENT_NOW) {
// Not scheduled previously.
zone_events_schedule(zone, ZONE_EVENT_FLUSH, dbsync_timeout);
zone_events_schedule(zone, ZONE_EVENT_FLUSH, sync_timeout);
return;
}
// Pick time to schedule: either reuse or schedule sooner than old event.
const time_t schedule_at = MIN(time(NULL) + dbsync_timeout, flush_time);
const time_t schedule_at = MIN(time(NULL) + sync_timeout, flush_time);
zone_events_schedule_at(zone, ZONE_EVENT_FLUSH, schedule_at);
}
......
......@@ -315,6 +315,13 @@ int zone_flush_journal(zone_t *zone)
return KNOT_EINVAL;
}
/* Check for disabled zonefile synchronization. */
conf_val_t val = conf_zone_get(conf(), C_ZONEFILE_SYNC, zone->name);
if (conf_int(&val) < 0 && (zone->flags & ZONE_FORCE_FLUSH) == 0) {
return KNOT_EOK;
}
zone->flags &= ~ZONE_FORCE_FLUSH;
/* Check for difference against zonefile serial. */
zone_contents_t *contents = zone->contents;
uint32_t serial_to = zone_contents_serial(contents);
......
......@@ -45,7 +45,8 @@ struct process_query_param;
*/
typedef enum zone_flag_t {
ZONE_FORCE_AXFR = 1 << 0, /* Force AXFR as next transfer. */
ZONE_FORCE_RESIGN = 1 << 1 /* Force zone resign. */
ZONE_FORCE_RESIGN = 1 << 1, /* Force zone resign. */
ZONE_FORCE_FLUSH = 1 << 2 /* Force zone flush. */
} zone_flag_t;
/*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment