async def METHOD_NAME(self, room_id: str) -> int:
    """Delete any extra forward extremities for a room.
    Invalidates the "get_latest_event_ids_in_room" cache if any forward
    extremities were deleted.
    Returns count deleted.
    """
    def delete_forward_extremities_for_room_txn(txn: LoggingTransaction) -> int:
        # First we need to get the event_id to not delete
        sql = """
            SELECT event_id FROM event_forward_extremities
            INNER JOIN events USING (room_id, event_id)
            WHERE room_id = ?
            ORDER BY stream_ordering DESC
            LIMIT 1
        """
        txn.execute(sql, (room_id,))
        rows = txn.fetchall()
        try:
            event_id = rows[0][0]
            logger.debug(
                "Found event_id %s as the forward extremity to keep for room %s",
                event_id,
                room_id,
            )
        except KeyError:
            msg = "No forward extremity event found for room %s" % room_id
            logger.warning(msg)
            raise SynapseError(400, msg)
        # Now delete the extra forward extremities
        sql = """
            DELETE FROM event_forward_extremities
            WHERE event_id != ? AND room_id = ?
        """
        txn.execute(sql, (event_id, room_id))
        deleted_count = txn.rowcount
        logger.info(
            "Deleted %s extra forward extremities for room %s",
            deleted_count,
            room_id,
        )
        if deleted_count > 0:
            # Invalidate the cache
            self._invalidate_cache_and_stream(
                txn,
                self.get_latest_event_ids_in_room,
                (room_id,),
            )
        return deleted_count
    return await self.db_pool.runInteraction(
        "delete_forward_extremities_for_room",
        delete_forward_extremities_for_room_txn,
    )