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
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
7f18b3d5
Commit
7f18b3d5
authored
5 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Do the update as a background index
parent
1d385837
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/storage/events_bg_updates.py
+43
-0
43 additions, 0 deletions
synapse/storage/events_bg_updates.py
synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres
+8
-9
8 additions, 9 deletions
...schema/delta/56/redaction_censor3_fix_update.sql.postgres
with
51 additions
and
9 deletions
synapse/storage/events_bg_updates.py
+
43
−
0
View file @
7f18b3d5
...
...
@@ -71,6 +71,19 @@ class EventsBackgroundUpdatesStore(BackgroundUpdateStore):
"
redactions_received_ts
"
,
self
.
_redactions_received_ts
)
# This index gets deleted in `event_fix_redactions_bytes` update
self
.
register_background_index_update
(
"
event_fix_redactions_bytes_create_index
"
,
index_name
=
"
redactions_censored_redacts
"
,
table
=
"
redactions
"
,
columns
=
[
"
redacts
"
],
where_clause
=
"
have_censored
"
,
)
self
.
register_background_update_handler
(
"
event_fix_redactions_bytes
"
,
self
.
_event_fix_redactions_bytes
)
@defer.inlineCallbacks
def
_background_reindex_fields_sender
(
self
,
progress
,
batch_size
):
target_min_stream_id
=
progress
[
"
target_min_stream_id_inclusive
"
]
...
...
@@ -458,3 +471,33 @@ class EventsBackgroundUpdatesStore(BackgroundUpdateStore):
yield
self
.
_end_background_update
(
"
redactions_received_ts
"
)
return
count
@defer.inlineCallbacks
def
_event_fix_redactions_bytes
(
self
,
progress
,
batch_size
):
"""
Undoes hex encoded censored redacted event JSON.
"""
def
_event_fix_redactions_bytes_txn
(
txn
):
# This update is quite fast due to new index.
txn
.
execute
(
"""
UPDATE event_json
SET
json = convert_from(json::bytea,
'
utf8
'
)
FROM redactions
WHERE
redactions.have_censored
AND event_json.event_id = redactions.redacts
AND json NOT LIKE
'
{%
'
;
"""
)
txn
.
execute
(
"
DROP INDEX redactions_censored_redacts
"
)
yield
self
.
runInteraction
(
"
_event_fix_redactions_bytes
"
,
_event_fix_redactions_bytes_txn
)
yield
self
.
_end_background_update
(
"
event_fix_redactions_bytes
"
)
return
1
This diff is collapsed.
Click to expand it.
synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres
+
8
−
9
View file @
7f18b3d5
...
...
@@ -15,12 +15,11 @@
-- There was a bug where we may have updated censored redactions as bytes,
-- which can (somehow) cause json to be inserted hex encoded. This goes and
-- undoes any such hex encoded JSON.
UPDATE event_json SET json = convert_from(json::bytea, 'utf8')
WHERE event_id IN (
SELECT event_json.event_id
FROM event_json
INNER JOIN redactions ON (event_json.event_id = redacts)
WHERE have_censored AND json NOT LIKE '{%'
);
-- which can (somehow) cause json to be inserted hex encoded. These updates go
-- and undoes any such hex encoded JSON.
INSERT into background_updates (update_name, progress_json)
VALUES ('event_fix_redactions_bytes_create_index', '{}');
INSERT into background_updates (update_name, progress_json, depends_on)
VALUES ('event_fix_redactions_bytes', '{}', 'event_fix_redactions_bytes_create_index');
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