[chronojump] SQL close safer. Allows big open/close actions. Added stress tests.



commit bf0eeb099ff0011237debe134b764ce09b500080
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jul 28 02:47:56 2015 +0200

    SQL close safer. Allows big open/close actions. Added stress tests.

 glade/chronojump.glade |   90 ++++++++++++++++++++++++++++++++++++++++++++++--
 src/gui/chronojump.cs  |   16 ++++++++
 src/sqlite/main.cs     |   11 +++++-
 3 files changed, 112 insertions(+), 5 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index f03ca5c..897f85c 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -445,6 +445,30 @@
                         <signal name="activate" handler="on_menuitem_presentation_activate" swapped="no"/>
                       </widget>
                     </child>
+                    <child>
+                      <widget class="GtkSeparatorMenuItem" id="separator4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkMenuItem" id="menuitem_SQL_stress_test_short">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">SQL stress test short</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="on_menuitem_SQL_stress_test_short_activate" 
swapped="no"/>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkMenuItem" id="menuitem_SQL_stress_test_long">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">SQL stress test long</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="on_menuitem_SQL_stress_test_long_activate" 
swapped="no"/>
+                      </widget>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -7586,6 +7610,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -8967,6 +8994,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -9989,6 +10019,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -21464,6 +21497,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -22385,6 +22421,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -23798,6 +23837,9 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -24268,6 +24310,9 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -35573,6 +35618,24 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -37220,6 +37283,18 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -38599,9 +38674,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                       <placeholder/>
                                     </child>
                                     <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
                                       <widget class="GtkLabel" id="label218">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -39522,6 +39594,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                     <child>
                                       <placeholder/>
                                     </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </widget>
                                 </child>
                               </widget>
@@ -43230,6 +43305,9 @@ It starts before and arrives there with some speed.</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -43815,6 +43893,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -44415,6 +44496,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 021841e..d670050 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -6211,6 +6211,22 @@ LogB.Debug("X");
                                "Temporarily Disabled");
                */
        }
+       
+       private void on_menuitem_SQL_stress_test_short_activate (object o, EventArgs args) {
+               sql_stress_test(1000);
+       }
+       private void on_menuitem_SQL_stress_test_long_activate (object o, EventArgs args) {
+               sql_stress_test(4000);
+       }
+       private void sql_stress_test (int times) {
+               //trying if new way of Sqlite.Close disposing dbcmd fixes problems when multiple open / close 
connection
+               for(int i=0 ; i < times; i++) {
+                       LogB.Debug (" i=" + i.ToString());
+                       LogB.Debug(SqlitePreferences.Select("databaseVersion"));
+               }
+                       
+               new DialogMessage(Constants.MessageTypes.INFO, "SQL test successfull!" + "\n\n" + "Done " + 
times + " times.");
+       }
 
 
        private void on_about1_activate (object o, EventArgs args) {
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 028a930..c1ee5a3 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -101,20 +101,27 @@ class Sqlite
                        LogB.SQL("-- catched --");
 
                        LogB.SQLoff();
+                       dbcmd.Dispose(); //this seems critical in multiple open/close SQL
                        dbcon.Close();
-                       
+                       GC.Collect();
+                       dbcmd = dbcon.CreateCommand();
+
+                       LogB.Warning(" going to open ");
                        LogB.SQLon();
                        dbcon.Open();
                        
                        LogB.SQL("-- end of catched --");
                }
-
+               
                IsOpened = true;
        }
        public static void Close()
        {
                LogB.SQLoff();
+               dbcmd.Dispose(); //this seems critical in multiple open/close SQL
                dbcon.Close();
+               GC.Collect();
+               dbcmd = dbcon.CreateCommand();
                
                IsOpened = false;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]