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

Make purge_history operate on tokens #3221

Merged
merged 5 commits into from
May 18, 2018
Merged

Conversation

erikjohnston
Copy link
Member

No description provided.

As we're soon going to change how topological_ordering works
@@ -1856,6 +1855,8 @@ def _purge_history_txn(
# furthermore, we might already have the table from a previous (failed)
# purge attempt, so let's drop the table first.

token = RoomStreamToken.parse(token)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you put this somewhere that isn't between the "let's build a temporary table" comment and the building of said temp table?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also use different names for the stringy token and the tokeny token?

@@ -1871,6 +1872,10 @@ def _purge_history_txn(
"CREATE INDEX events_to_purge_should_delete"
" ON events_to_purge(should_delete)",
)
txn.execute(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth commenting on why we need this index

@@ -1927,9 +1932,8 @@ def _purge_history_txn(
txn.execute(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment on this doesn't really seem to be true any more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How so?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# We calculate the new entries for the backward extremeties by finding
# all events that point to events that are to be purged

we now look for events we are about to purge, which point to events we are not going to purge. it's completely different.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, its different in terms that we're not returning the event that points to purged events but the purged events that we get pointed at, yes. (And this isn't anything to do with the change in the sql, and was wrong before)

SELECT COALESCE(MIN(depth), 0)
FROM event_backward_extremities AS eb
INNER JOIN event_edges AS eg ON eg.prev_event_id = eb.event_id
INNER JOIN events AS e ON e.event_id = eg.event_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this looking for the prev_event before the extremity? which we have likely just purged?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking at the events that point to the extremity, as we don't actually have the extremity events.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(And I think the check is the right way round?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right. ehm. I'm not convinced this is going to calculate the right thing in the presence of disconnected bits of dag.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each disconnected part of the DAG will have their backwards extremities in the event_backward_extremities table, so the event with the minimum depth must be one of them, no?

@erikjohnston erikjohnston merged commit fa30ac3 into develop May 18, 2018
@erikjohnston erikjohnston deleted the erikj/purge_token branch September 20, 2018 13:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants