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

[Lock] Add a TTL to refresh lock #26232

Merged
merged 1 commit into from Feb 19, 2018

Conversation

Projects
None yet
5 participants
@jderusse
Contributor

jderusse commented Feb 19, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? see LockInterface's comment
Tests pass? yes
Fixed tickets NA
License MIT
Doc PR NA

Using remote locks in long processes needs to defines a fined grain refresh TTL. For instance, when looping over a long list of jobs we can extends the live of the lock by few seconds before processing each item.
But when the the jobs is splitted and each part to take the same time, we can not define the best TTL

Exemple

$lock->acquire();

$this->2minutesJob();

$lock->refresh();
$this->5minutesJob();

$lock->refresh();
$this->1minutesJob();

The purpose of this PR is to be able to override the default TTL

$lock->acquire();

$lock->refresh(120);
$this->2minutesJob();

$lock->refresh(300);
$this->5minutesJob();

$lock->refresh(60);
$this->1minutesJob();

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Feb 19, 2018

* @throws LockConflictedException If the lock is acquired by someone else
* @throws LockAcquiringException If the lock can not be refreshed
*/
public function refresh();
public function refresh(/* $ttl = null */);

This comment has been minimized.

@jderusse

jderusse Feb 19, 2018

Contributor

I'm not such this is the right way to keep BC layer on interfaces. ping @nicolas-grekas

Is there a way to trigger a deprecation?

This comment has been minimized.

@Simperfit

Simperfit Feb 19, 2018

Contributor

Maybe you can trigger a deprecation in the interface like e8351d8#diff-7994cccf0d9c75a5a481e1240a159cce

@fabpot

fabpot approved these changes Feb 19, 2018

@fabpot

This comment has been minimized.

Member

fabpot commented Feb 19, 2018

Thank you @jderusse.

@fabpot fabpot merged commit 3b1f328 into symfony:master Feb 19, 2018

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Feb 19, 2018

feature #26232 [Lock] Add a TTL to refresh lock (jderusse)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Lock] Add a TTL to refresh lock

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | see LockInterface's comment
| Tests pass?   | yes
| Fixed tickets | NA
| License       | MIT
| Doc PR        | NA

Using remote locks in long processes needs to defines a fined grain refresh TTL. For instance, when looping over a long list of jobs we can extends the live of the lock by few seconds before processing each item.
But when the the jobs is splitted and each part to take the same time, we can not define the best TTL

Exemple
```
$lock->acquire();

$this->2minutesJob();

$lock->refresh();
$this->5minutesJob();

$lock->refresh();
$this->1minutesJob();
```

The purpose of this PR is to be able to override the default TTL

```
$lock->acquire();

$lock->refresh(120);
$this->2minutesJob();

$lock->refresh(300);
$this->5minutesJob();

$lock->refresh(60);
$this->1minutesJob();
```

Commits
-------

3b1f328 Add a TTL to refresh lock

@fabpot fabpot referenced this pull request May 7, 2018

Merged

Release v4.1.0-BETA1 #27181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment