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

Ensure all push actions are deleted from staging #2894

Merged
merged 5 commits into from
Feb 26, 2018

Conversation

erikjohnston
Copy link
Member

Sometimes we get events multiple times over federation, and we end up calculating and inserting the push rules for these events into the staging area. This PR ensures that all events that were going to be persisted have their staging push actions cleared.

Note: This includes a refactor as the first commit.

@@ -1162,16 +1162,17 @@ def _update_metadata_tables_txn(self, txn, events_and_contexts, backfilled):
backfilled (bool): True if the events were backfilled
"""

# Insert all the push actions into the event_push_actions table.
Copy link
Member

Choose a reason for hiding this comment

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

stick this after lines 1171-1173?

Copy link
Member Author

Choose a reason for hiding this comment

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

We want to ensure that it always gets run, so that it clears up the staging area with all events.

Copy link
Member

Choose a reason for hiding this comment

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

right, but if events_and_contexts is falsy, then this is a no-op, so you might as well move it down?

Copy link
Member Author

Choose a reason for hiding this comment

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

Its not a noop if all_events_and_contexts isn't empty.

Copy link
Member

@richvdh richvdh Feb 26, 2018

Choose a reason for hiding this comment

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

right, but it is if it is, which is what we're talking about here.

I feel like we must be at cross-purposes here, so let me clarify. I am suggesting changing:

        self._set_push_actions_for_event_and_users_txn(...)

        if not events_and_contexts:
            return

to:

        if not events_and_contexts:
            return

        self._set_push_actions_for_event_and_users_txn(...)

(which, incidentally, also resolves the discussion below)

Copy link
Member

Choose a reason for hiding this comment

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

oh ffs I was reviewing a previous commit and not realising that all_events_and_contexts was added later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, oops. Yay go github

},
retcol="user_id",
)
if events_and_contexts:
Copy link
Member

Choose a reason for hiding this comment

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

why do we do this check?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not 100% convinced that we events_and_contexts can't be empty, given the number of times we filter it down. The rest of the code should be fine with it being empty.

Copy link
Member

Choose a reason for hiding this comment

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

and why is this code not ok with it being empty?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it is? But there isn't any documentation that executemany is fine with empty lists and its the sort of thing I can imagine it complaining about.

tuples: list of tuples of (user_id, actions)
events_and_contexts (list[(EventBase, EventContext)]): events
we are persisting
all_events_and_contexts (list[(EventBase, EventContext)]): all
Copy link
Member

Choose a reason for hiding this comment

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

it's a lovely parameter, but it doesn't seem to do much.

Copy link
Member Author

Choose a reason for hiding this comment

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

Woops.

@richvdh richvdh assigned erikjohnston and unassigned richvdh Feb 20, 2018
@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Feb 21, 2018
@richvdh richvdh assigned erikjohnston and unassigned richvdh Feb 22, 2018
@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Feb 26, 2018
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

ok sorry for being a bit cranky

@erikjohnston erikjohnston merged commit 73fe866 into develop Feb 26, 2018
@erikjohnston erikjohnston deleted the erikj/handle_unpersisted_events_push branch March 5, 2018 15:56
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