Skip to content

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

Merged
merged 5 commits into from
Jun 6, 2025

Conversation

guillaumejacquart
Copy link
Contributor

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

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Jun 3, 2025
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ckages/cli/src/modules/insights/insights.module.ts 50.00% 0 Missing and 1 partial ⚠️
...kages/cli/src/modules/insights/insights.service.ts 92.85% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@guillaumejacquart guillaumejacquart force-pushed the pay-2901-insights-on-webhook-instances branch from 742a1e6 to cf36bad Compare June 3, 2025 10:09
@guillaumejacquart guillaumejacquart marked this pull request as ready for review June 3, 2025 10:59
@guillaumejacquart guillaumejacquart requested a review from ivov June 3, 2025 10:59
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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.

@guillaumejacquart guillaumejacquart force-pushed the pay-2901-insights-on-webhook-instances branch 3 times, most recently from 34ac412 to d1b4786 Compare June 4, 2025 09:23
@guillaumejacquart guillaumejacquart requested a review from ivov June 4, 2025 09:23
Comment on lines 45 to 47
if (!this.instanceSettings.isLeader && this.instanceSettings.instanceType !== 'webhook') {
return;
}
Copy link
Contributor

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

Copy link
Contributor Author

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)

Copy link
Contributor

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.

Copy link
Contributor Author

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 !

Copy link
Contributor Author

@guillaumejacquart guillaumejacquart Jun 4, 2025

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

Copy link
Contributor Author

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

@guillaumejacquart guillaumejacquart requested a review from ivov June 4, 2025 13:58
@guillaumejacquart guillaumejacquart force-pushed the pay-2901-insights-on-webhook-instances branch from fc804c6 to d650fd2 Compare June 5, 2025 12:32
Copy link
Contributor

github-actions bot commented Jun 5, 2025

✅ All Cypress E2E specs passed

@guillaumejacquart guillaumejacquart merged commit 7a67dcb into master Jun 6, 2025
33 checks passed
@guillaumejacquart guillaumejacquart deleted the pay-2901-insights-on-webhook-instances branch June 6, 2025 07:45
@janober
Copy link
Member

janober commented Jun 11, 2025

Got released with [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants