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

TasksQueue doesn't remove entry from tasks on RejectedExecutionException #4900

Closed
ahus1 opened this issue Oct 11, 2023 · 2 comments · Fixed by #4901
Closed

TasksQueue doesn't remove entry from tasks on RejectedExecutionException #4900

ahus1 opened this issue Oct 11, 2023 · 2 comments · Fixed by #4901
Labels

Comments

@ahus1
Copy link
Contributor

ahus1 commented Oct 11, 2023

Version

master branch.

Context

I had a look at the code when analyzing a problem in the 4.4.x after I configured a thread pool with a limited backlog which would reject executions eventually.

I found that the code in master throws the exception that the task is rejected, but then the task is still in the taskQueue, so it will eventually be executed when another task is then successfully submitted.
So for the caller it is both rejected and accepted, which is confusing and IMHO wrong.

I'll create a different issue for that as it doesn't handle the RejectedExecutionException at all.

Do you have a reproducer?

Here a unit test as a reproducer - not that (at least for the reproducer) I made the tasks attribute public to I can use it the test. See https://github.com/ahus1/vert.x/tree/poc-show-how-taskqueue-fails-in-main

    TaskQueue taskQueue = new TaskQueue();
    Executor executorThatAlwaysThrowsRejectedExceptions = new Executor() {
        @Override
        public void execute(Runnable command) {
            throw new RejectedExecutionException();
        }
    };

    assertThatThrownBy(() -> {
        taskQueue.execute(new Thread(), executorThatAlwaysThrowsRejectedExceptions);
      }).isInstanceOf(RejectedExecutionException.class);

    // this fails in main
    Assertions.assertThat(taskQueue.tasks).isEmpty();

Steps to reproduce

See test.

Extra

I can start writing a test, but I'm not sure on how to test this.

@ahus1
Copy link
Contributor Author

ahus1 commented Oct 11, 2023

I've created PR #4901. Once this change has been discussed and agreed, I'd be happy to provide a backport to 4.4.x, as I plan to use it in the Keycloak project, which uses this dependency via the Quarkus project.

@ahus1
Copy link
Contributor Author

ahus1 commented Oct 12, 2023

Prepared a backport #4904 for the 4.x branch.

ahus1 added a commit to ahus1/vert.x that referenced this issue Oct 13, 2023
ahus1 added a commit to ahus1/vert.x that referenced this issue Oct 13, 2023
ahus1 added a commit to ahus1/vert.x that referenced this issue Oct 13, 2023
ahus1 added a commit to ahus1/vert.x that referenced this issue Oct 13, 2023
vietj pushed a commit that referenced this issue Oct 16, 2023
vietj pushed a commit that referenced this issue Oct 16, 2023
ahus1 added a commit to ahus1/vert.x that referenced this issue Oct 17, 2023
vietj pushed a commit that referenced this issue Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant