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

Allow unknown task time in QueueResizingEsTPE #41810

Conversation

williamrandolph
Copy link
Contributor

The afterExecute method previously asserted that a TimedRunnable task
must have a positive execution time. However, the code in TimedRunnable
returns a value of -1 when a task time is unknown. Here, we expand the
logic in the assertion to allow for that possibility, and we don't
update our task time average if the value is negative.

Fixes #41448

The afterExecute method previously asserted that a TimedRunnable task
must have a positive execution time. However, the code in TimedRunnable
returns a value of -1 when a task time is unknown. Here, we expand the
logic in the assertion to allow for that possibility, and we don't
update our task time average if the value is negative.

Fixes elastic#41448
@williamrandolph williamrandolph added >bug :Core/Infra/Core Core issues without another label v8.0.0 v7.2.0 labels May 3, 2019
@williamrandolph williamrandolph requested a review from jaymode May 3, 2019 20:13
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@williamrandolph
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/1

Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

This looks pretty good. I think we can make a change to be more explicit though.

@@ -151,8 +151,12 @@ protected void afterExecute(Runnable r, Throwable t) {
final long totalNanos = totalTaskNanos.addAndGet(taskNanos);

final long taskExecutionNanos = timedRunnable.getTotalExecutionNanos();
assert taskExecutionNanos >= 0 : "expected task to always take longer than 0 nanoseconds, got: " + taskExecutionNanos;
executionEWMA.addValue(taskExecutionNanos);
assert taskExecutionNanos >= 0 || taskExecutionNanos == -1 :
Copy link
Member

Choose a reason for hiding this comment

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

I am a bit paranoid about things. I'd prefer if we also tracked if an exception occurred with a boolean that gets updated in the onRejection and onFailure methods. Then we can say for certain that a taskExecutionNanos of -1 was really due to an exception.

In order to be sure that a task has an execution time of -1 because of
a failure, I'm adding a failure flag boolean to the TimedRunnable class.
If execution time is negative for some other reason, an assertion will
fail.
@williamrandolph williamrandolph requested a review from jaymode May 6, 2019 21:44
Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

LGTM

@williamrandolph williamrandolph merged commit 86d9e98 into elastic:master May 7, 2019
jasontedor pushed a commit that referenced this pull request May 7, 2019
* Allow unknown task time in QueueResizingEsTPE

The afterExecute method previously asserted that a TimedRunnable task
must have a positive execution time. However, the code in TimedRunnable
returns a value of -1 when a task time is unknown. Here, we expand the
logic in the assertion to allow for that possibility, and we don't
update our task time average if the value is negative.

Fixes #41448

* Add a failure flag to TimedRunnable

In order to be sure that a task has an execution time of -1 because of
a failure, I'm adding a failure flag boolean to the TimedRunnable class.
If execution time is negative for some other reason, an assertion will
fail.
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request May 7, 2019
* elastic/master: (50 commits)
  Cleanup versioned deprecations in analysis (elastic#41560)
  Allow unknown task time in QueueResizingEsTPE (elastic#41810)
  SQL: Remove CircuitBreaker from parser (elastic#41835)
  [DOCS] Fix callouts for dataframe APIs (elastic#41904)
  Handle serialization exceptions during publication (elastic#41781)
  Correct spelling of MockLogAppender.PatternSeenEventExpectation (elastic#41893)
  Update TLS ciphers and protocols for JDK 11 (elastic#41808)
  Remove Harmful Exists Check from BlobStoreFormat (elastic#41898)
  Fix fractional seconds for strict_date_optional_time (elastic#41871)
  Remove op.name configuration setting (elastic#41445)
  Reject port ranges in `discovery.seed_hosts` (elastic#41404)
  [ML-DataFrame] migrate to PageParams for get and stats, move PageParams into core (elastic#41851)
  Reenable RareClusterStateIT Mapping Propagation Tests (elastic#41884)
  [DOCS] Rewrite `exists` query docs (elastic#41868)
  Revert "Mute MinimumMasterNodesIT.testThreeNodesNoMasterBlock()"
  [DOCS] Fix typo referring to multi search API
  Provide names for all artifact repositories (elastic#41857)
  Move InternalAggregations to Writeable (elastic#41841)
  Fix compilation after incorrect merge
  Unmute TestClustersPluginIT.testMultiNode (elastic#41340)
  ...
williamrandolph added a commit to williamrandolph/elasticsearch that referenced this pull request May 8, 2019
* Allow unknown task time in QueueResizingEsTPE

The afterExecute method previously asserted that a TimedRunnable task
must have a positive execution time. However, the code in TimedRunnable
returns a value of -1 when a task time is unknown. Here, we expand the
logic in the assertion to allow for that possibility, and we don't
update our task time average if the value is negative.

* Add a failure flag to TimedRunnable

In order to be sure that a task has an execution time of -1 because of
a failure, I'm adding a failure flag boolean to the TimedRunnable class.
If execution time is negative for some other reason, an assertion will
fail.

Backport of elastic#41810
Fixes elastic#41448
williamrandolph added a commit that referenced this pull request May 8, 2019
* Allow unknown task time in QueueResizingEsTPE

The afterExecute method previously asserted that a TimedRunnable task
must have a positive execution time. However, the code in TimedRunnable
returns a value of -1 when a task time is unknown. Here, we expand the
logic in the assertion to allow for that possibility, and we don't
update our task time average if the value is negative.

* Add a failure flag to TimedRunnable

In order to be sure that a task has an execution time of -1 because of
a failure, I'm adding a failure flag boolean to the TimedRunnable class.
If execution time is negative for some other reason, an assertion will
fail.

Backport of #41810
Fixes #41448
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
* Allow unknown task time in QueueResizingEsTPE

The afterExecute method previously asserted that a TimedRunnable task
must have a positive execution time. However, the code in TimedRunnable
returns a value of -1 when a task time is unknown. Here, we expand the
logic in the assertion to allow for that possibility, and we don't
update our task time average if the value is negative.

Fixes elastic#41448

* Add a failure flag to TimedRunnable

In order to be sure that a task has an execution time of -1 because of
a failure, I'm adding a failure flag boolean to the TimedRunnable class.
If execution time is negative for some other reason, an assertion will
fail.
@williamrandolph williamrandolph deleted the fix/41448_allow_unknown_task_times branch August 21, 2019 14:30
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 this pull request may close these issues.

[CI] QueueResizingEsThreadPoolExecutor assertion fails if task time not available
4 participants