I've a Batch class RecordsUpsertBatch whose job is to Process the Account's Child records. In some scenario I was hitting that batch twice/multiple times back-to-back for the same Account's child list and was getting the LOCK RECORD error. To over come this issue I've added the new method to check the transaction of RecordsUpsertBatch class and if the batch already has a Job I'm Scheduling the same batch with the help of a Scheduler class. This way my LOCK RECORD issue got resolved because my batch is in Queue for the next run.
In other scenario my Parent Accounts are different and so my Child list will be different too. This time batch will not throw the LOCK RECORD error because of the different child lists. But, when I'm hitting the same batch for other Account's Child list then also my batch is getting to the Queue because of the above Scheduler logic.
Need help here to Schedule the batch call for same Parent but Run it without Scheduler if the Parent Account are different.
Thanks in Advance, Ashu