Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
15122da0
Commit
15122da0
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Thats not how transactions work.
parent
ae6ff094
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/registration.py
+16
-13
16 additions, 13 deletions
synapse/storage/registration.py
with
16 additions
and
13 deletions
synapse/storage/registration.py
+
16
−
13
View file @
15122da0
...
...
@@ -197,26 +197,29 @@ class RegistrationStore(SQLBaseStore):
@defer.inlineCallbacks
def
user_delete_access_tokens
(
self
,
user_id
,
except_token_ids
=
[]):
def
f
(
txn
):
txn
.
execute
(
"
SELECT token FROM access_tokens
"
"
WHERE user_id = ? AND id NOT IN (%s)
"
%
(
sql
=
"
SELECT token FROM access_tokens WHERE user_id = ?
"
clauses
=
[
user_id
]
if
except_token_ids
:
sql
+=
"
AND id NOT IN (%s)
"
%
(
"
,
"
.
join
([
"
?
"
for
_
in
except_token_ids
]),
),
[
user_id
]
+
except_token_ids
)
)
clauses
+=
except_token_ids
txn
.
execute
(
sql
,
clauses
)
while
True
:
rows
=
txn
.
fetchmany
(
100
)
if
not
rows
:
break
rows
=
txn
.
fetchall
()
for
row
in
rows
:
n
=
100
chunks
=
[
rows
[
i
:
i
+
n
]
for
i
in
xrange
(
0
,
len
(
rows
),
n
)]
for
chunk
in
chunks
:
for
row
in
chunk
:
txn
.
call_after
(
self
.
get_user_by_access_token
.
invalidate
,
(
row
[
0
],))
txn
.
execute
(
"
DELETE FROM access_tokens WHERE token in (%s)
"
%
(
"
,
"
.
join
([
"
?
"
for
_
in
rows
]),
),
[
r
[
0
]
for
r
in
rows
]
"
,
"
.
join
([
"
?
"
for
_
in
chunk
]),
),
[
r
[
0
]
for
r
in
chunk
]
)
yield
self
.
runInteraction
(
"
user_delete_access_tokens
"
,
f
)
...
...
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