From 2d8eadf2d012426c159f7c597cbd9b456a135923 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 17 May 2024 11:54:39 +0530 Subject: [PATCH] fix: Apply limit on matching rows, not read rows (#102) Binary log browser is unintuitive to use with filters, the "max lines" is applied before filtering. Since we have bounded size of bin log (100MB per file) just reading everything which is ~= 100MB of text is fine IMO. --- agent/database.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agent/database.py b/agent/database.py index 13ece353..b53fc8a0 100644 --- a/agent/database.py +++ b/agent/database.py @@ -30,7 +30,7 @@ def search_binary_log( f"mysqlbinlog --short-form --database {database} " f"--start-datetime '{start_datetime}' " f"--stop-datetime '{stop_datetime}' " - f" {log} | grep -Piv '{LINES_TO_SKIP}' | head -n {max_lines}" + f" {log} | grep -Piv '{LINES_TO_SKIP}'" ) DELIMITER = "/*!*/;" @@ -55,6 +55,8 @@ def search_binary_log( ), } ) + if len(events) > max_lines: + break return events @property