Skip to content
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

Introduce lock acquisition timeout #8062

Merged

Conversation

MishaDemianenko
Copy link
Contributor

Introduce property that defines timeout for shared and exclusive lock acquisition in lock clients.
In case if user configure timeout any acquisitions that take more then configured time interval will be terminated and LockAcquisitionTimeoutException will be raised.
Add support of new property to community and forseti lock managers.

Unify clocks usage during database construction/creation: now all components will use exactly the same instance of clock that provided by PlatformModule.

@MishaDemianenko
Copy link
Contributor Author

@lutovich any news?

Copy link
Contributor

@lutovich lutovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MishaDemianenko sorry, I kind of forgot about this PR.

Changes look good, added one question/suggestion.
Also couple more general points:

  • please make newly introduced fields in LockManagerImpl, RWLock, ForsetiClient and ForsetiLockManager final
  • would be really nice to have ITs for lock acquisition timeout involving community/forseti, shared/exclusive and master/slave. I understand, they might be flaky or long running because of need to rely on time but still it is better than nothing.

* Used in lock clients for cases when we unable to acquire a lock for a time that exceed configured
* timeout, if any.
*
* @see Locks.Client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also @see GraphDatabaseSettings#lock_acquisition_timeout

wait();
if ( lockAcquisitionTimeoutMillis > 0 )
{
wait( Math.abs( lockAcquisitionTimeBoundary - clock.millis() ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If clock.millis() >>> lockAcquisitionTimeBoundary due to thread scheduling or smth, thread will still wait for a while and then throw exception. Would it make sense to make previous condition
if (lockAcquisitionTimeoutMillis > 0 && lockAcquisitionTimeBoundary > currentMillis)
and then just wait(lockAcquisitionTimeBoundary-currentMillis) ?

@MishaDemianenko MishaDemianenko force-pushed the 3.1-terminate-long-locks-acquisitions branch from 09c65da to f708f7d Compare October 17, 2016 16:01
@MishaDemianenko MishaDemianenko changed the base branch from 3.1 to 3.2 November 7, 2016 15:52
Introduce property that defines timeout for shared and exclusive lock acquisition in lock clients.
In case if user configure timeout any acquisitions that take more then configured time interval will be terminated and LockAcquisitionTimeoutException will be raised.
Add support of new property to community and forseti lock managers.

Unify clocks usage during database construction/creation: now all components will use exactly the same instance of clock that provided by PlatformModule.
@MishaDemianenko MishaDemianenko force-pushed the 3.1-terminate-long-locks-acquisitions branch from b572d73 to c0e43ad Compare November 7, 2016 16:04
… shared locks for community and forseti lock managers.
@MishaDemianenko
Copy link
Contributor Author

@lutovich additional tests introduced, can you please take a look now!

Copy link
Contributor

@lutovich lutovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MishaDemianenko looks good, one small question.

public void tearDown()
{
secondTransactionExecutor.close();
clockExecutor.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should database.shutdown() be here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lutovich absolutely, we need to shut it down; updated, thx!

@lutovich lutovich merged commit 6c597a9 into neo4j:3.2 Nov 16, 2016
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.

None yet

3 participants