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 concurrency issue in PrioritizedEsThreadPoolExecutor. #12599

Commits on Aug 3, 2015

  1. Fix concurrency issue in PrioritizedEsThreadPoolExecutor.

    Tasks can be registered with a timeout, which runs as a task in a separate
    threadpool. The idea is that the timeout runner cancels the main task when
    the time is out, and the timeout runner is cancelled when the main task
    starts executing. However, the following statement:
    
    ```java
                        timeoutFuture = timer.schedule(new Runnable() {
                            @OverRide
                            public void run() {
                                if (remove(TieBreakingPrioritizedRunnable.this)) {
                                    runAndClean(timeoutCallback);
                                }
                            }
                        }, timeValue.nanos(), TimeUnit.NANOSECONDS);
    ```
    
    is not atomic: the removal task is first started, and then the (volatile)
    variable is assigned. As a consequence, there is a short window that allows
    a timeout task to wait until the time is out even if the task is already
    completed.
    
    See http://build-us-00.elastic.co/job/es_core_17_centos/496/ for an example of
    such a failure.
    jpountz committed Aug 3, 2015
    Configuration menu
    Copy the full SHA
    1eaa9f9 View commit details
    Browse the repository at this point in the history