Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different async action mapping approach #3678

Merged
merged 18 commits into from
Mar 18, 2021
Merged

Conversation

Twixes
Copy link
Member

@Twixes Twixes commented Mar 17, 2021

Changes

This makes async calculation of new action-event pairs every 30 seconds the new and default approach.

Benefits over the previous async approach:

  • enabled by default on Postgres whether plugin server ingesting or not
  • actually tested since it's the default
  • 30 seconds instead of the previous 5 minutes should make the user experience understandable (only a slight delay), while still being reasonably efficient (only calculating for events since last calculation)

Benefits over the previous on-the-fly approach:

  • most importantly compatible with plugins
  • doesn't require the plugin server additionally hammering Redis/Celery with webhook task dispatches, since that's also fired every 30 s
  • overall significantly less queries

In the future we may want to hand off action calculation to the plugin server (PostHog/plugin-server#235), but that will require a serious effort with exact porting of the matching logic, which we do not want to do now.

Closes #3627 (Marius's WIP PR). Resolves #3576.

Checklist

  • All querysets/queries filter by Organization, by Team, and by User
  • Django backend tests

@Twixes Twixes requested a review from macobo March 17, 2021 09:34
@Twixes Twixes changed the title Different async approach Different async action mapping approach Mar 17, 2021
@timgl timgl temporarily deployed to posthog-different-async-mbnsuo March 17, 2021 09:38 Inactive
@Twixes Twixes temporarily deployed to posthog-different-async-mbnsuo March 17, 2021 10:56 Inactive
@Twixes Twixes temporarily deployed to posthog-different-async-mbnsuo March 17, 2021 11:11 Inactive
@Twixes Twixes temporarily deployed to posthog-different-async-mbnsuo March 18, 2021 10:20 Inactive
Copy link
Contributor

@macobo macobo left a comment

Choose a reason for hiding this comment

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

LGTM other than the unresolved question on webhooks. Once that's resolved, feel free to merge. :)

@Twixes Twixes temporarily deployed to posthog-different-async-mbnsuo March 18, 2021 11:06 Inactive
@Twixes Twixes merged commit 3c571f1 into master Mar 18, 2021
@Twixes Twixes deleted the different-async-approach branch March 18, 2021 11:30
Twixes added a commit that referenced this pull request Mar 18, 2021
* Disable useless InsecureRequestWarning

* Disallow ASYNC_EVENT_ACTION_MAPPING on CH and make it default otherwise

* Return early from calculate_actions_from_last_calculation if CH

* Optimize Action.calculate_events and fire hooks from it

* Run calculate_event_action_mappings every 30 s instead of 5 min

* Optimize post_event_to_webhook thanks to new actions approach

* Add Event.site_url field for reworked Postgres webhooks

* Adjust tests by using sync calls to actions calculation

* Update calculate_action.py

* Use assertEntityResponseEqual more

* Update test_capture_new_person for Cloud

* Don't async calculate actions that haven't finished last calculation

* Fix is_calculating condition place

* Improve calculate_actions_from_last_calculation logging

* Clean up event_query, params

* Fix .only usage

* Update migration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Events stopped being added for an Action, whilst still working for identical duplicate Action
3 participants