Merge branch 'release-v1.129' into matrix-org-hotfixes

This commit is contained in:
Devon Hudson
2025-04-16 07:20:54 -06:00
3 changed files with 33 additions and 18 deletions

View File

@@ -10,6 +10,8 @@
- Fix `force_tracing_for_users` config when using delegated auth. ([\#18334](https://github.com/element-hq/synapse/issues/18334)) - Fix `force_tracing_for_users` config when using delegated auth. ([\#18334](https://github.com/element-hq/synapse/issues/18334))
- Fix the token introspection cache logging access tokens when MAS integration is in use. ([\#18335](https://github.com/element-hq/synapse/issues/18335)) - Fix the token introspection cache logging access tokens when MAS integration is in use. ([\#18335](https://github.com/element-hq/synapse/issues/18335))
- Stop caching introspection failures when delegating auth to MAS. ([\#18339](https://github.com/element-hq/synapse/issues/18339)) - Stop caching introspection failures when delegating auth to MAS. ([\#18339](https://github.com/element-hq/synapse/issues/18339))
- Fix `ExternalIDReuse` exception after migrating to MAS on workers with a high traffic. ([\#18342](https://github.com/element-hq/synapse/issues/18342))
- Fix minor performance regression caused by tracking of room participation. Regressed in v1.128.0. ([\#18345](https://github.com/element-hq/synapse/issues/18345))
### Updates to the Docker image ### Updates to the Docker image

View File

@@ -763,16 +763,33 @@ class RegistrationWorkerStore(CacheInvalidationWorkerStore):
txn, self.get_user_by_external_id, (auth_provider, external_id) txn, self.get_user_by_external_id, (auth_provider, external_id)
) )
self.db_pool.simple_insert_txn( # This INSERT ... ON CONFLICT DO NOTHING statement will cause a
# 'could not serialize access due to concurrent update'
# if the row is added concurrently by another transaction.
# This is exactly what we want, as it makes the transaction get retried
# in a new snapshot where we can check for a genuine conflict.
was_inserted = self.db_pool.simple_upsert_txn(
txn, txn,
table="user_external_ids", table="user_external_ids",
values={ keyvalues={"auth_provider": auth_provider, "external_id": external_id},
"auth_provider": auth_provider, values={},
"external_id": external_id, insertion_values={"user_id": user_id},
"user_id": user_id,
},
) )
if not was_inserted:
existing_id = self.db_pool.simple_select_one_onecol_txn(
txn,
table="user_external_ids",
keyvalues={"auth_provider": auth_provider, "user_id": user_id},
retcol="external_id",
allow_none=True,
)
if existing_id != external_id:
raise ExternalIDReuseException(
f"{user_id!r} has external id {existing_id!r} for {auth_provider} but trying to add {external_id!r}"
)
async def remove_user_external_id( async def remove_user_external_id(
self, auth_provider: str, external_id: str, user_id: str self, auth_provider: str, external_id: str, user_id: str
) -> None: ) -> None:

View File

@@ -1622,14 +1622,11 @@ class RoomMemberWorkerStore(EventsWorkerStore, CacheInvalidationWorkerStore):
sql = """ sql = """
UPDATE room_memberships UPDATE room_memberships
SET participant = true SET participant = true
WHERE (user_id, room_id) IN ( WHERE event_id IN (
SELECT user_id, room_id SELECT event_id FROM local_current_membership
FROM room_memberships WHERE user_id = ? AND room_id = ?
WHERE user_id = ?
AND room_id = ?
ORDER BY event_stream_ordering DESC
LIMIT 1
) )
AND NOT participant
""" """
txn.execute(sql, (user_id, room_id)) txn.execute(sql, (user_id, room_id))
@@ -1651,11 +1648,10 @@ class RoomMemberWorkerStore(EventsWorkerStore, CacheInvalidationWorkerStore):
) -> bool: ) -> bool:
sql = """ sql = """
SELECT participant SELECT participant
FROM room_memberships FROM local_current_membership AS l
WHERE user_id = ? INNER JOIN room_memberships AS r USING (event_id)
AND room_id = ? WHERE l.user_id = ?
ORDER BY event_stream_ordering DESC AND l.room_id = ?
LIMIT 1
""" """
txn.execute(sql, (user_id, room_id)) txn.execute(sql, (user_id, room_id))
res = txn.fetchone() res = txn.fetchone()