Here we only allow once instance of the autorenewal job to run at any given time, given the renewal might happen more than one time for the same membership if the autorenewal happen to run multiple times simultaneously.
Before
Multiple instances of the autorenewal job could run at the same time, which might cause the same membership to be renewed multiple times.
After
Only once instance of the autorenewal job can run at any given time:
An error saying:
Could not acquire lock, another Offline Autorenewal process is running
would show in the job logs for any other instance tries to run while there is a one t hat is already running.
Technical Details
I've used CiviCRM lock manager Civi::lockManager() to acquire a lock on the first instance that runs, and that lock is only released when job is done running.
Overview
Here we only allow once instance of the autorenewal job to run at any given time, given the renewal might happen more than one time for the same membership if the autorenewal happen to run multiple times simultaneously.
Before
Multiple instances of the autorenewal job could run at the same time, which might cause the same membership to be renewed multiple times.
After
Only once instance of the autorenewal job can run at any given time:
An error saying:
would show in the job logs for any other instance tries to run while there is a one t hat is already running.
Technical Details
I've used CiviCRM lock manager
Civi::lockManager()
to acquire a lock on the first instance that runs, and that lock is only released when job is done running.