You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to documentation, implementing ShouldBeUnique on job class is enough to ensure only one instance of given job is present in the queue. However, using dynamodb cache driver without setting $uniqueFor explicitly makes the lock item expire after 1 second, because expires_at is set to current timestamp when $uniqueFor is 0 (default value).
This is the change event in DynamoDB table after putItem request when trying to acquire job lock:
expires_at is equal to current timestamp (see ApproximateCreationDateTime), so trying to acquire the lock in the following second will work because of used condition:
'ConditionExpression' => 'attribute_not_exists(#key) OR #expires_at < :now',
It seems like the behavior is not consistent across other cache providers, e.g. database cache provider uses lock expiration time of 1 day if no time was provided:
Description:
According to documentation, implementing ShouldBeUnique on job class is enough to ensure only one instance of given job is present in the queue. However, using
dynamodb
cache driver without setting$uniqueFor
explicitly makes the lock item expire after 1 second, becauseexpires_at
is set to current timestamp when$uniqueFor
is 0 (default value).This is the change event in DynamoDB table after
putItem
request when trying to acquire job lock:expires_at
is equal to current timestamp (seeApproximateCreationDateTime
), so trying to acquire the lock in the following second will work because of used condition:framework/src/Illuminate/Cache/DynamoDbStore.php
Line 273 in d425952
It seems like the behavior is not consistent across other cache providers, e.g.
database
cache provider uses lock expiration time of 1 day if no time was provided:framework/src/Illuminate/Cache/DatabaseLock.php
Lines 92 to 95 in d425952
redis
provider creates non-expiring item:framework/src/Illuminate/Cache/RedisLock.php
Lines 35 to 42 in d425952
memcached
items doesn't expire with expiration time set to 0.While
dynamodb
items expire in the next second after the lock is acquired.Possible solution would be to use 1 day as default expiration value, as in
database
cache provider case.Steps To Reproduce:
dynamodb
cache providerShouldBeUnique
that takes longer than a few seconds to completeShouldBeUnique
Repository demonstrating the issue: https://github.com/Wowu/laravel-dynamodb-bug-report
The text was updated successfully, but these errors were encountered: