summary refs log tree commit diff
path: root/synapse/storage/search.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-02-14 15:54:09 +0000
committerRichard van der Hoff <richard@matrix.org>2018-02-14 15:54:09 +0000
commit5978dccff09e647509bb92e8125aa02e87f7a0a2 (patch)
treec507cf08080bc5d85728897dafa3d84e3dbb9d41 /synapse/storage/search.py
parentMerge branch 'matthew/gin_work_mem' into matthew/hit_the_gin (diff)
downloadsynapse-5978dccff09e647509bb92e8125aa02e87f7a0a2.tar.xz
remove overzealous exception handling
Diffstat (limited to 'synapse/storage/search.py')
-rw-r--r--synapse/storage/search.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/synapse/storage/search.py b/synapse/storage/search.py
index 8d294d497b..2755acff40 100644
--- a/synapse/storage/search.py
+++ b/synapse/storage/search.py
@@ -16,7 +16,6 @@
 from collections import namedtuple
 import logging
 import re
-import sys
 import ujson as json
 
 from twisted.internet import defer
@@ -335,25 +334,18 @@ class SearchStore(BackgroundUpdateStore):
             # (postgres 9.5 uses the separate gin_pending_list_limit setting,
             # so doesn't suffer the same problem, but changing work_mem will
             # be harmless)
+            #
+            # Note that we don't need to worry about restoring it on
+            # exception, because exceptions will cause the transaction to be
+            # rolled back, including the effects of the SET command.
+            #
+            # Also: we use SET rather than SET LOCAL because there's lots of
+            # other stuff going on in this transaction, which want to have the
+            # normal work_mem setting.
 
             txn.execute("SET work_mem='256kB'")
-            try:
-                txn.executemany(sql, args)
-            except Exception:
-                # we need to reset work_mem, but doing so may throw a new
-                # exception and we want to preserve the original
-                t, v, tb = sys.exc_info()
-                try:
-                    txn.execute("RESET work_mem")
-                except Exception as e:
-                    logger.warn(
-                        "exception resetting work_mem during exception "
-                        "handling: %r",
-                        e,
-                    )
-                raise t, v, tb
-            else:
-                txn.execute("RESET work_mem")
+            txn.executemany(sql, args)
+            txn.execute("RESET work_mem")
 
         elif isinstance(self.database_engine, Sqlite3Engine):
             sql = (