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

fix #1715 #1740

Merged
merged 1 commit into from
Sep 29, 2015
Merged

fix #1715 #1740

merged 1 commit into from
Sep 29, 2015

Conversation

nishantmonu51
Copy link
Member

fixes #1715

  • TaskLockBox has a set of active tasks
  • lock requests throws exception for if they are from a task not in
    active task set.
  • TaskQueue is responsible for updating the active task set on
    tasklockbox

*/
private Optional<TaskLock> tryLock(final Task task, final Interval interval, final Optional<String> preferredVersion)
{
giant.lock();

try {
if(!tasks.contains(task)){
Copy link
Contributor

Choose a reason for hiding this comment

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

This has me a bit worried because then every task needs to implement equals and hash properly, which I'm not sure was enforced prior to this. Is there a reason it cannot be a set of the string TaskID?

Copy link
Member Author

Choose a reason for hiding this comment

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

makes sense, will change it to store taskId.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@@ -66,6 +66,9 @@

private static final EmittingLogger log = new EmittingLogger(TaskLockbox.class);

// Stores List of Active Tasks. TaskLockbox will only grant locks to active activeTasks.
private final Set<String> activeTasks = Sets.newHashSet();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need memory protection of the big lock to access or modify? If so it is probably worth calling out here.

*/
private Optional<TaskLock> tryLock(final Task task, final Interval interval, final Optional<String> preferredVersion)
{
giant.lock();

try {
if(!activeTasks.contains(task.getId())){
Copy link
Contributor

Choose a reason for hiding this comment

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

Why throw ISE instead of returning absent?

Copy link
Member Author

Choose a reason for hiding this comment

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

modified to return absent for invalid tasks.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it doesn't throw something then "lock" will spin forever.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

@nishantmonu51 nishantmonu51 force-pushed the validate-locks branch 3 times, most recently from 5c21b80 to c0da8dc Compare September 17, 2015 11:24
{
giant.lock();
try {
return activeTasks.remove(task.getId());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this method should be combined with unlock(Task), they're both called at the same time (by the queue, when a task finishes).

This method should also be signalling the lockReleaseCondition, since when a task is removed then we want to ISE out of any lock(task) calls for that task.

@nishantmonu51
Copy link
Member Author

@gianm have taken care of your comments. please have a look again

@drcrallen drcrallen added this to the 0.8.2 milestone Sep 22, 2015
}
finally {
activeTasks.remove(task.getId());
Copy link
Contributor

Choose a reason for hiding this comment

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

unlock should have a finally block of its own, even if this remove is in its own try{}finally{} block.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

*/
private Optional<TaskLock> tryLock(final Task task, final Interval interval, final Optional<String> preferredVersion)
{
giant.lock();

try {
if(!activeTasks.contains(task.getId())){
throw new IllegalStateException(String.format("Unable to grant lock to inactive Task [%s]", task.getId()));
Copy link
Contributor

Choose a reason for hiding this comment

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

small comment, but why don't we use ISE here instead?

@fjy
Copy link
Contributor

fjy commented Sep 23, 2015

👍

fixes apache#1715
- TaskLockBox has a set of active tasks
- lock requests throws exception for if they are from a task not in
active task set.
- TaskQueue is responsible for updating the active task set on
tasklockbox

fix apache#1715

fixes apache#1715
- TaskLockBox has a set of active tasks
- lock requests throws exception for if they are from a task not in
active task set.
- TaskQueue is responsible for updating the active task set on
tasklockbox

review comment

remove duplicate line

use ISE instead

organise imports
drcrallen added a commit that referenced this pull request Sep 29, 2015
@drcrallen drcrallen merged commit d2e400f into apache:master Sep 29, 2015
@drcrallen drcrallen deleted the validate-locks branch September 29, 2015 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zombie tasks able to acquire locks after failure
4 participants