diff -Nru fail2ban-0.9.3/debian/changelog fail2ban-0.9.3/debian/changelog --- fail2ban-0.9.3/debian/changelog 2015-08-01 02:16:30.000000000 +0000 +++ fail2ban-0.9.3/debian/changelog 2016-07-15 03:52:02.000000000 +0000 @@ -1,3 +1,9 @@ +fail2ban (0.9.3-1.1~wily1) wily; urgency=high + + * Extreme speedup of all sqlite database operations (gh-1436), + + -- Robert Hardy Thu, 14 Jul 2016 18:45:43 -0400 + fail2ban (0.9.3-1) unstable; urgency=medium * Fresh upstream release diff -Nru fail2ban-0.9.3/debian/patches/0002-Database-Speedup-1436.patch fail2ban-0.9.3/debian/patches/0002-Database-Speedup-1436.patch --- fail2ban-0.9.3/debian/patches/0002-Database-Speedup-1436.patch 1970-01-01 00:00:00.000000000 +0000 +++ fail2ban-0.9.3/debian/patches/0002-Database-Speedup-1436.patch 2016-07-14 22:51:20.000000000 +0000 @@ -0,0 +1,77 @@ +--- a/ChangeLog ++++ b/ChangeLog +@@ -62,6 +62,11 @@ ver. 0.9.3 (2015/08/01) - lets-all-stay- + - pass2allow-ftp - allows FTP traffic after successful HTTP authentication + + - Enhancements: ++ * Extreme speedup of all sqlite database operations (gh-1436), ++ by using of following sqlite options: ++ - (synchronous = OFF) write data through OS without syncing ++ - (journal_mode = MEMORY) use memory for the transaction logging ++ - (temp_store = MEMORY) temporary tables and indices are kept in memory + * action.d/cloudflare.conf - improved documentation on how to allow + multiple CF accounts, and jail.conf got new compound action + definition action_cf_mwl to submit cloudflare report. +--- a/fail2ban/server/database.py ++++ b/fail2ban/server/database.py +@@ -181,8 +181,23 @@ class Fail2BanDb(object): + filename, e.args[0]) + raise + ++ # differentiate pypy: switch journal mode later (save it during the upgrade), ++ # to prevent errors like "database table is locked": ++ try: ++ import __pypy__ ++ pypy = True ++ except ImportError: ++ pypy = False ++ + cur = self._db.cursor() +- cur.execute("PRAGMA foreign_keys = ON;") ++ cur.execute("PRAGMA foreign_keys = ON") ++ # speedup: write data through OS without syncing (no wait): ++ cur.execute("PRAGMA synchronous = OFF") ++ # speedup: transaction log in memory, alternate using OFF (disable, rollback will be impossible): ++ if not pypy: ++ cur.execute("PRAGMA journal_mode = MEMORY") ++ # speedup: temporary tables and indices are kept in memory: ++ cur.execute("PRAGMA temp_store = MEMORY") + + try: + cur.execute("SELECT version FROM fail2banDb LIMIT 1") +@@ -202,6 +217,9 @@ class Fail2BanDb(object): + Fail2BanDb.__version__, version, newversion) + raise RuntimeError('Failed to fully update') + finally: ++ # pypy: set journal mode after possible upgrade db: ++ if pypy: ++ cur.execute("PRAGMA journal_mode = MEMORY") + cur.close() + + @property +@@ -244,13 +262,14 @@ class Fail2BanDb(object): + + A timestamped backup is also created prior to attempting the update. + """ +- self._dbBackupFilename = self.filename + '.' + time.strftime('%Y%m%d-%H%M%S', MyTime.gmtime()) +- shutil.copyfile(self.filename, self._dbBackupFilename) +- logSys.info("Database backup created: %s", self._dbBackupFilename) + if version > Fail2BanDb.__version__: + raise NotImplementedError( + "Attempt to travel to future version of database ...how did you get here??") + ++ self._dbBackupFilename = self.filename + '.' + time.strftime('%Y%m%d-%H%M%S', MyTime.gmtime()) ++ shutil.copyfile(self.filename, self._dbBackupFilename) ++ logSys.info("Database backup created: %s", self._dbBackupFilename) ++ + if version < 2: + cur.executescript("BEGIN TRANSACTION;" + "CREATE TEMPORARY TABLE logs_temp AS SELECT * FROM logs;" +@@ -547,5 +566,4 @@ class Fail2BanDb(object): + (MyTime.time() - self._purgeAge, )) + cur.execute( + "DELETE FROM jails WHERE enabled = 0 " +- "AND NOT EXISTS(SELECT * FROM bans WHERE jail = jails.name)") +- ++ "AND NOT EXISTS(SELECT * FROM bans WHERE jail = jails.name)") +\ No newline at end of file diff -Nru fail2ban-0.9.3/debian/patches/series fail2ban-0.9.3/debian/patches/series --- fail2ban-0.9.3/debian/patches/series 2015-08-01 02:16:30.000000000 +0000 +++ fail2ban-0.9.3/debian/patches/series 2016-07-14 22:43:39.000000000 +0000 @@ -1,2 +1,3 @@ deb_init_paths deb_manpages_reportbug +0002-Database-Speedup-1436.patch