Skip to content

Commit

Permalink
If deleteZone fails due to a backend exception, show it...
Browse files Browse the repository at this point in the history
...rather than any further backend exception caused by
abortTransaction(), which will be much less helpful.

Using the sqlite backend on a full filesystem, pdnsutil delete-zone now
correctly reports "database or disk is full" instead of "cannot rollback
- no transaction is active" which no human can make sense of in this
situation.
  • Loading branch information
miodvallat committed Feb 14, 2025
1 parent cc7d8cd commit 415a97c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pdns/pdnsutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@ static int increaseSerial(const DNSName& zone, DNSSECKeeper &dk)

auto rrs = vector<DNSResourceRecord>{rr};
if (!sd.db->replaceRRSet(sd.domain_id, zone, rr.qtype, rrs)) {
sd.db->abortTransaction();
cerr << "Backend did not replace SOA record. Backend might not support this operation." << endl;
sd.db->abortTransaction();
return -1;
}

Expand Down Expand Up @@ -997,7 +997,13 @@ static int deleteZone(const DNSName &zone) {
return EXIT_SUCCESS;
}
} catch (...) {
di.backend->abortTransaction();
try {
di.backend->abortTransaction();
} catch (...) {
// Ignore this exception (which is likely "cannot rollback - no
// transaction is active"), we have a more important one we want to
// rethrow.
}
throw;
}

Expand Down

0 comments on commit 415a97c

Please sign in to comment.