Parcourir la source

modules_k/rls: Updated module documentation and changed use of BEGIN/COMMIT so it only happens in database only mode

Peter Dunkley il y a 13 ans
Parent
commit
d5b8c4f909
4 fichiers modifiés avec 44 ajouts et 12 suppressions
  1. 9 0
      modules_k/rls/README
  2. 11 0
      modules_k/rls/doc/rls_admin.xml
  3. 12 6
      modules_k/rls/notify.c
  4. 12 6
      modules_k/rls/resource_notify.c

+ 9 - 0
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
    in a database, allowing scalability at the expense of speed. Mode 1 is
    reserved.
    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”
    Default value is “0”
 
 
    Example 1.4. Set db_mode parameter
    Example 1.4. Set db_mode parameter

+ 11 - 0
modules_k/rls/doc/rls_admin.xml

@@ -175,6 +175,17 @@ modparam("rls", "xcap_db_url", "&exampledb;")
 		Mode 1 is reserved.
 		Mode 1 is reserved.
 		</para>
 		</para>
 		<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>	Default value is <quote>0</quote> 	
 		</emphasis>
 		</emphasis>
 		</para>
 		</para>

+ 12 - 6
modules_k/rls/notify.c

@@ -128,10 +128,13 @@ int send_full_notify(subs_t* subs, xmlNodePtr rl_node, str* rl_uri,
 		goto error;
 		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,
 	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;
 		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);
 	xmlFree(rlmi_cont->s);

+ 12 - 6
modules_k/rls/resource_notify.c

@@ -1037,10 +1037,13 @@ static void timer_send_update_notifies(int round)
 		goto done;
 		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,
 	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;
 		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,
 	send_notifies(result, did_col, resource_uri_col, auth_state_col, reason_col,