-
Notifications
You must be signed in to change notification settings - Fork 33.7k
fix(core): Start insights collection timer for webhook instances #15964
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(core): Start insights collection timer for webhook instances #15964
Conversation
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
742a1e6
to
cf36bad
Compare
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.
cubic found 1 issue across 4 files. Review it in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai
to give specific feedback.
packages/cli/src/modules/insights/__tests__/insights.module.test.ts
Outdated
Show resolved
Hide resolved
34ac412
to
d1b4786
Compare
if (!this.instanceSettings.isLeader && this.instanceSettings.instanceType !== 'webhook') { | ||
return; | ||
} |
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.
Won't this check incorrectly exclude a follower from flushing? As far as I understand, we want:
- leader flushes, compacts, prunes
- follower flushes
- webhook flushes
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.
So for now, we don't want followers to flush.
We want the instance that gets the workflow execution hooks triggered to buffer and flush, which means (unless I'm wrong):
- the main leader instance
- the webhook instance, as we've realized recently that webhook instance are the only instance receiving the hook (when workflow is triggered by a webhook)
I'm not sure follower instance also get the workflowExecuteAfter hook ran, but I hope note, otherwise we would get duplicated insights, because they would be saved when the buffer is full (even if the flushing timer is not running)
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.
I'm not sure follower instance also get the workflowExecuteAfter hook ran, but I hope not
Can we verify this please? I'd expect followers enqueue just like leaders and webhook instances do.
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.
Yes definitely, I'm doing that now !
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.
@ivov So I checked and you are right, followers can have the workflowExecuteAfter fired, in those cases:
- if they received the HTTP trigger of the workflow (from the load balancer)
- if they trigger the execution themselves (like manual executions) - although we don't save manual execs for insights
So I think you were right that followers need to buffer / flush as well, because all workflow execution will be scheduled / run by either:
- the main leader
- one of the followers
- the webhook instance
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.
@ivov I've implemented and tested the insights collection flushing for followers. All good when manually testing
fc804c6
to
d650fd2
Compare
✅ All Cypress E2E specs passed |
Got released with |
Summary
Before this PR, insights module did not start the collection flushing timer for webhook instances, meaning executions would only be saved when the buffer is full, instead of also every X seconds - 30 by default.
This PR starts the flushing timer for webhook instances as well, and split the timers starting between collection and the others (compaction and pruning) that are done in the main instances
Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/PAY-2901/insights-on-webhook-instances
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)