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

KeyError on recent background updates #16054

Open
Fizzadar opened this issue Aug 2, 2023 · 4 comments
Open

KeyError on recent background updates #16054

Fizzadar opened this issue Aug 2, 2023 · 4 comments
Labels
A-Database DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the db O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. X-Regression Something broke which worked on a previous release

Comments

@Fizzadar
Copy link
Contributor

Fizzadar commented Aug 2, 2023

Description

We're seeing a KeyError on the recent updates introduced by 11e15d7:

KeyError: 'current_state_events_stream_ordering_idx'
  File "synapse/storage/background_updates.py", line 405, in run_background_updates
    result = await self.do_next_background_update(sleep)
  File "synapse/storage/background_updates.py", line 528, in do_next_background_update
    update_info = self._background_update_handlers[self._current_background_update]

Specifically appears to be missing in BackgroundUpdates._background_update_handlers, but adding some logging indicates it is being registered as a background update:

{"message":"Registering background index update: current_state_events_stream_ordering_idx","namespace":"synapse.storage.background_updates","level":"info","time":1690998470.67,"request":"main","server_name":"beeper.com"}
{"message":"Error doing update","namespace":"synapse.storage.background_updates","level":"error","time":1690998470.9,"request":"background_updates-0","server_name":"beeper.com","exc_type":"KeyError","exc_value":"'current_state_events_stream_ordering_idx'"}
{"message":"Error doing update","namespace":"synapse.storage.background_updates","level":"error","time":1690998470.97,"request":"background_updates-0","server_name":"beeper.com","exc_type":"KeyError","exc_value":"'current_state_events_stream_ordering_idx'"}
{"message":"Error doing update","namespace":"synapse.storage.background_updates","level":"error","time":1690998470.97,"request":"background_updates-0","server_name":"beeper.com","exc_type":"KeyError","exc_value":"'current_state_events_stream_ordering_idx'"}
{"message":"Error doing update","namespace":"synapse.storage.background_updates","level":"error","time":1690998470.98,"request":"background_updates-0","server_name":"beeper.com","exc_type":"KeyError","exc_value":"'current_state_events_stream_ordering_idx'"}

If I run locally with sqlite there is no error, but I can't see any codepath that would change the behaviour for postgres 🤔

@Fizzadar
Copy link
Contributor Author

Fizzadar commented Aug 2, 2023

Just checked - applies to all three of those updates only - the following update, event_forward_extremities_event_id_foreign_key_constraint_update, ran just fine after I manually created the indices and removed the update from the table.

@clokep
Copy link
Member

clokep commented Aug 2, 2023

Are you running the script to execute schema deltas while having a Synapse running? If the running Synapse doesn't yet have the new code which registers the background updates then you can hit this.

@Fizzadar
Copy link
Contributor Author

Fizzadar commented Aug 2, 2023

No this is running v1.88, this is on the main process running a background job so the schema changes are applied already. Stumped on how this could be a KeyError given the logging indicating it registering as expected..

@reivilibre
Copy link
Contributor

Are you running a split main and state database by any chance? Just a hunch, but could be that the background update is registered on the wrong database — there would be two different background updaters in that case.

@DMRobertson DMRobertson added S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. X-Regression Something broke which worked on a previous release A-Database DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the db O-Uncommon Most users are unlikely to come across this or unexpected workflow labels Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Database DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the db O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. X-Regression Something broke which worked on a previous release
Projects
None yet
Development

No branches or pull requests

4 participants