<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14541">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, approved
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, but someone else must approve
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_sorcery_memory_cache: Disallow per-object expire with full backend.<br><br>The AMI action and CLI command did not take into account the properties<br>of full backend caching. This resulted in an expired object remaining<br>removed until a full backend update occurred, instead of having the<br>object updated when needed.<br><br>This change makes it so that the AMI action and CLI command for object<br>expire will now fail instead of putting the cache into an undesired<br>state. If full backend caching is enabled then only operations<br>which act on the entire cache are available.<br><br>ASTERISK-28942<br><br>Change-Id: Id662d888f177ab566c8e802ad583083b742d21f4<br>---<br>A doc/CHANGES-staging/sorcery_memory_cache_full_expire_object.txt<br>M res/res_sorcery_memory_cache.c<br>2 files changed, 33 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/sorcery_memory_cache_full_expire_object.txt b/doc/CHANGES-staging/sorcery_memory_cache_full_expire_object.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..d568e38</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/sorcery_memory_cache_full_expire_object.txt</span><br><span>@@ -0,0 +1,19 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_sorcery_memory_cache</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The SorceryMemoryCacheExpireObject AMI action and CLI</span><br><span style="color: hsl(120, 100%, 40%);">+command allow expiring of a specific object within the</span><br><span style="color: hsl(120, 100%, 40%);">+sorcery memory cache. This is done by removing the</span><br><span style="color: hsl(120, 100%, 40%);">+object from the cache with the expectation that the</span><br><span style="color: hsl(120, 100%, 40%);">+cache will then re-populate the object when it is next</span><br><span style="color: hsl(120, 100%, 40%);">+needed.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+For full backend caching this does not occur. The cache</span><br><span style="color: hsl(120, 100%, 40%);">+won't repopulate until an entire refresh is done resulting</span><br><span style="color: hsl(120, 100%, 40%);">+in the possibility that objects are missing until that</span><br><span style="color: hsl(120, 100%, 40%);">+time.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The AMI action and CLI command will now not allow</span><br><span style="color: hsl(120, 100%, 40%);">+expiring of an object if the cache is configured as a</span><br><span style="color: hsl(120, 100%, 40%);">+full backend cache. Instead you must use either the</span><br><span style="color: hsl(120, 100%, 40%);">+SorceryMemoryCacheExpire or SorceryMemoryCachePopulate</span><br><span style="color: hsl(120, 100%, 40%);">+AMI actions or their associated CLI commands.</span><br><span>diff --git a/res/res_sorcery_memory_cache.c b/res/res_sorcery_memory_cache.c</span><br><span>index 5029131..dad3146 100644</span><br><span>--- a/res/res_sorcery_memory_cache.c</span><br><span>+++ b/res/res_sorcery_memory_cache.c</span><br><span>@@ -54,7 +54,9 @@</span><br><span> </parameter></span><br><span> </syntax></span><br><span> <description></span><br><span style="color: hsl(0, 100%, 40%);">- <para>Expires (removes) an object from a sorcery memory cache.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>Expires (removes) an object from a sorcery memory cache. If full backend caching is enabled</span><br><span style="color: hsl(120, 100%, 40%);">+ this action is not available and will fail. In this case the SorceryMemoryCachePopulate or</span><br><span style="color: hsl(120, 100%, 40%);">+ SorceryMemoryCacheExpire AMI actions must be used instead.</para></span><br><span> </description></span><br><span> </manager></span><br><span> <manager name="SorceryMemoryCacheExpire" language="en_US"></span><br><span>@@ -1892,7 +1894,9 @@</span><br><span> remove_all_from_cache(cache);</span><br><span> ast_cli(a->fd, "All objects have been removed from cache '%s'\n", a->argv[4]);</span><br><span> } else {</span><br><span style="color: hsl(0, 100%, 40%);">- if (!remove_from_cache(cache, a->argv[5], 1)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (cache->full_backend_cache) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Due to full backend caching per-object expiration is not available on cache '%s'\n", a->argv[4]);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!remove_from_cache(cache, a->argv[5], 1)) {</span><br><span> ast_cli(a->fd, "Successfully expired object '%s' from cache '%s'\n", a->argv[5], a->argv[4]);</span><br><span> } else {</span><br><span> ast_cli(a->fd, "Object '%s' was not expired from cache '%s' as it was not found\n", a->argv[5],</span><br><span>@@ -2084,12 +2088,18 @@</span><br><span> }</span><br><span> </span><br><span> ao2_wrlock(cache->objects);</span><br><span style="color: hsl(0, 100%, 40%);">- res = remove_from_cache(cache, object_name, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (cache->full_backend_cache) {</span><br><span style="color: hsl(120, 100%, 40%);">+ res = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ res = remove_from_cache(cache, object_name, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> ao2_unlock(cache->objects);</span><br><span> </span><br><span> ao2_ref(cache, -1);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!res) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (res == 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ astman_send_error(s, m, "Due to full backend caching per-object expiration is not available, consider using SorceryMemoryCachePopulate or SorceryMemoryCacheExpire instead\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!res) {</span><br><span> astman_send_ack(s, m, "The provided object was expired from the cache\n");</span><br><span> } else {</span><br><span> astman_send_error(s, m, "The provided object could not be expired from the cache\n");</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14541">change 14541</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/14541"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id662d888f177ab566c8e802ad583083b742d21f4 </div>
<div style="display:none"> Gerrit-Change-Number: 14541 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>