diff --git a/changelog.d/7548.bugfix b/changelog.d/7548.bugfix
new file mode 100644
index 0000000000000000000000000000000000000000..1233b3b31a12a1da5b5dddf4af4ff0036705764e
--- /dev/null
+++ b/changelog.d/7548.bugfix
@@ -0,0 +1 @@
+Fix bug where a local user leaving a room could fail under rare circumstances.
diff --git a/synapse/storage/persist_events.py b/synapse/storage/persist_events.py
index 41881ea20b250c5fdf59898b596fb0f6a687fe45..12e1ffb9a2f26d1dc1252c200a42cddc6247a563 100644
--- a/synapse/storage/persist_events.py
+++ b/synapse/storage/persist_events.py
@@ -740,8 +740,8 @@ class EventsPersistenceStorage(object):
         # whose state has changed as we've already their new state above.
         users_to_ignore = [
             state_key
-            for _, state_key in itertools.chain(delta.to_insert, delta.to_delete)
-            if self.is_mine_id(state_key)
+            for typ, state_key in itertools.chain(delta.to_insert, delta.to_delete)
+            if typ == EventTypes.Member and self.is_mine_id(state_key)
         ]
 
         if await self.main_store.is_local_host_in_room_ignoring_users(