Synapse 1.4.1 (2019-10-18)

==========================
 
 No changes since 1.4.1rc1.
 
 Synapse 1.4.1rc1 (2019-10-17)
 =============================
 
 Bugfixes
 --------
 
 - Fix bug where redacted events were sometimes incorrectly censored in the database, breaking APIs that attempted to fetch such events. ([\#6185](https://github.com/matrix-org/synapse/issues/6185), [5b0e9948](5b0e9948ea))
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEdVkXOgzrGzds0jtrHgFcFF8ZFs0FAl2pg/YACgkQHgFcFF8Z
 Fs005BAAtPckcNZ4u/CVZCROFBGsmA5MMFw2eKIVhkTXt/lcq4rY/XguTrEq1NlI
 0f6dHiRY6c4wZEJxpTpH4H4xVD4Qs+iNjPgCwEPVxsvgtSGymDHsXJUo3e5TlXDF
 q9e3GXCXkzdHDXyKi1ZdiiNK7Ul6oRqw+Iuudh5M5z+9J/fI56uQlc+njMFNUNTY
 2QDN53xOGx2puLtJ+huGwlQOi2ADsikyYx4w27qBO6/3Y8fEP0JYcd/iPq+rORVS
 6WUsvtOlbMjMDJYGfpPrHzswgY6d/woFfQbK7bseqvPg5AXtUG9qSacHzaxYiD12
 2i04+UkH955W7i/97oW3MR+q7XJaD77Okkxw6XV/SbN/ynK0TvWnjhGiEiSKM7z6
 ZmAVh2XSKIjflCnj8dC8JECsNUEFCRN1CUCa0V19+F5vxvrTRZ5N3pYmZdiYSlNE
 rTB2oYTyNtMzPzeut7imBEk2o21hmuF7h8CqffuBWwpuPHk4+sY/675kxWvUsUmt
 Ldfr9l6gHv/45Oki91teDRtRvCVXR5YO6NOx5qoryrUDsvgsxelzO8BDloaTBaNl
 EDQt4C6gty3Hd13Q1GT42nc9uB3zorz6fCtNZDPPrSHBopf0ZB9DFp7ImBIVLl+l
 h4OIqAS99LBBooQEQX8YbelxzKTtzQ9400QG0O2nFPJvnfUjFRo=
 =kY2n
 -----END PGP SIGNATURE-----

Merge tag 'v1.4.1'

Synapse 1.4.1 (2019-10-18)
==========================

No changes since 1.4.1rc1.

Synapse 1.4.1rc1 (2019-10-17)
=============================

Bugfixes
--------

- Fix bug where redacted events were sometimes incorrectly censored in the database, breaking APIs that attempted to fetch such events. ([\#6185](https://github.com/matrix-org/synapse/issues/6185), [5b0e9948](5b0e9948ea))
This commit is contained in:
Brendan Abolivier 2019-10-18 10:59:01 +01:00
commit 9fc14b5e84
6 changed files with 91 additions and 5 deletions

View File

@ -1,3 +1,17 @@
Synapse 1.4.1 (2019-10-18)
==========================
No changes since 1.4.1rc1.
Synapse 1.4.1rc1 (2019-10-17)
=============================
Bugfixes
--------
- Fix bug where redacted events were sometimes incorrectly censored in the database, breaking APIs that attempted to fetch such events. ([\#6185](https://github.com/matrix-org/synapse/issues/6185), [5b0e9948](https://github.com/matrix-org/synapse/commit/5b0e9948eaae801643e594b5abc8ee4b10bd194e))
Synapse 1.4.0 (2019-10-03) Synapse 1.4.0 (2019-10-03)
========================== ==========================

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
matrix-synapse-py3 (1.4.1) stable; urgency=medium
* New synapse release 1.4.1.
-- Synapse Packaging team <packages@matrix.org> Fri, 18 Oct 2019 10:13:27 +0100
matrix-synapse-py3 (1.4.0) stable; urgency=medium matrix-synapse-py3 (1.4.0) stable; urgency=medium
* New synapse release 1.4.0. * New synapse release 1.4.0.

View File

@ -35,4 +35,4 @@ try:
except ImportError: except ImportError:
pass pass
__version__ = "1.4.0" __version__ = "1.4.1"

View File

@ -23,7 +23,7 @@ from functools import wraps
from six import iteritems, text_type from six import iteritems, text_type
from six.moves import range from six.moves import range
from canonicaljson import encode_canonical_json, json from canonicaljson import json
from prometheus_client import Counter, Histogram from prometheus_client import Counter, Histogram
from twisted.internet import defer from twisted.internet import defer
@ -1632,9 +1632,7 @@ class EventsStore(
and original_event.internal_metadata.is_redacted() and original_event.internal_metadata.is_redacted()
): ):
# Redaction was allowed # Redaction was allowed
pruned_json = encode_canonical_json( pruned_json = encode_json(prune_event_dict(original_event.get_dict()))
prune_event_dict(original_event.get_dict())
)
else: else:
# Redaction wasn't allowed # Redaction wasn't allowed
pruned_json = None pruned_json = None

View File

@ -71,6 +71,19 @@ class EventsBackgroundUpdatesStore(BackgroundUpdateStore):
"redactions_received_ts", self._redactions_received_ts "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 @defer.inlineCallbacks
def _background_reindex_fields_sender(self, progress, batch_size): def _background_reindex_fields_sender(self, progress, batch_size):
target_min_stream_id = progress["target_min_stream_id_inclusive"] 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") yield self._end_background_update("redactions_received_ts")
return count 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

View File

@ -0,0 +1,25 @@
/* Copyright 2019 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-- There was a bug where we may have updated censored redactions as bytes,
-- 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');