Module: sip-router Branch: master Commit: d5b8c4f9091646597341e0d8dc08e2c3930f713a URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d5b8c4f9...
Author: Peter Dunkley peter.dunkley@crocodile-rcs.com Committer: Peter Dunkley peter.dunkley@crocodile-rcs.com Date: Fri Apr 20 16:11:48 2012 +0100
modules_k/rls: Updated module documentation and changed use of BEGIN/COMMIT so it only happens in database only mode
---
modules_k/rls/README | 9 +++++++++ modules_k/rls/doc/rls_admin.xml | 11 +++++++++++ modules_k/rls/notify.c | 18 ++++++++++++------ modules_k/rls/resource_notify.c | 18 ++++++++++++------ 4 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/modules_k/rls/README b/modules_k/rls/README index df3a879..40ebeae 100644 --- a/modules_k/rls/README +++ b/modules_k/rls/README @@ -259,6 +259,15 @@ modparam("rls", "xcap_db_url", "dbdriver://username:password@dbhost/dbname") in a database, allowing scalability at the expense of speed. Mode 1 is reserved.
+ The RLS modules uses SQL BEGIN/COMMIT statements around related sets of + database queries to make sure they are a single transaction when + database only mode is used. This means you should ensure that automatic + retries/reconnects are disabled for your database (for example, by + setting the retries parameter for db_mysql or db_postgres to 0). This + is needed because if the connection fails any unCOMMITed queries will + be automatically rolled back by the database. This means that automatic + retries could result in data inconsistencies. + Default value is “0”
Example 1.4. Set db_mode parameter diff --git a/modules_k/rls/doc/rls_admin.xml b/modules_k/rls/doc/rls_admin.xml index 0669b70..db03b9f 100644 --- a/modules_k/rls/doc/rls_admin.xml +++ b/modules_k/rls/doc/rls_admin.xml @@ -175,6 +175,17 @@ modparam("rls", "xcap_db_url", "&exampledb;") Mode 1 is reserved. </para> <para> + The RLS modules uses SQL BEGIN/COMMIT statements around related + sets of database queries to make sure they are a single + transaction when database only mode is used. This means you + should ensure that automatic retries/reconnects are disabled + for your database (for example, by setting the retries + parameter for db_mysql or db_postgres to 0). This is needed + because if the connection fails any unCOMMITed queries will + be automatically rolled back by the database. This means that + automatic retries could result in data inconsistencies. + </para> + <para> <emphasis> Default value is <quote>0</quote> </emphasis> </para> diff --git a/modules_k/rls/notify.c b/modules_k/rls/notify.c index 1836808..fbb7e17 100644 --- a/modules_k/rls/notify.c +++ b/modules_k/rls/notify.c @@ -128,10 +128,13 @@ int send_full_notify(subs_t* subs, xmlNodePtr rl_node, str* rl_uri, goto error; }
- if (db_begin(&rlpres_dbf, rlpres_db) < 0) + if (dbmode == RLS_DB_ONLY) { - LM_ERR("in BEGIN\n"); - goto error; + if (db_begin(&rlpres_dbf, rlpres_db) < 0) + { + LM_ERR("in BEGIN\n"); + goto error; + } }
if(rlpres_dbf.query(rlpres_db, query_cols, 0, query_vals, result_cols, @@ -263,10 +266,13 @@ int send_full_notify(subs_t* subs, xmlNodePtr rl_node, str* rl_uri, goto error; }
- if (db_commit(&rlpres_dbf, rlpres_db) < 0) + if (dbmode == RLS_DB_ONLY) { - LM_ERR("in COMMIT\n"); - goto error; + if (db_commit(&rlpres_dbf, rlpres_db) < 0) + { + LM_ERR("in COMMIT\n"); + goto error; + } }
xmlFree(rlmi_cont->s); diff --git a/modules_k/rls/resource_notify.c b/modules_k/rls/resource_notify.c index 87ce806..910b098 100644 --- a/modules_k/rls/resource_notify.c +++ b/modules_k/rls/resource_notify.c @@ -1037,10 +1037,13 @@ static void timer_send_update_notifies(int round) goto done; }
- if (db_begin(&rlpres_dbf, rlpres_db) < 0) + if (dbmode == RLS_DB_ONLY) { - LM_ERR("in BEGIN\n"); - goto error; + if (db_begin(&rlpres_dbf, rlpres_db) < 0) + { + LM_ERR("in BEGIN\n"); + goto error; + } }
if(rlpres_dbf.query(rlpres_db, query_cols, 0, query_vals, result_cols, @@ -1060,10 +1063,13 @@ static void timer_send_update_notifies(int round) goto error; }
- if (db_commit(&rlpres_dbf, rlpres_db) < 0) + if (dbmode == RLS_DB_ONLY) { - LM_ERR("in COMMIT\n"); - goto error; + if (db_commit(&rlpres_dbf, rlpres_db) < 0) + { + LM_ERR("in COMMIT\n"); + goto error; + } }
send_notifies(result, did_col, resource_uri_col, auth_state_col, reason_col,