-
Notifications
You must be signed in to change notification settings - Fork 126
fix(billable_metric): Destroy when attached to a lot of charges #3747
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8313023
to
9ace42b
Compare
rsempe
approved these changes
May 30, 2025
vincent-pochet
added a commit
that referenced
this pull request
Jun 2, 2025
## Context This PR follows #3747 Deleting a charge in a plan with a large number of override can cause Timeout error or lead to a memory error on Redis. The main reasons are: - The service will enqueue one job per child charge - In the service, the soft deletion is done using `discard_all` witch is not scalable as it is using a DB call per record... ## Description This PR is refactoring the logic to enqueue only one job responsible of the soft deletion of all child charges. The filter deletion is also done by replacing `discard_all` calls with `update_all(deleted_at:)` Note: The same logic will have to be applied to both update and creation of child charges
vincent-pochet
added a commit
that referenced
this pull request
Jun 2, 2025
## Context This PR follows #3747 and #3765 Create a new charge in a plan with a large number of override can cause Timeout error or lead to a memory error on Redis. The main reasons is that the service will enqueue one job per child plan ## Description This PR is refactoring the logic to enqueue only one job responsible of the creation of all child charges. Note: The same logic will have to be applied to the update of child charges
diegocharles
pushed a commit
that referenced
this pull request
Jun 2, 2025
## Context Deleting a billable metric attached to a lot of charges and filters may lead to a Timeout error because: - The soft deletion of sub-resources is done synchronously - It is using `discard_all` witch is not scalable as it is using a DB call per record... ## Description This PR is moving the filter deletion to a dedicated job and is replacing `discard_all` calls with `update_all(deleted_at:)`
diegocharles
pushed a commit
that referenced
this pull request
Jun 2, 2025
## Context This PR follows #3747 Deleting a charge in a plan with a large number of override can cause Timeout error or lead to a memory error on Redis. The main reasons are: - The service will enqueue one job per child charge - In the service, the soft deletion is done using `discard_all` witch is not scalable as it is using a DB call per record... ## Description This PR is refactoring the logic to enqueue only one job responsible of the soft deletion of all child charges. The filter deletion is also done by replacing `discard_all` calls with `update_all(deleted_at:)` Note: The same logic will have to be applied to both update and creation of child charges
diegocharles
pushed a commit
that referenced
this pull request
Jun 2, 2025
## Context This PR follows #3747 and #3765 Create a new charge in a plan with a large number of override can cause Timeout error or lead to a memory error on Redis. The main reasons is that the service will enqueue one job per child plan ## Description This PR is refactoring the logic to enqueue only one job responsible of the creation of all child charges. Note: The same logic will have to be applied to the update of child charges
lovrocolic
added a commit
that referenced
this pull request
Jun 9, 2025
## Context This PR follows: - #3747 - #3765 - #3767 Updating a charge in a plan with a large number of override can cause Timeout error or lead to a memory error on Redis. The main reason is: - The service will enqueue one job per child charge ## Description This PR is refactoring the logic to enqueue only one job responsible of the updates for all child charges.
This was referenced Aug 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Deleting a billable metric attached to a lot of charges and filters may lead to a Timeout error because:
discard_all
witch is not scalable as it is using a DB call per record...Description
This PR is moving the filter deletion to a dedicated job and is replacing
discard_all
calls withupdate_all(deleted_at:)