-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix cohorts stuck on empty querysets #2441
Conversation
posthog/tasks/calculate_cohort.py
Outdated
Q(is_calculating=False) | Q(last_calculation__lte=timezone.now() - relativedelta(minutes=max_age_minutes)) | ||
).order_by("id"): | ||
Q(is_calculating=False) | Q(last_calculation__lte=timezone.now() - relativedelta(minutes=MAX_AGE_MINUTES)) | ||
).order_by("last_calculation")[0:15]: |
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.
Let's extract const: PARALLEL_COHORTS
.
posthog/tasks/calculate_cohort.py
Outdated
Q(is_calculating=False) | Q(last_calculation__lte=timezone.now() - relativedelta(minutes=max_age_minutes)) | ||
).order_by("id"): | ||
Q(is_calculating=False) | Q(last_calculation__lte=timezone.now() - relativedelta(minutes=MAX_AGE_MINUTES)) | ||
).order_by("last_calculation")[0:15]: |
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.
Does .order_by put nulls first or last? If last some cohorts may never be processed.
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.
Good question. By default I think yes, but I've made it super explicit now
🥳 |
Changes
Checklist