Skip to content

unlockActivity in WithoutOverlappingMiddleware not using expiresAfter property #327

@janwehner

Description

@janwehner

Hi,

is there a reason that the unlockActivity method in the WithoutOverlappingMiddleware class does not take the $expiresAfter property into account when setting the value for the activity semaphore key?

The compareAndSet method is setting a TTL when passed:

if ($expiresAfter) {
    $this->cache->put($key, $newValue, $expiresAfter);
} else {
    $this->cache->put($key, $newValue);
}

The lock method is calling compareAndSet for the activity semaphore key in line 112 and passing the class property $expiresAfter to it. But when the unlockActivity method is running it will override the activity semaphore key in line 180 without a TTL:

$this->cache->put($this->getActivitySemaphoreKey(), $remaining);

I think this does result in many non-expiring keys in the Redis DB. Since I started testing my workflows in an staging environment the non-expiring keys in the Redis DB grew from 10000 to over 1 million. Nearly all keys are of the activity semaphore type laravel-workflow-overlap:{WORKFLOW_ID}:activity with a value of "a:0:{}".

Would it be possible to use the $expiresAfter property there too or maybe use a fixed and longer TTL?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions