Skip to content

[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

GaneshChandrasekaran-zz
Copy link
Contributor

@GaneshChandrasekaran-zz GaneshChandrasekaran-zz commented Oct 4, 2018

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.

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #28696
License MIT
Doc PR n/a

@GaneshChandrasekaran-zz GaneshChandrasekaran-zz force-pushed the gchandrasekaran_fixPutOffExpirationForZookeeperStore branch 2 times, most recently from 61aca8c to d8e4de3 Compare October 4, 2018 15:02
@GaneshChandrasekaran-zz GaneshChandrasekaran-zz force-pushed the gchandrasekaran_fixPutOffExpirationForZookeeperStore branch from d8e4de3 to 5a0cad2 Compare October 4, 2018 15:11
@GaneshChandrasekaran-zz GaneshChandrasekaran-zz force-pushed the gchandrasekaran_fixPutOffExpirationForZookeeperStore branch 3 times, most recently from a5b504b to 07457f3 Compare October 4, 2018 16:45
@GaneshChandrasekaran-zz GaneshChandrasekaran-zz changed the title WIP: Create new NotExpirableStoreException for stores which don't support … Create new NotExpirableStoreException for stores which don't support expiration of locks Oct 4, 2018
@GaneshChandrasekaran-zz
Copy link
Contributor Author

GaneshChandrasekaran-zz commented Oct 4, 2018

@jderusse - this is now ready for review.

Also, I can't figure out why it's failing in this environment
https://travis-ci.org/symfony/symfony/jobs/437228068

I have a feeling that it's reading files from vendor directory but I am unable to confirm that from the stack trace.

@GaneshChandrasekaran-zz GaneshChandrasekaran-zz force-pushed the gchandrasekaran_fixPutOffExpirationForZookeeperStore branch 2 times, most recently from 7d89ad2 to acea2b6 Compare October 8, 2018 12:34
@GaneshChandrasekaran-zz GaneshChandrasekaran-zz changed the title Create new NotExpirableStoreException for stores which don't support expiration of locks Refine the contract and implementation for Stores. Oct 8, 2018
@GaneshChandrasekaran-zz GaneshChandrasekaran-zz force-pushed the gchandrasekaran_fixPutOffExpirationForZookeeperStore branch from 2de1da7 to 238958a Compare October 14, 2018 12:45
@GaneshChandrasekaran-zz GaneshChandrasekaran-zz changed the title Refine the contract and implementation for Stores. Refine the contract and implementation for Stores to handle Not Expirable Store cases. Oct 14, 2018
@GaneshChandrasekaran-zz GaneshChandrasekaran-zz force-pushed the gchandrasekaran_fixPutOffExpirationForZookeeperStore branch 2 times, most recently from 01b7fba to 4ec842a Compare October 15, 2018 12:06
@GaneshChandrasekaran-zz GaneshChandrasekaran-zz changed the title Refine the contract and implementation for Stores to handle Not Expirable Store cases. [Lock] Refine the contract and implementation for Stores to handle Not Expirable Store cases. Oct 16, 2018
@@ -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();
Copy link
Member

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

Copy link
Member

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.

@GaneshChandrasekaran-zz GaneshChandrasekaran-zz force-pushed the gchandrasekaran_fixPutOffExpirationForZookeeperStore branch from ed9d45e to c110405 Compare October 16, 2018 07:50
@GaneshChandrasekaran-zz GaneshChandrasekaran-zz force-pushed the gchandrasekaran_fixPutOffExpirationForZookeeperStore branch 2 times, most recently from 85e6204 to 3efcaa2 Compare October 16, 2018 08:20
@nicolas-grekas nicolas-grekas added this to the next milestone Oct 17, 2018
Copy link
Member

@fabpot fabpot left a 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();
Copy link
Member

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';
Copy link
Member

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));
Copy link
Member

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);
}

@jderusse
Copy link
Member

jderusse commented Jul 9, 2019

closed by #32299 @fabpot

@fabpot fabpot closed this Jul 9, 2019
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants