Hello,

indeed, the location_attrs should be deleted along with the contact records.

What db_mode value you use for usrloc module?

Cheers,
Daniel


On 20/02/2017 10:17, Mridul B wrote:
Hi,

We've noticed a case where the location_attrs table isn't updated when there's an unexpected shutdown of a SIP device (here there'll be no REGISTER message sent with expires=0). 

We're using Kamailio v4.3.x

When the SIP device shuts down ungracefully. The location table is updated using DELETE query
This is done by the timer which deletes the expired contacts, by default the timer_interval is set as 60.

Here, the logs of auto-removal of expired contacts entries by the timer


Feb 17 17:16:13 localhost kamailio[23273]: DEBUG: db_postgres [km_dbase.c:272]: db_postgres_submit_query(): sending query ok: 0x7f34969433c8 (1) - [delete from location where expires<'2017-02-17 17:16:14' AND expires<>'1970-01-01 00:00:00']
 
Feb 17 17:16:14 localhost kamailio[23272]: DEBUG: db_postgres [km_dbase.c:272]: db_postgres_submit_query(): sending query ok: 0x7f34969433c8 (1) - [delete from location where expires<'2017-02-17 17:16:15' AND expires<>'1970-01-01 00:00:00'] 
 

The delete operation is only on location table, shouldn't we have the same implementation on the location_attrs table based upon ruid or username?

We're getting duplicate entries in the location_attrs table of the same sip user after it registers.

But when the SIP device un-registers, the entries in the location as well as in the location_attrs table is deleted

Feb 17 18:14:32 localhost kamailio[23249]: DEBUG: usrloc [ucontact.c:1725]: uldb_delete_attrs(): trying to delete location attributes
Feb 17 18:14:32 localhost kamailio[23249]: DEBUG: db_postgres [km_dbase.c:272]: db_postgres_submit_query(): sending query ok: 0x7f3496941888 (1) - [delete from location_attrs where username='mridul' AND ruid='uloc-58a72243-5ace-2']
 
Feb 17 18:14:32 localhost kamailio[23249]: DEBUG: db_postgres [km_dbase.c:272]: db_postgres_submit_query(): sending query ok: 0x7f3496941888 (1) - [delete from location where username='mridul' AND contact='sip:mridul@127.0.0.1:37881;rinstance=b841a8c916e47dfa']


I think the usrloc module should have the implementation of deleting the entries of expired sip users based on its ruid/username in the location_attrs table also.

Thanks for the help.

Best regards,
MRIDUL



_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.com
Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.com