Skip to content

Transient cache not properly invalidated #523

Closed
@JUVOJustin

Description

@JUVOJustin

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

  1. Create a script emitting two jobs using https://actionscheduler.org/
  2. With step debugging enabled, trigger the first job which creates a "lock" transient
  3. Start the second job manually and check the return of the get_transient for the same transient name previously set in job 1
  4. Continue with job 1 until the transient is deleted, meaning the lock is released.
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions