]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
load/double changeset: proper check of zone-in-journal non-existence
authorLibor Peltan <libor.peltan@nic.cz>
Wed, 20 Nov 2019 15:04:05 +0000 (16:04 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Thu, 21 Nov 2019 14:43:32 +0000 (15:43 +0100)
...the previous did not work with old_contents_exists

src/knot/events/handlers/load.c
src/knot/journal/journal_metadata.c
src/knot/journal/journal_metadata.h
src/knot/nameserver/ixfr.c
src/knot/zone/zone.c
src/knot/zone/zone.h
src/knot/zone/zonedb.c
src/utils/kjournalprint/main.c
tests/knot/test_journal.c

index 577dc7b9c940fc49eb4f3f05c3326edd41d840f1..843f5b913faf52e175dd3a6045bc5064e98c166f 100644 (file)
@@ -217,7 +217,7 @@ int event_load(conf_t *conf, zone_t *zone)
 
        uint32_t middle_serial = zone_contents_serial(up.new_cont);
 
-       if (do_diff && old_contents_exist && journal_conts == NULL && dnssec_enable) {
+       if (do_diff && old_contents_exist && dnssec_enable && !zone_journal_has_zij(zone)) {
                ret = zone_update_start_extra(&up);
                if (ret != KNOT_EOK) {
                        goto cleanup;
index 38900b7020fbfa3ebc29a3ccc56efc2512f09ec2..e8e8c092e2c75e9aecd09f4aea4ffe33f9d4e1d4 100644 (file)
@@ -298,7 +298,7 @@ int journal_set_flushed(zone_journal_t j)
        return txn.ret;
 }
 
-int journal_info(zone_journal_t j, bool *exists, uint32_t *first_serial,
+int journal_info(zone_journal_t j, bool *exists, uint32_t *first_serial, bool *has_zij,
                  uint32_t *serial_to, bool *has_merged, uint32_t *merged_serial,
                  uint64_t *occupied, uint64_t *occupied_total)
 {
@@ -318,6 +318,9 @@ int journal_info(zone_journal_t j, bool *exists, uint32_t *first_serial,
        if (first_serial != NULL) {
                *first_serial = md.first_serial;
        }
+       if (has_zij != NULL) {
+               *has_zij = journal_contains(&txn, true, 0, j.zone);
+       }
        if (serial_to != NULL) {
                *serial_to = md.serial_to;
        }
index 17580a4fd38ccb565ef2e01ef2cdd34f8d4fac1e..b91b431db20a6ffb0985d7a9106180f64936a32d 100644 (file)
@@ -135,6 +135,7 @@ int journal_set_flushed(zone_journal_t j);
  * \param j                Zone journal.
  * \param exists           Output: bool if the zone exists in the journal.
  * \param first_serial     Optional output: serial-from of the first changeset in journal.
+ * \param has_zij          Optional output: bool if there is zone-in-journal.
  * \param serial_to        Optional output: serial.to of the last changeset in journal.
  * \param has_merged       Optional output: bool if there is a special (non zone-in-journal) merged changeset.
  * \param merged_serial    Optional output: serial-from of the merged changeset.
@@ -143,14 +144,14 @@ int journal_set_flushed(zone_journal_t j);
  *
  * \return KNOT_E*
  */
-int journal_info(zone_journal_t j, bool *exists, uint32_t *first_serial,
+int journal_info(zone_journal_t j, bool *exists, uint32_t *first_serial, bool *has_zij,
                  uint32_t *serial_to, bool *has_merged, uint32_t *merged_serial,
                  uint64_t *occupied, uint64_t *occupied_total);
 
 /*! \brief Return true if this zone exists in journal DB. */
 inline static bool journal_is_existing(zone_journal_t j) {
        bool ex = false;
-       (void)journal_info(j, &ex, NULL, NULL, NULL, NULL, NULL, NULL);
+       (void)journal_info(j, &ex, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        return ex;
 }
 
index 1c12b1be7ba4824947e43bb42f28c1a8b39d8fce..63b331ee54a8b690f971933292f7ee40d9554656 100644 (file)
@@ -106,7 +106,7 @@ static int ixfr_load_chsets(journal_read_t **journal_read, zone_t *zone,
 
        zone_journal_t j = zone_journal(zone);
        bool j_exists = false;
-       int ret = journal_info(j, &j_exists, NULL, &j_serial_to, NULL, NULL, NULL, NULL);
+       int ret = journal_info(j, &j_exists, NULL, NULL, &j_serial_to, NULL, NULL, NULL, NULL);
        if (ret != KNOT_EOK) {
                return ret;
        } else if (!j_exists) {
index 89ea931393496f44272507d0e26a24755a2e0e5f..be37ad85312d949b950ac44470e430679456b9dc 100644 (file)
@@ -285,6 +285,13 @@ int zone_flush_journal(conf_t *conf, zone_t *zone, bool verbose)
        return flush_journal(conf, zone, false, verbose);
 }
 
+bool zone_journal_has_zij(zone_t *zone)
+{
+       bool exists = false, zij = false;
+       journal_info(zone_journal(zone), &exists, NULL, &zij, NULL, NULL, NULL, NULL, NULL);
+       return exists && zij;
+}
+
 zone_contents_t *zone_switch_contents(zone_t *zone, zone_contents_t *new_contents)
 {
        if (zone == NULL) {
index d419581f5e5b81253905d030dcc4a1fb74120b58..bed37ec054fab7b92b3558a01e9d3788170faf50 100644 (file)
@@ -130,6 +130,8 @@ int zone_in_journal_store(conf_t *conf, zone_t *zone, zone_contents_t *new_conte
 /*! \brief Synchronize zone file with journal. */
 int zone_flush_journal(conf_t *conf, zone_t *zone, bool verbose);
 
+bool zone_journal_has_zij(zone_t *zone);
+
 /*!
  * \brief Atomically switch the content of the zone.
  */
index 5cf8fc527b5a7d823384baae8294ca013f435eb4..58b98f7bc27342ffed4220653a9a3b0e446bc8ae 100644 (file)
@@ -33,7 +33,7 @@ static void discard_zone(zone_t *zone)
 
                // Flush if bootstrapped or if the journal doesn't exist.
                if (!zone->zonefile.exists || journal_info(
-                       zone_journal(zone), &exists, NULL, &journal_serial, NULL, NULL, NULL, NULL
+                       zone_journal(zone), &exists, NULL, NULL, &journal_serial, NULL, NULL, NULL, NULL
                    ) != KNOT_EOK || !exists || journal_serial != zone_serial) {
                        zone_flush_journal(conf(), zone, false);
                }
index 38fb193b72e9f9049afb4fc6d581e17a44f98439..a9140a974d40d4ab2da7f17733a11a87ba75e5d8 100644 (file)
@@ -172,7 +172,7 @@ int print_journal(char *path, knot_dname_t *name, print_params_t *params)
                return ret;
        }
 
-       ret = journal_info(j, &exists, NULL, NULL, NULL, NULL, &occupied, &occupied_all);
+       ret = journal_info(j, &exists, NULL, NULL, NULL, NULL, NULL, &occupied, &occupied_all);
        if (ret != KNOT_EOK || !exists) {
                fprintf(stderr, "This zone does not exist in DB %s\n", path);
                knot_lmdb_deinit(&jdb);
index 1efe783d9719a7a13921f0acfb071702a1af6aff..70bef41a0ee9d1dacf5e9966e85a7ff60047a344 100644 (file)
@@ -566,7 +566,7 @@ static changeset_t * tm_chs(const knot_dname_t * apex, int x)
 static int merged_present(void)
 {
        bool exists, has_merged;
-       return journal_info(jj, &exists, NULL, NULL, &has_merged, NULL, NULL, NULL) == KNOT_EOK && exists && has_merged;
+       return journal_info(jj, &exists, NULL, NULL, NULL, &has_merged, NULL, NULL, NULL) == KNOT_EOK && exists && has_merged;
 }
 
 static void test_merge(const knot_dname_t *apex)