elastic / connectors

Source code for all Elastic connectors, developed by the Search team at Elastic, and home of our Python connector development framework
https://www.elastic.co/guide/en/enterprise-search/master/index.html
Other
71 stars 126 forks source link

Make job cleanup service not sleep if it's not running any more #2786

Closed artem-shelkovnikov closed 1 month ago

artem-shelkovnikov commented 1 month ago

All other services do this.

Rationale: If the service is interrupted it should stop doing whatever it's doing and quit.

It can happen due to asynchronous nature that the service is stopped right before the await self._sleeps.sleep(self.idling) is called. What happens is:

  1. self.running is set to false
  2. self._sleeps.cancel is called

But CancellableSleeps class allows adding new sleeps after cancellation happens, so service is not running but it will still sleep one last time before exiting. For job cleanup service this sleep will be 5 minutes by default, thus graceful cancellation will just hang for 5 minutes cause of it.

This change is just to "make it work" - we need to think about making CancellableSleeps not accept any more sleeps if cancelled.

github-actions[bot] commented 1 month ago

💔 Failed to create backport PR(s)

The backport operation could not be completed due to the following error: There are no branches to backport to. Aborting.

The backport PRs will be merged automatically after passing CI.

To backport manually run: backport --pr 2786 --autoMerge --autoMergeMethod squash