From 4a8e33b9f01820f576d8000d9e479d70ee693c62 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 4 May 2021 17:22:56 +1000 Subject: [PATCH] Always perform a re-write when processing a version 1 journal version 1 journals may have a mix of type 1 and type 2 transaction headers so always use the recovery code. --- bin/tools/named-journalprint.rst | 9 +++++---- doc/man/named-journalprint.1in | 9 +++++---- lib/dns/journal.c | 6 ++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/bin/tools/named-journalprint.rst b/bin/tools/named-journalprint.rst index 974afe39d9..8bc4a3e136 100644 --- a/bin/tools/named-journalprint.rst +++ b/bin/tools/named-journalprint.rst @@ -51,10 +51,11 @@ into a human-readable text format. Each line begins with ``add`` or ``del``, to indicate whether the record was added or deleted, and continues with the resource record in master-file format. -The ``-c`` option provides a mechanism to compact the journal starting -with the specified serial. Note this option *must not* be used while -``named`` is running and can cause data loss if the the zone file does -not contain the data that is being remove. Use with extreme caution. +The ``-c`` (compact) option provides a mechanism to reduce the size of +a journal by removing (most/all) transactions prior to the specified +serial number. Note: this option *must not* be used while ``named`` is +running, and can cause data loss if the zone file has not been updated +to contain the data being removed from the journal. Use with extreme caution. The ``-x`` option causes additional data about the journal file to be printed at the beginning of the output and before each group of changes. diff --git a/doc/man/named-journalprint.1in b/doc/man/named-journalprint.1in index cebd2103d7..8b4c7c6929 100644 --- a/doc/man/named-journalprint.1in +++ b/doc/man/named-journalprint.1in @@ -52,10 +52,11 @@ into a human\-readable text format. Each line begins with \fBadd\fP or \fBdel\fP to indicate whether the record was added or deleted, and continues with the resource record in master\-file format. .sp -The \fB\-c\fP option provides a mechanism to compact the journal starting -with the specified serial. Note this option \fImust not\fP be used while -\fBnamed\fP is running and can cause data loss if the the zone file does -not contain the data that is being remove. Use with extreme caution. +The \fB\-c\fP (compact) option provides a mechanism to reduce the size of +a journal by removing (most/all) transactions prior to the specified +serial number. Note: this option \fImust not\fP be used while \fBnamed\fP is +running, and can cause data loss if the zone file has not been updated +to contain the data being removed from the journal. Use with extreme caution. .sp The \fB\-x\fP option causes additional data about the journal file to be printed at the beginning of the output and before each group of changes. diff --git a/lib/dns/journal.c b/lib/dns/journal.c index c4931ba101..878255e4be 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -2493,6 +2493,11 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial, return (result); } + /* + * Always perform a re-write when processing a version 1 journal. + */ + rewrite = j1->header_ver1; + /* * Check whether we need to rewrite the whole journal * file (for example, to upversion it). @@ -2581,6 +2586,7 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial, INSIST(best_guess.serial != j1->header.end.serial); if (best_guess.serial != serial) { CHECK(journal_next(j1, &best_guess, false)); + serial = best_guess.serial; } /*