diff options
author | Wojciech Kosior <kwojtus@protonmail.com> | 2020-06-16 22:33:56 +0200 |
---|---|---|
committer | Wojciech Kosior <kwojtus@protonmail.com> | 2020-06-16 22:33:56 +0200 |
commit | 28dcfa23585c35c70a59c793c0cef5a8ee3a17a1 (patch) | |
tree | 5fd7e3b94f2f8d1f56b40c1260b968f96081fa1a /src | |
parent | 780789c6c233ace56dd293813dd749edcada44db (diff) | |
download | 0tdns-28dcfa23585c35c70a59c793c0cef5a8ee3a17a1.tar.gz 0tdns-28dcfa23585c35c70a59c793c0cef5a8ee3a17a1.zip |
log all attempts to place duplicates in database
Diffstat (limited to 'src')
-rwxr-xr-x | src/perform_queries.py | 12 |
1 files 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)) |