Megatest

Check-in [c47b41a610]
Login
Overview
Comment:wip
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.6584-nanomsg
Files: files | file ages | folders
SHA1: c47b41a610c72248abe5e45c167c4859226f3153
User & Date: matt on 2021-06-12 04:25:16
Other Links: branch diff | manifest | tags
Context
2021-06-14
00:21
wip check-in: 8f1a13e4de user: matt tags: v1.6584-nanomsg
2021-06-12
04:25
wip check-in: c47b41a610 user: matt tags: v1.6584-nanomsg
2021-06-09
09:02
wip check-in: 29dd9489e5 user: matt tags: v1.6584-nanomsg
Changes

Modified dbmod.scm from [4c56626e6f] to [2aad81d989].

419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
(define (db:sync-inmem->disk dbstruct apath dbfile #!key (force-sync #f))
  (let* ((dbdat       (db:get-dbdat dbstruct apath dbfile))
	 (db          (dbr:dbdat-db dbdat))
	 (inmem       (dbr:dbdat-inmem dbdat))
	 (start-t     (current-seconds))
	 (last-update (dbr:dbdat-last-write dbdat))
	 (last-sync   (dbr:dbdat-last-sync dbdat)))
    (debug:print-info 4 *default-log-port* "Syncing for dbfile: " dbfile)
    (mutex-lock! *db-multi-sync-mutex*)
    (let* ((update_info (cons (if force-sync 0 last-update) "last_update"))
    	   (need-sync   (or force-sync (>= last-update last-sync))))
       (if need-sync
	  (db:sync-tables (db:sync-all-tables-list) update_info inmem db)
	  (debug:print 0 *default-log-port* "Skipping sync as nothing touched.")))
    (dbr:dbdat-last-sync-set! dbdat start-t)







|







419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
(define (db:sync-inmem->disk dbstruct apath dbfile #!key (force-sync #f))
  (let* ((dbdat       (db:get-dbdat dbstruct apath dbfile))
	 (db          (dbr:dbdat-db dbdat))
	 (inmem       (dbr:dbdat-inmem dbdat))
	 (start-t     (current-seconds))
	 (last-update (dbr:dbdat-last-write dbdat))
	 (last-sync   (dbr:dbdat-last-sync dbdat)))
    (debug:print-info 0 *default-log-port* "Syncing for dbfile: " dbfile)
    (mutex-lock! *db-multi-sync-mutex*)
    (let* ((update_info (cons (if force-sync 0 last-update) "last_update"))
    	   (need-sync   (or force-sync (>= last-update last-sync))))
       (if need-sync
	  (db:sync-tables (db:sync-all-tables-list) update_info inmem db)
	  (debug:print 0 *default-log-port* "Skipping sync as nothing touched.")))
    (dbr:dbdat-last-sync-set! dbdat start-t)

Modified launchmod.scm from [6c7ea9f92b] to [60133fcc07].

2287
2288
2289
2290
2291
2292
2293
2294
2295


2296

2297
2298
2299
2300
2301
2302
2303
  (let* ((start-time (current-seconds))
	 (am-server  (args:get-arg "-server"))
	 (dbfile     (args:get-arg "-db"))
	 (apath      *toppath*))
    (let loop ()
      (thread-sleep! 5) ;; add control / setting for this
      (if am-server
	  (if (not  *dbstruct-db*)
	      (loop)


	      (db:sync-inmem->disk *dbstruct-db* *toppath* dbfile))))))

  
;; 
;; (let ((dbstruct 
;; 	    (debug:print-info 13 *default-log-port* "after db:setup with dbstruct=" dbstruct)
;; 	    (cond
;; 	     ((dbr:dbstruct-read-only dbstruct)
;; 	      (debug:print-info 13 *default-log-port* "loading read-only watchdog")







|

>
>
|
>







2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
  (let* ((start-time (current-seconds))
	 (am-server  (args:get-arg "-server"))
	 (dbfile     (args:get-arg "-db"))
	 (apath      *toppath*))
    (let loop ()
      (thread-sleep! 5) ;; add control / setting for this
      (if am-server
	  (if (not  *dbstruct-db*) ;; skip syncing until db is setup
	      (loop)
	      (begin
		(debug:print-info 0 *default-log-port* "syncing "apath" "dbfile" at "(current-seconds))
		(db:sync-inmem->disk *dbstruct-db* apath dbfile)
		(loop)))))))
  
;; 
;; (let ((dbstruct 
;; 	    (debug:print-info 13 *default-log-port* "after db:setup with dbstruct=" dbstruct)
;; 	    (cond
;; 	     ((dbr:dbstruct-read-only dbstruct)
;; 	      (debug:print-info 13 *default-log-port* "loading read-only watchdog")

Modified rmtmod.scm from [d9cd48e79d] to [e913ee1afe].

1450
1451
1452
1453
1454
1455
1456
1457
1458

1459
1460


1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471




1472
1473
1474
1475
1476
1477
1478






1479
1480
1481
1482
1483

1484
1485
1486
1487
1488
1489
1490
    (debug:print-info 4 *default-log-port* "starting exit process, finalizing databases.")
    (if (and no-hurry (debug:debug-mode 18))
	(rmt:print-db-stats))
    (let ((th1 (make-thread (lambda () ;; thread for cleaning up, give it five seconds
                              (if *server-info*
				  (let ((dbfile   (servdat-dbfile *server-info*)))
				    (if dbfile
					(begin


					  ;; do a final sync here
					  


					  (if (string-match ".*/main.db$" dbfile)
					      (let ((pkt-file (conc (get-pkts-dir *toppath*)
							"/" (servdat-uuid *server-info*)
							".pkt")))
						(debug:print-info 0 *default-log-port* "removing pkt "pkt-file)
						(delete-file* pkt-file)
						(debug:print-info 0 *default-log-port* "Releasing lock for "dbfile)
						(db:with-lock-db (servdat-dbfile *server-info*)
								 (lambda (dbh dbfile)
								   (db:release-lock dbh dbfile))))
					      (let* ((sdat *server-info*)) ;; we have a run-id server




						(rmt:send-receive-real *rmt:remote* *toppath*
								       (db:run-id->dbname #f)
								       'deregister-server
								       `(,(servdat-uuid sdat)
									 ,(current-process-id)
									 ,(servdat-host sdat)   ;; iface
									 ,(servdat-port sdat)))))))))






			      ;; (if *dbstruct-db* (db:close-all *dbstruct-db*)) ;; one second allocated
			      (if (bdat-task-db *bdat*)    ;; TODO: Check that this is correct for task db
				  (let ((db (cdr (bdat-task-db *bdat*))))
				    (if (sqlite3:database? db)
					(begin

					  (sqlite3:interrupt! db)
					  (sqlite3:finalize! db #t)
					  (bdat-task-db-set! *bdat* #f)))))
                              #;(http-client#close-idle-connections!)
                              (if (not (eq? *default-log-port* (current-error-port)))
                                  (close-output-port *default-log-port*))
			      (set! *default-log-port* (current-error-port))) "Cleanup db exit thread"))







|
|
>

|
>
>
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
|
|
|
|
|
|
|
>
>
>
>
>
>





>







1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
    (debug:print-info 4 *default-log-port* "starting exit process, finalizing databases.")
    (if (and no-hurry (debug:debug-mode 18))
	(rmt:print-db-stats))
    (let ((th1 (make-thread (lambda () ;; thread for cleaning up, give it five seconds
                              (if *server-info*
				  (let ((dbfile   (servdat-dbfile *server-info*)))
				    (if dbfile
					(let* ((am-server  (args:get-arg "-server"))
					       (dbfile     (args:get-arg "-db"))
					       (apath      *toppath*))
					  ;; do a final sync here
					  (debug:print-info 0 *default-log-port* "Doing final sync for "apath" "dbfile" at "(current-seconds))
					  (db:sync-inmem->disk *dbstruct-db* apath dbfile)
					  (if am-server
					      (if (string-match ".*/main.db$" dbfile)
						  (let ((pkt-file (conc (get-pkts-dir *toppath*)
									"/" (servdat-uuid *server-info*)
									".pkt")))
						    (debug:print-info 0 *default-log-port* "removing pkt "pkt-file)
						    (delete-file* pkt-file)
						    (debug:print-info 0 *default-log-port* "Releasing lock for "dbfile)
						    (db:with-lock-db (servdat-dbfile *server-info*)
								     (lambda (dbh dbfile)
								       (db:release-lock dbh dbfile))))
						  (let* ((sdat *server-info*) ;; we have a run-id server
							 (host (servdat-host sdat))
							 (port (servdat-port sdat))
							 (uuid (servdat-uuid sdat)))
						    (debug:print-info 0 *default-log-port* "deregistering server "host":"port" with uuid "uuid)
						    #;(rmt:send-receive-real *rmt:remote* *toppath*
									   (db:run-id->dbname #f)
									   'deregister-server
									   `(,(servdat-uuid sdat)
									     ,(current-process-id)
									     ,(servdat-host sdat)   ;; iface
									     ,(servdat-port sdat)))
						    (rmt:send-receive 'deregister-server #f
								      `(,(servdat-uuid sdat)
									,(current-process-id)
									,(servdat-host sdat)   ;; iface
									,(servdat-port sdat)))
						    )))))))
			      ;; (if *dbstruct-db* (db:close-all *dbstruct-db*)) ;; one second allocated
			      (if (bdat-task-db *bdat*)    ;; TODO: Check that this is correct for task db
				  (let ((db (cdr (bdat-task-db *bdat*))))
				    (if (sqlite3:database? db)
					(begin
					  (debug:print-info 0 *default-log-port* "Closing down task db "db)
					  (sqlite3:interrupt! db)
					  (sqlite3:finalize! db #t)
					  (bdat-task-db-set! *bdat* #f)))))
                              #;(http-client#close-idle-connections!)
                              (if (not (eq? *default-log-port* (current-error-port)))
                                  (close-output-port *default-log-port*))
			      (set! *default-log-port* (current-error-port))) "Cleanup db exit thread"))

Modified tests/unittests/server.scm from [fecd3b071a] to [c951dcac9c].

62
63
64
65
66
67
68




69
70
71




72
73
74
75
76
77
78

(thread-sleep! 2)
(test #f #t (list? (rmt:general-open-connection *rmt:remote* *toppath* ".db/2.db")))

(test #f '("SYSTEM" "RELEASE") (rmt:get-keys))
(test #f 1 (rmt:send-receive 'register-run #f (list keyvals "run1" "new" "n/a" "justme" #f)))
(print "Got here.")




(test #t 1 (rmt:send-receive 'register-run 1 (list keyvals "run2" "new" "n/a" "justme" #f)))

(test #f 1 (rmt:register-run keyvals "run2" "new" "n/a" "justme" #f))





;; (delete-file* "logs/1.log")
;; (define run-id 1)

;; (test "setup for run" #t (begin (launch:setup)
;;  				(string? (getenv "MT_RUN_AREA_HOME"))))
;; 







>
>
>
>
|


>
>
>
>







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

(thread-sleep! 2)
(test #f #t (list? (rmt:general-open-connection *rmt:remote* *toppath* ".db/2.db")))

(test #f '("SYSTEM" "RELEASE") (rmt:get-keys))
(test #f 1 (rmt:send-receive 'register-run #f (list keyvals "run1" "new" "n/a" "justme" #f)))
(print "Got here.")
(trace
 rmt:send-receive
 rmt:send-receive-real
 )
(test #f 1 (rmt:send-receive 'register-run 1 (list keyvals "run1" "new" "n/a" "justme" #f)))

(test #f 1 (rmt:register-run keyvals "run2" "new" "n/a" "justme" #f))

(thread-sleep! 5)
(exit)


;; (delete-file* "logs/1.log")
;; (define run-id 1)

;; (test "setup for run" #t (begin (launch:setup)
;;  				(string? (getenv "MT_RUN_AREA_HOME"))))
;;