Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
e062f2df
Commit
e062f2df
authored
10 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Apparently we can't do txn.rollback(), so raise and catch an exception instead.
parent
c1a25756
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/__init__.py
+19
-11
19 additions, 11 deletions
synapse/storage/__init__.py
with
19 additions
and
11 deletions
synapse/storage/__init__.py
+
19
−
11
View file @
e062f2df
...
@@ -47,6 +47,11 @@ import os
...
@@ -47,6 +47,11 @@ import os
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
class
_RollbackButIsFineException
(
Exception
):
"""
This exception is used to rollback a transaction without implying
something went wrong.
"""
pass
class
DataStore
(
RoomMemberStore
,
RoomStore
,
class
DataStore
(
RoomMemberStore
,
RoomStore
,
RegistrationStore
,
StreamStore
,
ProfileStore
,
FeedbackStore
,
RegistrationStore
,
StreamStore
,
ProfileStore
,
FeedbackStore
,
...
@@ -71,13 +76,16 @@ class DataStore(RoomMemberStore, RoomStore,
...
@@ -71,13 +76,16 @@ class DataStore(RoomMemberStore, RoomStore,
self
.
min_token
-=
1
self
.
min_token
-=
1
stream_ordering
=
self
.
min_token
stream_ordering
=
self
.
min_token
latest
=
yield
self
.
_db_pool
.
runInteraction
(
try
:
self
.
_persist_pdu_event_txn
,
latest
=
yield
self
.
_db_pool
.
runInteraction
(
pdu
=
pdu
,
self
.
_persist_pdu_event_txn
,
event
=
event
,
pdu
=
pdu
,
backfilled
=
backfilled
,
event
=
event
,
stream_ordering
=
stream_ordering
,
backfilled
=
backfilled
,
)
stream_ordering
=
stream_ordering
,
)
except
_RollbackButIsFineException
as
e
:
pass
defer
.
returnValue
(
latest
)
defer
.
returnValue
(
latest
)
@defer.inlineCallbacks
@defer.inlineCallbacks
...
@@ -175,12 +183,12 @@ class DataStore(RoomMemberStore, RoomStore,
...
@@ -175,12 +183,12 @@ class DataStore(RoomMemberStore, RoomStore,
try
:
try
:
self
.
_simple_insert_txn
(
txn
,
"
events
"
,
vals
)
self
.
_simple_insert_txn
(
txn
,
"
events
"
,
vals
)
except
:
except
:
logger
.
exceptio
n
(
logger
.
war
n
(
"
Failed to persist, probably duplicate: %s
"
,
"
Failed to persist, probably duplicate: %s
"
,
event
.
event_id
event
.
event_id
,
exc_info
=
True
,
)
)
txn
.
rollback
()
raise
_RollbackButIsFineException
(
"
_persist_event
"
)
return
if
not
backfilled
and
hasattr
(
event
,
"
state_key
"
):
if
not
backfilled
and
hasattr
(
event
,
"
state_key
"
):
vals
=
{
vals
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment