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

Faster joins: fix race where we can fail to persist an incoming event with partial state after _sync_partial_state_room clears the partial state flag for a room #12988

Closed
@squahtx

Description

@squahtx

logger.info("Clearing partial-state flag for %s", room_id)
success = await self.store.clear_partial_state_room(room_id)
if success:
logger.info("State resync complete for %s", room_id)
self._storage_controllers.state.notify_room_un_partial_stated(
room_id
)
# TODO(faster_joins) update room stats and user directory?
return
# we raced against more events arriving with partial state. Go round
# the loop again. We've already logged a warning, so no need for more.
# TODO(faster_joins): there is still a race here, whereby incoming events which raced
# with us will fail to be persisted after the call to `clear_partial_state_room` due to
# having partial state.
continue

When we are processing an incoming event while _sync_partial_state_room is running, _sync_partial_state_room may clear the partial state flag for the room before we try to persist the event with a partial state flag. This leads to a foreign key constraint failure because there's no longer a partial_state_room entry for the room.

See #12394 (comment) for an example.

Metadata

Metadata

Assignees

Labels

A-Federated-Joinjoins over federation generally suckT-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions