[SR-Users] Problem with update/retrigger a htable

Daniel-Constantin Mierla miconda at gmail.com
Mon Nov 21 12:09:07 CET 2022


Hello,

the event route is executed on timer, and that can happen later that the
item is actually expired. The reason is not to stress the access to the
htable, looping every second. But you can set the timer interval to 1,
if you really need it.

As it is designed now, practically the item must no longer be in the
htable once the event route is executed. You can make a PR if you need a
different behaviour, ideally controlled by a modparam/option, if it
changes the current behaviour.

Also, if you just need to run some tasks periodically, maybe rtimer
module is more suitable.

Cheers,
Daniel

On 21.11.22 11:41, Bernd Krueger-Knauber wrote:
> Hi Daniel-Constantin,
>
> I just found this parameter too.
> I set it now to 10 seconds, but for example a 30 second expire is only
> executed every 40 seconds.
>
> It looks, that I'm not able to set the same entry again inside of the
> event_route.
> Maybe it is deleted after the event_route is executed.
> There should be a check afterards if the entry is still expired before
> deleting it.
> I found an ugly solution:
> I use 2 identical htables and toggle between them:
>
> event_route[htable:expired:userpush1] {
>     xinfo("[event_route] userpush1 Record expired $shtrecord(key) =>
> $shtrecord(value)");
>     $sht(userpush2=>$shtrecord(key)) = $shtrecord(value);
> }
>
> event_route[htable:expired:userpush2] {
>     xinfo("[event_route] userpush2 Record expired $shtrecord(key) =>
> $shtrecord(value)");
>     $sht(userpush1=>$shtrecord(key)) = $shtrecord(value);
> }
>
> It works, but it is ugly.
>
> Thank you for your response.
>
> Bernd
>
>
>
> Am 21.11.2022 um 11:34 schrieb Daniel-Constantin Mierla:
>> Hello,
>>
>> check the docs of the module, there is a modparam to set the timer
>> interval, which by default is 20 secods.
>>
>> Then, to troubleshoot, run with debug=3 and watch the log messages for
>> hints of what happens. Also, dump the htable via rpc to see its content.
>>
>> Cheers,
>> Daniel
>>
>> On 21.11.22 08:50, Bernd Krueger-Knauber wrote:
>>> Hi members,
>>>
>>> I run into a problemm with htable.
>>> For user push notifications I need a loop.
>>>
>>> So I did the following for a first test:
>>>
>>> modparam("htable", "htable", "user=>size=3;autoexpire=5")
>>>
>>> ...
>>>
>>>
>>> event_route[htable:mod-init] {
>>>      xinfo("htable init");
>>>      $sht(user=>testkey) = "testvalue";
>>> }
>>>
>>> event_route[htable:expired:user] {
>>>      xinfo("Record expired $shtrecord(key) => $shtrecord(value)");
>>>      $sht(user=>$shtrecord(key)) = $shtrecord(value);
>>> }
>>>
>>>
>>> I see the htable init, and I reach Record expired, but only once.
>>> The 'new' entry
>>> $sht(user=>$shtrecord(key)) = $shtrecord(value);
>>> seams not to be re-added, because I never reach the expired event
>>> again.
>>>
>>> I expected to see cyclic expired events.
>>> Also strange:
>>> expire is set to 5 seconds I get:
>>>
>>> Nov 21 08:34:50 xxx /usr/sbin/kamailio[254662]: INFO: <script>: htable
>>> init
>>> ...
>>> Nov 21 08:35:10 xxx /usr/sbin/kamailio[254671]: INFO: <script>: Record
>>> expired testkey => testvalue
>>>
>>> If I'm right, this are 20 seconds and not 5.
>>>
>>> Any ideas what's wrong?
>>>
>>> Best regards
>>>
>>>
>>> __________________________________________________________
>>> Kamailio - Users Mailing List - Non Commercial Discussions
>>> sr-users at lists.kamailio.org
>>> Important: keep the mailing list in the recipients, do not reply only
>>> to the sender!
>>> Edit mailing list options or unsubscribe:
>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
>
> -- 
> EDNT GmbH
> Werner-von-Siemens-Strasse 7
> 64625 Bensheim
> www.ednt.de
>
> Registergericht: Darmstadt
> Registernummer: 24972
>
> Geschäftsführerin: Kerstin Knapp
>
>
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda




More information about the sr-users mailing list