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

fixed wrong gc calculation #4203

Merged
merged 5 commits into from Aug 10, 2016
Merged

fixed wrong gc calculation #4203

merged 5 commits into from Aug 10, 2016

Conversation

unterstein
Copy link
Contributor

Before the task state refactoring the class ExpungeOverdueLostTasksActor had following logic to filter unreachable tasks which received 24 hours no updates:

  def filterLostGCTasks(tasks: Map[PathId, AppTasks]): Iterable[Task] = {
    def isTimedOut(task: Task): Boolean = {
      task.mesosStatus.fold(false) { status =>
        val age = clock.now().toDateTime.minus(status.getTimestamp.toLong * 1000).getMillis.millis
        age > config.taskLostExpungeGC
      }
    }
    tasks.values.flatMap(_.tasks.filter {
      case TemporarilyUnreachable(task) if isTimedOut(task) => true
      case _ => false
    })
  }

During the refactoring the filter was changed to

tasks.values.flatMap(_.tasks.filter(task => isTimedOut(task.mesosStatus)))

which misses the fact that it should filter the unreachable tasks, which I re-introduced with this PR by adding task => task.isUnreachable && isTimedOut(task.mesosStatus)

@@ -20,6 +20,7 @@ trait Mockito extends MockitoSugar {
def times(num: Int) = M.times(num)
def timeout(millis: Int) = M.timeout(millis.toLong)
def atLeastOnce = M.atLeastOnce()
def once = M.times(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

times(1) is the default, so this is redundant, but ok if you want to be very explicit =)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ok, did`t know that. Should I change this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually like it personally.

verify(mock).abc()vs verify(mock, once).abc() is much more obvious.

@gkleiman
Copy link
Contributor

LGTM, I guess that we need to cherry-pick this, so a changelog entry would be nice =)

@kensipe
Copy link
Contributor

kensipe commented Aug 10, 2016

LGTM after the style updates.

@gkleiman gkleiman merged commit f0d56de into master Aug 10, 2016
@gkleiman gkleiman deleted the ju/wrong-gc-calculation branch August 10, 2016 19:06
@gkleiman
Copy link
Contributor

Thanks for fixing this nasty bug!

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.

None yet

6 participants