question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The last member of a room cannot `/forget` it after leaving

See original GitHub issue

Description

If you call POST /_matrix/client/v3/rooms/{roomId}/forget the user does not forget the room. This only seems to occur when the user was the last member.

Steps to reproduce

  • leave a room
  • try to forget the room via /forget or webclient
  • get http 200 and nothing happens
  • there are no changes in db table room_memberships

If you run Synapse in SQL debug mode you can see the db runs synapse.storage.txn - 691 - DEBUG - POST-148 - [TXN START] {get_filtered_current_state_ids-3c6} but no forget_membership txn.

https://github.com/matrix-org/synapse/blob/e825f7366b589f61977f63d4fdc598abe052e6a0/synapse/handlers/room_member.py#L1912-L1927

https://github.com/matrix-org/synapse/blob/e825f7366b589f61977f63d4fdc598abe052e6a0/synapse/storage/databases/main/roommember.py#L1478-L1499

I have added two lines for debugging in room_member.py

        logger.info("add info: %s", (membership,))
        logger.info("add info: %s", (member,))
  • If you are member of the room, member is a FrozenEventV3 and membership join. Synapse raises http 400. 😄
  • If you have left the room, member and membership is None. Nothing happens, only http 200 😢
    • If the user was the last member of the room
  • If the user was not the last member, member is a FrozenEventV3 and membership leave

Homeserver

another homeserver

Synapse Version

Synapse/1.65.0rc1

Installation Method

Debian packages from packages.matrix.org

Platform

vm: Ubuntu 20.04.4 LTS

Relevant log output

see above

Anything else that would be useful to know?

Discovered while working on https://github.com/matrix-org/synapse/pull/13503#discussion_r944192792

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
H-Shaycommented, Aug 16, 2022

This is reproducible-I wrote a unit test to reproduce this, and did some debugging. I suspect that after the last member leaves the room, the background update _background_remove_left_rooms is deleting rows related to this room from the table current_state_events. Thus when the /forget request executes this line:

member = await self._storage_controllers.state.get_current_state_event(
            room_id=room_id, event_type=EventTypes.Member, state_key=user_id
        )

the return value for get_current_state_events is None, as the table current_state_events now has no rows related to the room. I did verify that after the last member leaves the room, get_current_state_events no longer retains any rows from this room.

1reaction
H-Shaycommented, Aug 16, 2022

I didn’t create a PR, it was just some hacky code to try and reproduce the situation. If it’s helpful, here it is:

    def test_leave_and_forget(self):
        self.helper.join(self.room_id, user=self.second_user_id, tok=self.second_tok)
        self.helper.leave(self.room_id, user=self.creator, tok=self.creator_tok)
        self.helper.leave(self.room_id, user=self.second_user_id, tok=self.second_tok)

        channel = self.make_request(
            "POST",
            f"/_matrix/client/v3/rooms/{self.room_id}/forget",
            access_token=self.second_tok,
        )

        self.assertEqual(channel.code, HTTPStatus.OK, channel.result)
        self.assertEqual(self.get_success(
            self.hs.get_datastores().main.did_forget(self.second_user_id, self.room_id)), True)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory Lapse or Dementia? 5 Clues to Help Tell the Difference
What's not: “Driving or walking for a long time without realizing you're lost or completely forgetting where you are, and not asking for...
Read more >
It's not just doorways that make us forget what we came for in ...
Astoundingly, these studies show doorways cause forgetting, and this effect is so consistent it has come to be known as the “doorway effect”....
Read more >
Why You Keep Forgetting Why You Entered a Room - VICE
The term was coined after a 2011 study by researchers at the University of Notre Dame, who found that people tend to forget...
Read more >
When to be Concerned About Forgetfulness - Geisinger
It's common to forget things now and then, but here's how to know when to call your doctor. You were rushing to leave...
Read more >
Forgot Why You Walked Into a Room? Tips for Brain Blips
Many of us misplace objects, forget why we walked into a room, or forget the name of someone we just met. Although such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found