Description
Through two async requests, the transient cache is not properly invalidated
Description
I have two async jobs utilizing mutual locking by transient. This means each job trys to achieve a lock by setting a transient. Once finished, the "lock" transient is deleted. When the second job arrives in parallel, it waits till the lock is released. The problem now is that even when job 1 releases the lock by deleting the transient, the get_transient function of job 2 sill returns the old "lock" status.
Expected Behavior
After deleting the "lock" transient in job 1 a get_transient call in job 2 should return false.
Actual Behavior
After deleting the "lock" transient in job 1 a get_transient call in job 2 returns "1" which is the value representing the "lock" status.
Steps to Reproduce
- Create a script emitting two jobs using https://actionscheduler.org/
- With step debugging enabled, trigger the first job which creates a "lock" transient
- Start the second job manually and check the return of the get_transient for the same transient name previously set in job 1
- Continue with job 1 until the transient is deleted, meaning the lock is released.
- Check the return of get_transeint in job 2. Should return "false" will return "1"
Additional context
I am importing a lot of data using action-scheduler jobs. Each processed post_id is stored in a transient. To avoid race conditions, i integrated mutual locking using a transient. If a job is locked the running job will wait 1 second and try again.
Environment
- Plugin version: 2.5.2
- PHP version: 8.1
- WordPress version: 6.5.3