i have entries in htable with key name lpi::20033::prefix:
# sip-proxy_ctl mi sht_dump htable | egrep 20033 lpi::20033::prefix[0]:: +3583796294 lpi::20033::prefix[1]:: +35837824030 lpi::20033::prefix::size:: 1
as you see in above, size of that key name is 1 although there clearly is two entries in the table with that key name.
according to readme ::size is number of items:
3.7. array_size_suffix (str)
The suffix to be added to store the number of items in an array.
i verified with another key name where there was only one prefix, and then ::size was again 1. so sometimes ::size is correct and sometimes incorrect.
this looks like a serious bug to me. any comments?
-- juha
Hello,
On 5/24/11 4:40 PM, Juha Heinanen wrote:
iirc, the value of *::size is set only when loading the values from database table. If you add/remove later, it is not updated. Then you should update it as you do changes in hash table, or use the variable counting the items by name:
http://www.kamailio.org/dokuwiki/doku.php/pseudovariables:3.1.x#shtcn_htable...
If the value is invalid at startup/reload, then something is wrong, indeed.
Cheers, Daniel
Daniel-Constantin Mierla writes:
If the value is invalid at startup/reload, then something is wrong, indeed.
daniel,
here you go:
# sip-proxy_ctl mi sht_reload htable # sip-proxy_ctl mi sht_dump htable | egrep 20033 lpi::20033::prefix[0]:: +3583796294 lpi::20033::prefix[1]:: +35837824030 lpi::20033::prefix::size:: 1
-- juha
Juha Heinanen writes:
now when i took closer look at the db table, it actually contains FOUR records with key_name lpi::20033::prefix. so reload skips two of them and records wrong ::size value for the remaining two.
-- juha
mysql> select count(key_name) from htable where key_name = 'lpi::20033::prefix'; +-----------------+ | count(key_name) | +-----------------+ | 4 | +-----------------+
the query in ht_db_load_table is
select key_name,key_type,value_type,key_value from htable order by key_type;
that is records are ordered by key_type, which means that 0 entries come first and 1 entries after that.
in ht_db_load_table function there is test in the loop:
if(ktype==0 && last_ktype==1)
what is point of last_ktype==1 part if 0 records come first and then 1 records? or is c code getting the records in reverse order?
-- juha