Index: dbmod.scm ================================================================== --- dbmod.scm +++ dbmod.scm @@ -252,16 +252,20 @@ (if ((if (eq? syncdir 'todisk) < >) ;; use less than for todisk, greater than for from disk (file-modification-time tmpdb) (file-modification-time dbfullname)) (debug:print 4 *default-log-port* "Skipping sync, "tmpdb" older than "dbfullname) (if synclock-mod-time - (if (< (- (current-seconds) synclock-mod-time) 20) ;; something wrong with sync, remove file + (if (> (- (current-seconds) synclock-mod-time) 20) ;; something wrong with sync, remove file (begin (handle-exceptions exn #f - (delete-file synclock-file)) + (begin + (debug:print 0 *default-log-port* "Sync lock file " synclock-file "is older than 20 seconds (" synclock-mod-time " seconds). Removing it") + (delete-file synclock-file) + ) + ) (thethread)) (debug:print 0 *default-log-port* "Skipping sync, lockfile "synclock-file" found.")) (thethread))))))) ;; (dbmod:sync-tables tables #f db cachedb) ;; @@ -621,21 +625,24 @@ (stmt3 (conc "UPDATE "table" SET ("no-id-fields-str") = ("questionmarks") WHERE id=?;")) (start-ms (current-milliseconds))) (debug:print 0 *default-log-port* "stmt3="stmt3) (if (sqlite3:auto-committing? dbh1) (begin - (sqlite3:with-transaction - dbh1 - (lambda () - (sqlite3:execute dbh1 stmt1) ;; get all new rows + (handle-exceptions + exn + (debug:print 0 *default-log-port* "Transaction update of "table" failed.") + (sqlite3:with-transaction + dbh1 + (lambda () + (sqlite3:execute dbh1 stmt1) ;; get all new rows #;(if (member "last_update" fields) (sqlite3:execute dbh1 stmt8)) ;; get all updated rows ;; (sqlite3:execute dbh stmt5) ;; (sqlite3:execute dbh stmt4) ;; if it worked this would be better for incremental up ;; (sqlite3:execute dbh stmt6) - )) + ))) (debug:print 0 *default-log-port* "Synced table "table " in "(- (current-milliseconds) start-ms)"ms")) (debug:print 0 *default-log-port* "Skipping sync of table "table" due to transaction in flight.")))) table-names) (sqlite3:execute dbh1 "DETACH auxdb;"))))