Skip to content

[RFC] Make troubleshooting stuck tasks easier #706

Open
@greg0ire

Description

@greg0ire

Hi! I'm working with @julienpa to get the applications of my company on a new Algolia architecture, and I'm facing issues where some of the cronjobs I have to run appear to be stuck sometimes.

I'd like to be able to easily implement custom logic where I start logging the taskID with an increasingly high log level when exceeded an arbitrary duration, and I would like that logic to kick in whenever I call wait() on a response.

This seems to result in this method being called:

public function waitTask($taskId, $requestOptions = [])
{
$retry = 1;
$time = $this->config->getWaitTaskTimeBeforeRetry();
do {
$res = $this->getTask($taskId, $requestOptions);
if ('published' === $res['status']) {
return;
}
$retry++;
$factor = ceil($retry / 10);
usleep($factor * $time); // 0.1 second
} while (true);
}

It would be great if the current implementation of the retry logic could be extracted in a separate class, and if there was an interface I could implement with my custom logic and if I was able to inject my custom implementation in the configuration so that it replaces the default implementation.

Right now, the workaround would be to extend the SearchIndex, override that method, extend SearchClient and override initIndex so that it returns the overridden SearchIndex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions