[ 
https://issues.apache.org/jira/browse/YARN-2183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14183486#comment-14183486
 ] 

Sangjin Lee commented on YARN-2183:
-----------------------------------

Yes, I would arrive at essentially the same result if we removed this race 
condition check. This would ensure that only one cleaner task runs at a given 
time (i.e. serial execution). What it does not prevent, however, is a 
*back-to-back* execution if an on-demand cleaner run was submitted close to a 
scheduled cleaner run.

The key here is that we're using a *single-threaded* scheduled executor.

Here is the sequence with your patch:
# a scheduled run gets under way and sets cleanerTaskIsRunning to true
# an on-demand run gets submitted: but it will not run until the scheduled run 
finished because it runs on a single-threaded scheduled executor
# the scheduled run finishes and flips cleanerTaskIsRunning to false
# the on-demand run gets under way, and finds cleanerTaskIsRunning is false so 
it runs again (i.e. a back-to-back run)

With v.6:
# a scheduled run gets under way and sets cleanerTaskIsRunning to true
# an on-demand run is requested but does *not* get scheduled because we're 
checking if a run is already in progress before submitting it (i.e. no 
back-to-back run)
# the scheduled run finishes and flips cleanerTaskIsRunning to false

Another way of accomplishing this is to put the on-demand cleaner task on a 
different executor or a different thread within the same scheduled executor 
(e.g. giving the scheduled executor 2 threads instead of 1). Then we could do 
this with the simpler code as the check can be made concurrently and it will do 
the right thing. What do you think?


> Cleaner service for cache manager
> ---------------------------------
>
>                 Key: YARN-2183
>                 URL: https://issues.apache.org/jira/browse/YARN-2183
>             Project: Hadoop YARN
>          Issue Type: Sub-task
>            Reporter: Chris Trezzo
>            Assignee: Chris Trezzo
>         Attachments: YARN-2183-trunk-v1.patch, YARN-2183-trunk-v2.patch, 
> YARN-2183-trunk-v3.patch, YARN-2183-trunk-v4.patch, YARN-2183-trunk-v5.patch, 
> YARN-2183-trunk-v6.patch, on-demand-cleaner.patch
>
>
> Implement the cleaner service for the cache manager along with metrics for 
> the service. This service is responsible for cleaning up old resource 
> references in the manager and removing stale entries from the cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to