Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix returned count of delete extremities admin API #12496

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12496.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where the admin API for [deleting forward extremities](https://github.com/matrix-org/synapse/blob/erikj/fix_delete_event_response_count/docs/admin_api/rooms.md#deleting-forward-extremities) would always return a count of 1 no matter how many extremities were deleted. Broke in v1.27.0.
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,23 @@ def delete_forward_extremities_for_room_txn(txn: LoggingTransaction) -> int:
"""

txn.execute(sql, (event_id, room_id))

deleted_count = txn.rowcount
logger.info(
"Deleted %s extra forward extremities for room %s",
txn.rowcount,
deleted_count,
room_id,
)

if txn.rowcount > 0:
if deleted_count > 0:
# Invalidate the cache
self._invalidate_cache_and_stream(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very hidden but this eventually makes another SELECT call, which changes txn.rowcount.

txn,
self.get_latest_event_ids_in_room,
(room_id,),
)

return txn.rowcount
return deleted_count

return await self.db_pool.runInteraction(
"delete_forward_extremities_for_room",
Expand Down