Update BBM Best practices Docs
requested to merge 403073-rescuing-exceptions-inside-bbm-job-class-causing-job-to-not-fail-properly into master
What does this MR do and why?
Describe in detail what your merge request does and why.
Solves:
-
Update our BBM docs best practices section: Include some information about job classes not to rescue exceptions that happen during the job/batch execution.
Update docs best practices to:
Best practices
- Know how much data you're dealing with.
- Make sure the batched background migration jobs are idempotent.
- Confirm the tests you write are not false positives.
- If the data being migrated is critical and cannot be lost, the clean-up migration must also check the final state of the data before completing.
- Discuss the numbers with a database specialist. The migration may add more pressure on DB than you expect. Measure on staging, or ask someone to measure on production.
- Know how much time is required to run the batched background migration.
- Do not silently rescue exceptions inside job classes.
# good
def perform
each_sub_batch do |sub_batch|
sub_batch.update_all(name: 'My Name')
end
end
# acceptable
def perform
each_sub_batch do |sub_batch|
sub_batch.update_all(name: 'My Name')
rescue Exception => error
logger.error(message: error.message, class: self.class.name)
raise
end
end
# bad
def perform
each_sub_batch do |sub_batch|
sub_batch.update_all(name: 'My Name')
rescue Exception => error
logger.error(message: error.message, class: self.class.name)
end
end
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #403073 (closed)
Edited by Leonardo da Rosa