Running latest 4.2 with usrloc in db_mode=3. It seems "kamctl stats usrloc" or "kamctl ul show" always shows 0 registered users even when there are registered users (location table has entries).
This looks like a bug?
---
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/113
In order to avoid problems with reserved words We should quote the column names for auto-generated MySQL script files
Related to #159
---
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/160
Hello Daniel / List,
I think I have found some issues with the usrloc/serial forking/ul attributes functionality. I hope the following explanation is not too complicated!
The registrar.lookup() function loads contacts into the ruri and branch[] structures. If there are ulattrs associated with the record, these are loaded into an XAVP indexed by branch.
This means that if I immediately run t_relay(), I can use $xavp(ulattrs[$T_branch_idx]=>key) in the branch_route to access per-location attributes.
Issue 1:
As far as I see, if I run t_load_contacts() & t_next_contacts(), the ulattrs XAVP stack is not loaded along with the branches and may cause the branches and ulattrs XAVP to be mismatched. I believe the fix is to load each XAVP along with the branch info, and then reassign back to the correct index in t_next_contacts/t_next_contact_flow. Does this sound correct?
Issue 2:
When a usrloc contact record is created, the XAVP associated with each contact is cloned from the existing 'ulattrs' XAVP if one is already attached to the transaction. The code in usrloc/ucontact.c lines 53-84 does this cloning and was added by Daniel in Dec 2012 as part of the original xavp feature (https://github.com/kamailio/kamailio/commit/e6ad428f6699621b7ee622984eeea3e…).
This code is used when save() is called, to store the attributes into the record before saving to the database.
It is also run when lookup() is called and in some cases this can lead to the attributes loaded from the database being discarded or incorrect ones being cloned. I need this xavp cloning to be turned off on a lookup. Was the intention to have the option to clone changeable depending on where it was called from? There is a function to set the option, but it is never called from anywhere.
I don't have a fix for the 2nd issue yet. Is it too late to get these into 4.3.0?
Regards,
Hugh
________________________________
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you for understanding.
Hi,
I just notice an error in pua_reginfo and I was intrigued:
a REGISTER is received and then:
> proxy[30664]: DEBUG: usrloc [udomain.c:602]: db_load_urecord(): aor 88835677220000(a)X.X.X.X not found in table location
> proxy[30664]: DEBUG: usrloc [ul_callback.h:89]: run_ul_callbacks(): contact=0x7fddc7836b40, callback type 1/1, id 0 entered
> proxy[30664]: DEBUG: pua_reginfo [usrloc_cb.c:240]: reginfo_usrloc_cb(): AOR: 88835677220000(a)X.X.X.X (location)
> proxy[30664]: DEBUG: pua_reginfo [usrloc_cb.c:241]: reginfo_usrloc_cb(): type= UL_CONTACT_INSERT
> proxy[30664]: DEBUG: usrloc [udomain.c:702]: db_load_urecord_by_ruid(): aor uloc-555da99c-77c8-1 not found in table location
> proxy[30664]: ERROR: pua_reginfo [usrloc_cb.c:261]: reginfo_usrloc_cb(): '88835677220000(a)X.X.X.X (location)' Not found in usrloc
So I took a look over usrloc and I found that the callbacks are been
called after insert in mem but before insert on DB
when you set DB_ONLY.
> int insert_ucontact(urecord_t* _r, str* _contact, ucontact_info_t* _ci, ucontact_t** _c)
> {
> if ( ((*_c)=mem_insert_ucontact(_r, _contact, _ci)) == 0) {
> LM_ERR("failed to insert contact\n");
> return -1;
> }
>
> if (exists_ulcb_type(UL_CONTACT_INSERT)) {
> run_ul_callbacks( UL_CONTACT_INSERT, *_c);
> }
>
> if (db_mode == WRITE_THROUGH || db_mode==DB_ONLY) {
> if (db_insert_ucontact(*_c) < 0) {
> LM_ERR("failed to insert in database\n");
> return -1;
> } else {
> (*_c)->state = CS_SYNC;
> }
> }
>
> return 0;
> }
This happens on update too:
> int update_ucontact(struct urecord* _r, ucontact_t* _c, ucontact_info_t* _ci)
> {
> int res;
>
> /* we have to update memory in any case, but database directly
> * only in db_mode 1 */
> if (mem_update_ucontact( _c, _ci) < 0) {
> LM_ERR("failed to update memory\n");
> return -1;
> }
>
> /* run callbacks for UPDATE event */
> if (exists_ulcb_type(UL_CONTACT_UPDATE))
> {
> LM_DBG("exists callback for type= UL_CONTACT_UPDATE\n");
> run_ul_callbacks( UL_CONTACT_UPDATE, _c);
> }
>
> if (_r && db_mode!=DB_ONLY)
> update_contact_pos( _r, _c);
>
> st_update_ucontact(_c);
>
> if (db_mode == WRITE_THROUGH || db_mode==DB_ONLY) {
> if (ul_db_update_as_insert)
> res = db_insert_ucontact(_c);
> else
> res = db_update_ucontact(_c);
>
> if (res < 0) {
> LM_ERR("failed to update database\n");
> return -1;
> } else {
> _c->state = CS_SYNC;
> }
> }
> return 0;
> }
So I would say that DB_ONLY should be honored here before calling the
callbacks
i saw these kind of error messages in syslog:
May 20 00:32:56 proxy /usr/bin/sip-proxy[27601]: ERROR: db_mysql [km_dbase.c:123]: db_mysql_submit_query(): driver error on query: Lost connection to MySQL server during query
May 20 00:32:56 proxy /usr/bin/sip-proxy[27601]: ERROR: db_mysql [km_dbase.c:145]: db_mysql_async_exec_task(): failed to execute query on async worker
it would be nice of the error message would tell which query was in
question.
-- juha
This adds a parameter to allow users to disable the delete queries in the usrloc module. This is mainly for problems due to the differences between how a relational DB and Cassandra work. If the schema for Cassandra is created in certain ways a delete query isn't required to keep the data clean.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/165
-- Commit Summary --
* Add option to disable delete queries in usrloc module.
-- File Changes --
M modules/usrloc/ucontact.c (16)
M modules/usrloc/udomain.c (4)
M modules/usrloc/ul_mod.c (2)
M modules/usrloc/ul_mod.h (1)
M modules/usrloc/urecord.c (8)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/165.patchhttps://github.com/kamailio/kamailio/pull/165.diff
---
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/165