I have created a patch for 1.34. It decreases the time to wait for 1/4 second for new file checks and sets the timeout to 60 seconds.

This is has reduced the db timeout to a minimum.

---PATCH STARTS-----


--- db.c    2013-01-18 06:27:58.603983473 -0800
+++ db.c.CH    2013-02-04 15:35:08.028835058 -0800
@@ -37,7 +37,14 @@

 static int get_dblock_timeout()
 {
-    return getpid() % 7 + 12;
+/*
+   Chuck Handshy 01/17/2013
+   Increased the 12 second min to 60 second min timeout for sqlite db.
+   Chuck Handshy 02/04/2013
+ After USLEEP was added to reduce wait down to 1/4 second 60 now gets us 15 again.
+   Uping timeout to 240 to compensate for 1/4 second sleep.
+*/
+    return getpid() % 7 + 240;
 }


@@ -203,7 +210,8 @@
         if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
         csync_debug(2, "Database is busy, sleeping a sec.\n");
-        sleep(1);
+        /* Decreasing sleep to 1/4 a second */
+        usleep(250000);
     }

     if ( rc != SQLITE_OK && err )
@@ -235,7 +243,8 @@
         if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
         csync_debug(2, "Database is busy, sleeping a sec.\n");
-        sleep(1);
+        /* Decreasing sleep to 1/4 a second */
+        usleep(250000);
     }

     if ( rc != SQLITE_OK && err )
@@ -258,7 +267,8 @@
         if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
         csync_debug(2, "Database is busy, sleeping a sec.\n");
-        sleep(1);
+        /* Decreasing sleep to 1/4 a second */
+        usleep(250000);
     }

     if ( rc != SQLITE_OK && rc != SQLITE_ROW &&
@@ -280,7 +290,8 @@
         if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
         csync_debug(2, "Database is busy, sleeping a sec.\n");
-        sleep(1);
+        /* Decreasing sleep to 1/4 a second */
+        usleep(250000);
     }

     if ( rc != SQLITE_OK && err )

----PATCH ENDS---

--- db.c        2013-01-18 06:27:58.603983473 -0800
+++ db.c.CH     2013-02-04 15:35:08.028835058 -0800
@@ -37,7 +37,14 @@
 
 static int get_dblock_timeout()
 {
-       return getpid() % 7 + 12;
+/* 
+   Chuck Handshy 01/17/2013
+   Increased the 12 second min to 60 second min timeout for sqlite db.
+   Chuck Handshy 02/04/2013
+   After USLEEP was added to reduce wait down to 1/4 second 60 now gets us 15 
again.
+   Uping timeout to 240 to compensate for 1/4 second sleep.
+*/
+       return getpid() % 7 + 240;
 }
 
 
@@ -203,7 +210,8 @@
                if ( rc != SQLITE_BUSY ) break;
                if (busyc++ > get_dblock_timeout()) { db = 0; 
csync_fatal(DEADLOCK_MESSAGE); }
                csync_debug(2, "Database is busy, sleeping a sec.\n");
-               sleep(1);
+               /* Decreasing sleep to 1/4 a second */
+               usleep(250000);
        }
 
        if ( rc != SQLITE_OK && err )
@@ -235,7 +243,8 @@
                if ( rc != SQLITE_BUSY ) break;
                if (busyc++ > get_dblock_timeout()) { db = 0; 
csync_fatal(DEADLOCK_MESSAGE); }
                csync_debug(2, "Database is busy, sleeping a sec.\n");
-               sleep(1);
+               /* Decreasing sleep to 1/4 a second */
+               usleep(250000);
        }
 
        if ( rc != SQLITE_OK && err )
@@ -258,7 +267,8 @@
                if ( rc != SQLITE_BUSY ) break;
                if (busyc++ > get_dblock_timeout()) { db = 0; 
csync_fatal(DEADLOCK_MESSAGE); }
                csync_debug(2, "Database is busy, sleeping a sec.\n");
-               sleep(1);
+               /* Decreasing sleep to 1/4 a second */
+               usleep(250000);
        }
 
        if ( rc != SQLITE_OK && rc != SQLITE_ROW &&
@@ -280,7 +290,8 @@
                if ( rc != SQLITE_BUSY ) break;
                if (busyc++ > get_dblock_timeout()) { db = 0; 
csync_fatal(DEADLOCK_MESSAGE); }
                csync_debug(2, "Database is busy, sleeping a sec.\n");
-               sleep(1);
+               /* Decreasing sleep to 1/4 a second */
+               usleep(250000);
        }
 
        if ( rc != SQLITE_OK && err )

_______________________________________________
Csync2 mailing list
Csync2@lists.linbit.com
http://lists.linbit.com/mailman/listinfo/csync2

Reply via email to