-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix AssertionErrors after purging events #11642
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a long-standing bug which could cause `AssertionError`s to be written to the log when Synapse was restarted after purging events from the database. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a long-standing bug which could cause `AssertionError`s to be written to the log when Synapse was restarted after purging events from the database. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,8 +42,8 @@ echo "--------------------------" | |
echo | ||
|
||
matched=0 | ||
for f in $(git diff --name-only FETCH_HEAD... -- changelog.d); do | ||
# check that any modified newsfiles on this branch end with a full stop. | ||
for f in $(git diff --diff-filter=d --name-only FETCH_HEAD... -- changelog.d); do | ||
# check that any added newsfiles on this branch end with a full stop. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is added or modified, but not deleted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203 for docs on this btw. |
||
lastchar=$(tr -d '\n' < "$f" | tail -c 1) | ||
if [ "$lastchar" != '.' ] && [ "$lastchar" != '!' ]; then | ||
echo -e "\e[31mERROR: newsfragment $f does not end with a '.' or '!'\e[39m" >&2 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,17 @@ async def _unsafe_process(self) -> None: | |
# If self.pos is None then means we haven't fetched it from DB | ||
if self.pos is None: | ||
self.pos = await self.store.get_stats_positions() | ||
room_max_stream_ordering = self.store.get_room_max_stream_ordering() | ||
if self.pos > room_max_stream_ordering: | ||
# apparently, we've processed more events than exist in the database! | ||
# this can happen if events are removed with history purge or similar. | ||
logger.warning( | ||
"Event stream ordering appears to have gone backwards (%i -> %i): " | ||
"rewinding stats processor", | ||
self.pos, | ||
room_max_stream_ordering, | ||
) | ||
self.pos = room_max_stream_ordering | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm having trouble convincing myself this is a "safe" operation to do. I thought the max stream ordering was monotonically increasing, even if you purged events but I might be misunderstanding how it is used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, that's a fair question. The fact is that currently, on sqlite, we do reuse stream orderings, because we have no way of knowing which stream orderings were used before synapse was restarted. For things like the stats and userdirectory, that's not really a problem, because any events that get a stream ordering later than the max at startup must be new events, so I think this must be safe. One place it is a problem is in client /sync - since stream_orderings are encoded in sync tokens, any events that reuse old stream_orderings probably won't get synced to the client. Ironically, we don't log any warnings in that case. So, sure, a better solution here is not to reuse stream orderings at all, but that's not easy. Meanwhile I think we may as well update these bits to stop them complaining. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the thorough explanation! The issue with |
||
|
||
# Loop round handling deltas until we're up to date | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--diff-filter=d
tells git to ignore deleted files here. This should probably be a separate PR but at this stage I've got about 15 of the things open :-S