|
|
@ -29,6 +29,7 @@ from synapse.api.errors import StoreError |
|
|
|
from synapse.storage.engines import PostgresEngine |
|
|
|
from synapse.storage.engines import PostgresEngine |
|
|
|
from synapse.util.caches.descriptors import Cache |
|
|
|
from synapse.util.caches.descriptors import Cache |
|
|
|
from synapse.util.logcontext import LoggingContext, PreserveLoggingContext |
|
|
|
from synapse.util.logcontext import LoggingContext, PreserveLoggingContext |
|
|
|
|
|
|
|
from synapse.util.stringutils import exception_to_unicode |
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
@ -249,32 +250,32 @@ class SQLBaseStore(object): |
|
|
|
except self.database_engine.module.OperationalError as e: |
|
|
|
except self.database_engine.module.OperationalError as e: |
|
|
|
# This can happen if the database disappears mid |
|
|
|
# This can happen if the database disappears mid |
|
|
|
# transaction. |
|
|
|
# transaction. |
|
|
|
logger.warn( |
|
|
|
logger.warning( |
|
|
|
"[TXN OPERROR] {%s} %s %d/%d", |
|
|
|
"[TXN OPERROR] {%s} %s %d/%d", |
|
|
|
name, e, i, N |
|
|
|
name, exception_to_unicode(e), i, N |
|
|
|
) |
|
|
|
) |
|
|
|
if i < N: |
|
|
|
if i < N: |
|
|
|
i += 1 |
|
|
|
i += 1 |
|
|
|
try: |
|
|
|
try: |
|
|
|
conn.rollback() |
|
|
|
conn.rollback() |
|
|
|
except self.database_engine.module.Error as e1: |
|
|
|
except self.database_engine.module.Error as e1: |
|
|
|
logger.warn( |
|
|
|
logger.warning( |
|
|
|
"[TXN EROLL] {%s} %s", |
|
|
|
"[TXN EROLL] {%s} %s", |
|
|
|
name, e1, |
|
|
|
name, exception_to_unicode(e1), |
|
|
|
) |
|
|
|
) |
|
|
|
continue |
|
|
|
continue |
|
|
|
raise |
|
|
|
raise |
|
|
|
except self.database_engine.module.DatabaseError as e: |
|
|
|
except self.database_engine.module.DatabaseError as e: |
|
|
|
if self.database_engine.is_deadlock(e): |
|
|
|
if self.database_engine.is_deadlock(e): |
|
|
|
logger.warn("[TXN DEADLOCK] {%s} %d/%d", name, i, N) |
|
|
|
logger.warning("[TXN DEADLOCK] {%s} %d/%d", name, i, N) |
|
|
|
if i < N: |
|
|
|
if i < N: |
|
|
|
i += 1 |
|
|
|
i += 1 |
|
|
|
try: |
|
|
|
try: |
|
|
|
conn.rollback() |
|
|
|
conn.rollback() |
|
|
|
except self.database_engine.module.Error as e1: |
|
|
|
except self.database_engine.module.Error as e1: |
|
|
|
logger.warn( |
|
|
|
logger.warning( |
|
|
|
"[TXN EROLL] {%s} %s", |
|
|
|
"[TXN EROLL] {%s} %s", |
|
|
|
name, e1, |
|
|
|
name, exception_to_unicode(e1), |
|
|
|
) |
|
|
|
) |
|
|
|
continue |
|
|
|
continue |
|
|
|
raise |
|
|
|
raise |
|
|
|