From 0841ddf8b0e554fec2ee43c7a92a43d570e82e31 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 19 Dec 2019 10:45:06 -0500 Subject: [PATCH] Handle integrity errors in DNS aggregator --- node-daemon/pvcd/DNSAggregatorInstance.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/node-daemon/pvcd/DNSAggregatorInstance.py b/node-daemon/pvcd/DNSAggregatorInstance.py index 13bb90ad..5fa2d87e 100644 --- a/node-daemon/pvcd/DNSAggregatorInstance.py +++ b/node-daemon/pvcd/DNSAggregatorInstance.py @@ -484,11 +484,15 @@ class AXFRDaemonInstance(object): r_data = record[4] if self.config['debug']: print('Add record: {}'.format(name)) - sql_curs.execute( - "INSERT INTO records (domain_id, name, ttl, type, prio, content) VALUES (%s, %s, %s, %s, %s, %s)", - (domain_id, r_name, r_ttl, r_type, 0, r_data) - ) - changed = True + try: + sql_curs.execute( + "INSERT INTO records (domain_id, name, ttl, type, prio, content) VALUES (%s, %s, %s, %s, %s, %s)", + (domain_id, r_name, r_ttl, r_type, 0, r_data) + ) + changed = True + except psycopg2.IntegrityError as e: + if self.config['debug']: + print('Failed to add record due to {}: {}'.format(e, name)) if changed: # Increase SOA serial