From: Roland Häder Date: Sun, 4 Jun 2023 03:07:20 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1767881c15119171ba6cd6589c22d999d1e54703;p=fba.git Continued: - committing every single INSERT INTO will cause a lot of I/O load, let's combine them all into a single transaction --- diff --git a/fba/fba.py b/fba/fba.py index db002a9..14d500b 100644 --- a/fba/fba.py +++ b/fba/fba.py @@ -1074,8 +1074,6 @@ def block_instance(blocker: str, blocked: str, reason: str, block_level: str): time.time() ), ) - - connection.commit() except BaseException as e: print(f"ERROR: failed SQL query: blocker='{blocker}',blocked='{blocked}',reason='{reason}',block_level='{block_level}',exception[{type(e)}]:'{str(e)}'") sys.exit(255) diff --git a/fba/instances.py b/fba/instances.py index 1271048..9b0323a 100644 --- a/fba/instances.py +++ b/fba/instances.py @@ -116,6 +116,7 @@ def update_instance_data(domain: str): print(f"WARNING: Did not update any rows: domain='{domain}',fields()={len(fields)} - EXIT!") return + # DEBUG: print("DEBUG: Committing changes ...") fba.connection.commit() # DEBUG: print("DEBUG: Deleting instance_data for domain:", domain) diff --git a/fetch_blocks.py b/fetch_blocks.py index a9b8535..260945f 100755 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -141,6 +141,7 @@ for blocker, software, origin, nodeinfo_url in rows: print(f"DEBUG: Updating block last seen for blocker='{blocker}',blocked='{blocked}' ...") fba.update_last_seen(blocker, blocked, block_level) + # DEBUG: print("DEBUG: Committing changes ...") fba.connection.commit() # Reasons @@ -340,6 +341,7 @@ for blocker, software, origin, nodeinfo_url in rows: fba.update_last_seen(blocker, blocking, block_level) fba.update_block_reason(reason, blocker, blocking, block_level) + # DEBUG: print("DEBUG: Committing changes ...") fba.connection.commit() except Exception as e: print(f"ERROR: blocker='{blocker}',software='{software}',exception[{type(e)}]:'{str(e)}'") @@ -437,6 +439,7 @@ for blocker, software, origin, nodeinfo_url in rows: fba.update_last_seen(blocker, blocked, block_level) fba.update_block_reason(reason, blocker, blocked, block_level) + # DEBUG: print("DEBUG: Committing changes ...") fba.connection.commit() except Exception as e: print(f"ERROR: blocker='{blocker}',software='{software}',exception[{type(e)}]:'{str(e)}'") @@ -512,6 +515,7 @@ for blocker, software, origin, nodeinfo_url in rows: # DEBUG: print(f"DEBUG: Setting block reason for blocked='{blocked}':'{peer['public_comment']}'") entry["reason"] = peer["public_comment"] + # DEBUG: print("DEBUG: Committing changes ...") fba.connection.commit() except Exception as e: print(f"ERROR: blocker='{blocker}',software='{software}',exception[{type(e)}]:'{str(e)}'") diff --git a/fetch_cs.py b/fetch_cs.py index 94e4d68..e65738d 100755 --- a/fetch_cs.py +++ b/fetch_cs.py @@ -119,4 +119,7 @@ if len(domains) > 0: # DEBUG: print(f"DEBUG: domain='{row['domain']}',block_level='{block_level}' blocked by chaos.social, adding ...") fba.block_instance('chaos.social', row["domain"], row["reason"], block_level) + # DEBUG: print("DEBUG: Committing changes ...") + fba.connection.commit() + boot.shutdown()