-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Lock] Refine the contract and implementation for Stores to handle Not Expirable Store cases. #28727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
61aca8c
to
d8e4de3
Compare
d8e4de3
to
5a0cad2
Compare
a5b504b
to
07457f3
Compare
@jderusse - this is now ready for review. Also, I can't figure out why it's failing in this environment I have a feeling that it's reading files from |
7d89ad2
to
acea2b6
Compare
src/Symfony/Component/Lock/Tests/Store/ExpirableCombinedStoreTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Lock/Tests/Store/RetryTillSaveStoreTest.php
Outdated
Show resolved
Hide resolved
2de1da7
to
238958a
Compare
01b7fba
to
4ec842a
Compare
@@ -108,7 +109,7 @@ private function lock(Key $key, $blocking) | |||
*/ | |||
public function putOffExpiration(Key $key, $ttl) | |||
{ | |||
// do nothing, the flock locks forever. | |||
throw new NotExpirableStoreException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's should be treated like a BC break. ping @nicolas-grekas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a BC break to me, but might be worth doing anyway instead of silently ignoring the call.
ed9d45e
to
c110405
Compare
85e6204
to
3efcaa2
Compare
…xpiration of locks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me with two small comments. @jderusse I think we need your approval before merging.
@@ -108,7 +109,7 @@ private function lock(Key $key, $blocking) | |||
*/ | |||
public function putOffExpiration(Key $key, $ttl) | |||
{ | |||
// do nothing, the flock locks forever. | |||
throw new NotExpirableStoreException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a BC break to me, but might be worth doing anyway instead of silently ignoring the call.
@@ -46,7 +47,10 @@ public function getStore() | |||
self::markTestSkipped($e->getMessage()); | |||
} | |||
|
|||
return new CombinedStore(array(new RedisStore($redis)), new UnanimousStrategy()); | |||
$zookeeper_server = getenv('ZOOKEEPER_HOST').':2181'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo, should be $zookeeperServer
@@ -124,6 +125,8 @@ public function refresh($ttl = null) | |||
} | |||
|
|||
$this->logger->info('Expiration defined for "{resource}" lock for "{ttl}" seconds.', array('resource' => $this->key, 'ttl' => $ttl)); | |||
} catch (NotExpirableStoreException $e) { | |||
$this->logger->notice('The store does not support expiration of locks.', array('store' => $this->store)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method refresh
is called internally when calling acquire
with a non-null TTL (which is the default case when using the Factory with default arguments)
When using a NotExpirableStore (like flock) the logger will be full of notice.
Same comment when combining a non-expirable store and expirable one (flock + redis for instance)
IMHO You should either silent this exception when calling acquire
or update the factory to set a null TTL when the store does not support expiration.
Would be great from a user point of view to known whether or not the store supports expiration.
interface StoreInterface {
public function save(Key $key);
public function waitAndSave(Key $key);
public function delete(Key $key);
public function exists(Key $key);
}
interface ExpirableStoreInterface extends StoreInterface {
public function supportsExpiration(): bool
public function putOffExpiration(Key $key, $ttl);
}
The Stores contract and implementation doesn't clearly distinguish between stores that support expirable stores and ones which don't. This change attempts to improve that for better usage of the functions by the services without running into runtime issues.