From 28dcfa23585c35c70a59c793c0cef5a8ee3a17a1 Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Tue, 16 Jun 2020 22:33:56 +0200 Subject: log all attempts to place duplicates in database --- src/perform_queries.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/perform_queries.py b/src/perform_queries.py index 1d20b13..aae71aa 100755 --- a/src/perform_queries.py +++ b/src/perform_queries.py @@ -7,7 +7,7 @@ import unbound import psycopg2 # our own module used by several scripts in the project -from ztdnslib import start_db_connection, get_ztdns_config +from ztdnslib import start_db_connection, get_ztdns_config, log class dns_queries: def __init__(self, dns_IP, dns_id, services): @@ -58,6 +58,8 @@ def query_planned_queries(cursor, hour, vpn_id): return dnss_to_query def resolve_call_back(mydata, status, result): + global dups + query = mydata # debugging print("callback called for {}".format(result.qname)) @@ -95,10 +97,11 @@ def resolve_call_back(mydata, status, result): # Unique constraint is stopping us from adding duplicates; # This is most likey because back-end has been run multiple times # during the same hour (bad configuration or admin running manually - # after cron) - pass + # after cron), we'll write to logs about that. + dups = True # no committing, since auto-commit mode is set on the connection +dups = False hour = argv[1] vpn_id = argv[2] config = get_ztdns_config() @@ -146,3 +149,6 @@ for thread in threads: cursor.close() connection.close() + +if dups: + log('results already exist for vpn {}'.format(vpn_id)) -- cgit v1.2.3