问题描述
我正在考虑使用 apex 调度程序来运行批处理作业.我们可以随时运行它,比如凌晨 3 点,当流量低时,但我正在尝试预测一些哦-废话"场景.你们能帮我回答这些问题吗?
I'm looking into using apex scheduler to run a batch job. We can run it whenever we want, say 3 am when traffic is low, but I'm trying to anticipate some 'Oh-Crap' Scenarios. Can you guys help answer these questions for me?
设置:
当用户修改区域时,可以更新 10 万条记录.
When the user modifies a territory 100k's of records can get updated.
问题:
哪些情况可能会真正导致我的工作无法终止?我想到了一个场景 - 当用户正在编辑一个联系人时,该联系人恰好在其中一个正在运行的批次中.
What are some scenarios that can realistically cause my jobs to not terminate? I thought of a scenario of- when a user is editing a contact which happens to be in one of the batches is being run.
处理不会终止的作业有哪些好的做法?我正在考虑在此之后 2 小时安排另一批作业,但我不认为我的老板喜欢那样.我想过在 finish() 方法中做一些事情 - 但不知道究竟是什么.
What are some good practices for dealing with jobs that don't terminate? I was thinking about scheduling another batch job 2 hours after this one, but I don't see my boss liking that. I thought about maybe doing something in the finish() method- but don't know what exactly.
推荐答案
- 批次中的任何错误都会阻止该批次正确完成.
- 我建议您进行某种检查以了解您是否处理了所有内容.我通常用于批处理的是以某种方式标记需要处理的记录,以将它们与不需要处理的记录区分开来.当我处理完一个批次时,我将记录标记为已处理.然后您可以检查 finish() 方法是否仍有任何记录需要处理并重新安排批处理以再次运行.
这篇关于顶点调度程序 - 如果场景怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!