asterisk icon indicating copy to clipboard operation
asterisk copied to clipboard

[bug]: sorcery cache remove stale object if backend return error OR timeout.

Open bulatov-an opened this issue 2 years ago • 3 comments
trafficstars

Severity

Major

Versions

any from 13.6

Components/Modules

res_sorcery_memory_cache

Operating Environment

Any version

Frequency of Occurrence

Constant

Issue Description

The sorcery cache does not work correctly if the realtime backend returns an error. Both the error and the absence of the object are perceived the same way.

Example, file res_sorcery_memory_cache.c on line 996:

object = ast_sorcery_retrieve_by_id(task_data->sorcery, ast_sorcery_object_get_type(task_data->object), ast_sorcery_object_get_id(task_data->object)); if (!object) { ast_debug(1, "Backend no longer has object type '%s' ID '%s'. Removing from cache\n", ast_sorcery_object_get_type(task_data->object), ast_sorcery_object_get_id(task_data->object)); sorcery_memory_cache_delete(task_data->sorcery, task_data->cache, task_data->object); }

object NULL if no object or backend error. If backend down, then staled objects removed from cashe, but this should not be the case. The object must remain in the cache until the expiration date. Backend errors should not kill objects in the cache.

Relevant log output

No response

Asterisk Issue Guidelines

  • [X] Yes, I have read the Asterisk Issue Guidelines

bulatov-an avatar Aug 25 '23 07:08 bulatov-an

see, https://habr.com/ru/companies/ozontech/articles/717856/

example patch for ver 20.1.0 - https://github.com/vedga/asterisk-patch/blob/main/20.1.0/feature-fixed-realtime.patch

bulatov-an avatar Aug 25 '23 07:08 bulatov-an

The project can not take patches from other repos and include them or look at them. Contributions need to be done as a pull request with a contributor license agreement.

jcolp avatar Aug 25 '23 08:08 jcolp

Patch just example, i dont know how realy fix. This bug is critial for correct realtime healt. Realtime backend down = asterisk stop work.

bulatov-an avatar Aug 25 '23 08:08 bulatov-an