# Create some tasks that may never finish

**URL:** <https://discuss.elastic.co/t/create-some-tasks-that-may-never-finish/318990>\
**Category:** Elasticsearch\
**Created:** [November 15, 2022, 6:09pm UTC](https://discuss.elastic.co/t/create-some-tasks-that-may-never-finish/318990 "2022-11-15T18:09:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sunt-ing](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunt-ing/32/111872_2.png) [@Sunt-ing](https://discuss.elastic.co/u/Sunt-ing)\
**Post date:** [November 15, 2022, 6:09pm UTC](https://discuss.elastic.co/t/create-some-tasks-that-may-never-finish/318990/1 "2022-11-15T18:09:16Z")

</div>

In order to create a testbed for anomaly detection, I need to create some tasks that may never finish (unless you manually kill them) in ES. Is there any way to do that? I do find some problems with storage hardware may result in such tasks, and probably I can rely on some known bugs and ES of the corresponding versions to do that. But is there any regular approach to creating such tasks?

---

<div class="post-metadata">

**Author:** ![Sunt-ing](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunt-ing/32/111872_2.png) [@Sunt-ing](https://discuss.elastic.co/u/Sunt-ing)\
**Post date:** [November 16, 2022, 6:35pm UTC](https://discuss.elastic.co/t/create-some-tasks-that-may-never-finish/318990/2 "2022-11-16T18:35:48Z")

</div>

Maybe I can use Groovy scripting to send a task that does nothing but sleep for a long time to occupy the thread pool?

---

<div class="post-metadata">

**Author:** ![Sunt-ing](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunt-ing/32/111872_2.png) [@Sunt-ing](https://discuss.elastic.co/u/Sunt-ing)\
**Post date:** [November 16, 2022, 7:06pm UTC](https://discuss.elastic.co/t/create-some-tasks-that-may-never-finish/318990/3 "2022-11-16T19:06:02Z")

</div>

Oh, Groovy is not supported since ES 6... So maybe I can use `expert_scripts` to do that?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [November 16, 2022, 7:21pm UTC](https://discuss.elastic.co/t/create-some-tasks-that-may-never-finish/318990/4 "2022-11-16T19:21:12Z")

</div>

I am not sure this is possible. Why does the task need to run within Elasticsearch? Can you not instead monitor an external process that is easier to manipulate?

---

<div class="post-metadata">

**Author:** ![Sunt-ing](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunt-ing/32/111872_2.png) [@Sunt-ing](https://discuss.elastic.co/u/Sunt-ing)\
**Post date:** [November 17, 2022, 5:40am UTC](https://discuss.elastic.co/t/create-some-tasks-that-may-never-finish/318990/5 "2022-11-17T05:40:21Z")

</div>

Sadly, I cannot... Have to build a long-running task that only consumes a little CPU time within ES. 😢

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [November 17, 2022, 6:14am UTC](https://discuss.elastic.co/t/create-some-tasks-that-may-never-finish/318990/6 "2022-11-17T06:14:06Z")

</div>

Why?

---

<div class="post-metadata">

**Author:** ![Sunt-ing](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunt-ing/32/111872_2.png) [@Sunt-ing](https://discuss.elastic.co/u/Sunt-ing)\
**Post date:** [November 17, 2022, 6:50pm UTC](https://discuss.elastic.co/t/create-some-tasks-that-may-never-finish/318990/7 "2022-11-17T18:50:34Z")

</div>

Sorry for the late reply...  
We are going to develop some anomaly detection techniques and use ES to validate these developed techniques.  
Overall, we want to implement an example where one task may considerably degrade the performance of the whole ES system. In this case, an operator could manually cancel the corresponding task in order to improve the performance of ES.  
One such case I can imagine is that if a long-running task somehow occupies a thread from the thread pool for a long time but does nothing, the whole system may suffer.  
A better example could be: if an important task t1, such as create index, is somehow blocked for a while due to an unimportant task t2, and an operator could improve the system performance by canceling t2 and then re-send t2.  
Such a case has been found in MySQL, where a backup task that needs to get the global read lock could be blocked by a long-running query. Reference: [Handling long-running queries in MySQL with Percona XtraBackup](https://www.percona.com/blog/2013/10/11/handling-long-running-queries-in-mysql-with-percona-xtrabackup/)  
But I cannot find such a case in ES. I'm now reading the source codes of these important tasks in ES and hopefully I can find a satisfying case.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 15, 2022, 6:51pm UTC](https://discuss.elastic.co/t/create-some-tasks-that-may-never-finish/318990/8 "2022-12-15T18:51:36Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
