Megatest

Check-in [49befe770d]
Login
Overview
Comment:Turned off sync when direct-to-db mode 'none is used
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.80
Files: files | file ages | folders
SHA1: 49befe770d534813ea760fd2819bb30b383c136d
User & Date: matt on 2023-05-13 00:27:09
Other Links: branch diff | manifest | tags
Context
2023-05-13
20:11
key is todisk, not todest. Although todest would be more sensible but the attach sync prevents being sensible. check-in: de7cca3a62 user: matt tags: v1.80
00:27
Turned off sync when direct-to-db mode 'none is used check-in: 49befe770d user: matt tags: v1.80
00:00
Fixed server lock. Noticed sync running from dashboard only - seems wrong. check-in: ac41427eb2 user: matt tags: v1.80
Changes

Modified dbmod.scm from [9e57a3ede2] to [0f5df22242].

95
96
97
98
99
100
101

102

103
104
105
106
107
108
109
95
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110







+
-
+







	 (dbdat     (dbmod:open-db dbstruct run-id (dbfile:db-init-proc)))
	 (dbh       (dbr:dbdat-dbh dbdat)) ;; this will be the inmem handle
	 (dbfile    (dbr:dbdat-dbfile dbdat)))
    ;; if nfs mode do a sync if delta > 2
    (let* ((last-update (dbr:dbstruct-last-update dbstruct))
	   (sync-proc   (dbr:dbstruct-sync-proc dbstruct))
	   (curr-secs   (current-seconds)))
      (if (and (not (eq? (dbfile:cache-method) 'none)) ;; used by dashboard, no need for sync
      (if (> (- curr-secs last-update) 5)
	       (> (- curr-secs last-update) 5))
	  (begin
	    (sync-proc last-update)

	    ;; MOVE THIS CALL TO INSIDE THE sync-proc CALL
	    (dbr:dbstruct-last-update-set! dbstruct curr-secs)
	    )))
    (assert (sqlite3:database? dbh) "FATAL: bad db handle in dbmod:with-db") 
212
213
214
215
216
217
218



219
220
221
222
223
224
225
226
227
228










229
230
231
232
233
234
235
213
214
215
216
217
218
219
220
221
222










223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239







+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+







				       (debug:print 3 *default-log-port* "WARNING: overlapping calls to sync to disk")
				       (let* ((sync-cmd (conc "megatest -db2db -from "tmpdb" -to "dbfullname"&"))
					      (synclock-file (conc dbfullname".sync-lock")))
					 ;; (mutex-lock! *db-with-db-mutex*) ;; this mutex is used when overloaded or during a query that modifies the db
					 ;; (if (eq? (dbfile:cache-method) 'inmem)
					 ;;     (dbmod:sync-gasket tables last-update inmem db
					 ;; 			dbfullname syncdir keys)
					 (if (< (file-modification-time tmpdb)
						(file-modification-time dbfullname))
					     (debug:print 0 *default-log-port* "Skipping sync, "tmpdb" older than "dbfullname)
					 (if (file-exists? synclock-file)
					     (debug:print 0 *default-log-port* "Skipping sync, lockfile "synclock-file" found.")
					     (thread-start! (make-thread
							     (lambda ()
							       (set! *sync-in-progress* #t)
							       (debug:print-info "Running "sync-cmd)
							       (system sync-cmd)
							       ;; (mutex-unlock! *db-with-db-mutex*)
							       ;; (thread-sleep! 0.5) ;; ensure at least 1/2 second down time between sync calls
							       (set! *sync-in-progress* #f)))))
					     (if (file-exists? synclock-file)
						 (debug:print 0 *default-log-port* "Skipping sync, lockfile "synclock-file" found.")
						 (thread-start! (make-thread
								 (lambda ()
								   (set! *sync-in-progress* #t)
								   (debug:print-info "Running "sync-cmd)
								   (system sync-cmd)
								   ;; (mutex-unlock! *db-with-db-mutex*)
								   ;; (thread-sleep! 0.5) ;; ensure at least 1/2 second down time between sync calls
								   (set! *sync-in-progress* #f))))))
					 ))))
    ;; (dbmod:sync-tables tables #f db inmem)
    ;; (if db
    (dbmod:sync-gasket tables #f inmem db dbfullname 'fromdest keys) ;; ) ;; load into inmem
    (dbr:dbstruct-last-update-set! dbstruct (current-seconds)) ;; should this be offset back in time by one second?
    dbstruct))