Skip to content

Fix shutdown in httpRemote task runner - #13558

Merged
AmatyaAvadhanula merged 5 commits into
apache:masterfrom
AmatyaAvadhanula:httpRemote_shutdown_callbacks
Dec 22, 2022
Merged

AmatyaAvadhanula merged 5 commits into
apache:masterfrom
AmatyaAvadhanula:httpRemote_shutdown_callbacks

Conversation

@AmatyaAvadhanula

@AmatyaAvadhanula AmatyaAvadhanula commented Dec 13, 2022 •

Copy link
Copy Markdown
Contributor

Description

HttpRemoteTaskRunner#shutdown doesn't execute the shutdown hooks and this led to discrepancies such as task/run/time not being emitted by cancelled tasks or those shutdown by the supervisor.

This patch retains the task in the set of tasks within HttpRemoteTaskRunner and clears them only when the state is already completed.


Key changed/added classes in this PR
  • HttpRemoteTaskRunner

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@AmatyaAvadhanula
AmatyaAvadhanula marked this pull request as ready for review December 14, 2022 04:57

@kfaraz kfaraz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix, @AmatyaAvadhanula . Could you also add a test that verifies the emission of the task/run/time metric in case of a forced shutdown?

}

@Test
public void testShutdown()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add some more info, either as a comment or in the method name itself to clarify what this method validates?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@AmatyaAvadhanula

Copy link
Copy Markdown
Contributor Author

@kfaraz thank you for the review! The test has been added as well

}

@Test
public void testHttpRemoteTaskRunnerTaskShutdownMetricsEmission() throws EntryExistsException, InterruptedException

@kfaraz kfaraz Dec 20, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this test be a part of HttpRemoteTaskRunnerTest?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TaskQueue emits task/run/time

}

@Test
public void testHttpRemoteTaskRunnerTaskShutdownMetricsEmission() throws EntryExistsException, InterruptedException

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void testHttpRemoteTaskRunnerTaskShutdownMetricsEmission() throws EntryExistsException, InterruptedException
public void testKilledTasksEmitRuntimeMetric() throws EntryExistsException, InterruptedException

);
taskQueue.add(task);
taskQueue.manageInternal();
taskRunner.taskAddedOrUpdated(TaskAnnouncement.create(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is an internal method. We should avoid calling this in the test. Is it not possible to verify the behaviour just by invoking shutdown and verifying the emitted metric?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The test is a bit verbose because it requires the verification of metrics in the TaskQueue when HttpRemoteTaskRunner is used in particular

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I meant if it is possible to verify the behaviour without calling this method taskAddedOrupdated().


private HttpRemoteTaskRunner createTaskRunnerForTestTaskAddedOrUpdated(
/**
* Validate the internal state of tasks withing the task runner

@kfaraz kfaraz Dec 20, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding the comments! But this seems a little broad for a test. If you are validating multiple things, consider breaking up the test.

@kfaraz kfaraz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left some suggestions for the tests. The code change looks good.

@AmatyaAvadhanula

Copy link
Copy Markdown
Contributor Author

Merging since the failed ITs are unrelated

@AmatyaAvadhanula
AmatyaAvadhanula merged commit af05cfa into apache:master Dec 22, 2022
@clintropolis clintropolis added this to the 26.0 milestone Apr 10, 2023
riovic918data pushed a commit to riovic918data/druid that referenced this pull request Jun 12, 2026
* Fix shutdown in httpRemote task runner

* Add UT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants