Browse code

dialog: add parameter to configure synchronisation of all dialog states to DB

- add parameter to configure synchronisation of all dialog states to DB
- new parameter update_all_states added to module interface
- activated by default to provide correct failover behaviour for users
- really large installation should test it and consider the load trade-off

Henning Westerholt authored on 12/06/2020 08:21:20
Showing 3 changed files
... ...
@@ -114,6 +114,7 @@ int dlg_noack_timeout = 60;
114 114
 int dlg_end_timeout = 300;
115 115
 
116 116
 int dlg_enable_dmq = 0;
117
+int dlg_update_all_states = 1;
117 118
 
118 119
 int dlg_event_rt[DLG_EVENTRT_MAX];
119 120
 str dlg_event_callback = STR_NULL;
... ...
@@ -327,6 +328,7 @@ static param_export_t mod_params[]={
327 328
 	{ "h_id_start",            PARAM_INT, &dlg_h_id_start           },
328 329
 	{ "h_id_step",             PARAM_INT, &dlg_h_id_step            },
329 330
 	{ "keep_proxy_rr",         INT_PARAM, &dlg_keep_proxy_rr        },
331
+	{ "update_all_states",     INT_PARAM, &dlg_update_all_states    },
330 332
 	{ 0,0,0 }
331 333
 };
332 334
 
... ...
@@ -81,6 +81,7 @@ static db1_con_t* dialog_db_handle    = 0; /* database connection handle */
81 81
 static db_func_t dialog_dbf;
82 82
 
83 83
 extern int dlg_enable_stats;
84
+extern int dlg_update_all_states;
84 85
 extern int dlg_h_id_start;
85 86
 extern int dlg_h_id_step;
86 87
 
... ...
@@ -815,7 +816,7 @@ int update_dialog_dbinfo_unsafe(struct dlg_cell * cell)
815 816
 			&sflags_column, /*18*/     &toroute_name_column, /*19*/ &req_uri_column, /*20*/
816 817
 			&xdata_column, /*21*/      &iflags_column  /*22*/ };
817 818
 
818
-	if(cell->state<DLG_STATE_EARLY || cell->state==DLG_STATE_DELETED) {
819
+	if((dlg_update_all_states == 0) && (cell->state<DLG_STATE_EARLY || cell->state==DLG_STATE_DELETED)) {
819 820
 		LM_DBG("not storing dlg in db during initial or deleted states\n");
820 821
 		return 0;
821 822
 	}
... ...
@@ -82,7 +82,8 @@
82 82
 			<para><emphasis>5</emphasis> : Deleted dialog</para>
83 83
 		</listitem>
84 84
 	</itemizedlist>
85
-	<para>The early and deleted dialog states are not updated in database storage.
85
+	<para>The early and deleted dialog states are updated in database storage,
86
+	unless deactivated with the <emphasis>update_all_states</emphasis> parameter.
86 87
 	</para>
87 88
 	</section>
88 89
 
... ...
@@ -1640,6 +1641,39 @@ modparam("dialog", "keep_proxy_rr", 1)
1640 1641
 </programlisting>
1641 1642
 		</example>
1642 1643
 	</section>
1644
+
1645
+	<section id="dialog.p.update_all_states">
1646
+		<title><varname>update_all_states</varname> (string)</title>
1647
+		<para>
1648
+			When enabled the dialog modules will also synchronize the
1649
+			early and deleted dialog states to the database. This is
1650
+			useful in failover situations, but of course will generate
1651
+			more load to the database from this module.
1652
+		</para>
1653
+		<para>
1654
+			Valid values are:
1655
+		</para>
1656
+		<itemizedlist>
1657
+			<listitem><para>
1658
+				<emphasis>0</emphasis> - Don't synchronize early and deleted dialogs
1659
+			</para></listitem>
1660
+			<listitem><para>
1661
+				<emphasis>1</emphasis> - Synchronize early and deleted dialogs
1662
+			</para></listitem>
1663
+		</itemizedlist>
1664
+		<emphasis>
1665
+			Default value is <quote>1</quote>.
1666
+		</emphasis>
1667
+		<example>
1668
+		<title>Set <varname>update_all_states</varname> parameter</title>
1669
+		<programlisting format="linespecific">
1670
+...
1671
+modparam("dialog", "update_all_states", 1)
1672
+...
1673
+</programlisting>
1674
+		</example>
1675
+	</section>
1676
+
1643 1677
 	</section>
1644 1678
 
1645 1679
 	<section>