Overview
Comment: | Merged fork |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.80-processes |
Files: | files | file ages | folders |
SHA1: |
35feb6b8dbfbafbf4459ef6136c2af4e |
User & Date: | mrwellan on 2023-09-29 08:17:16 |
Other Links: | branch diff | manifest | tags |
Context
2023-10-01
| ||
19:23 | wip check-in: b31ebcea09 user: matt tags: v1.80-processes | |
2023-09-29
| ||
08:17 | Merged fork check-in: 35feb6b8db user: mrwellan tags: v1.80-processes | |
08:07 | Added beginnings of processes table in no-sync check-in: 923cf91611 user: matt tags: v1.80-processes | |
2023-09-25
| ||
19:04 | Added sync file age checking to -db2db check-in: 72065b6c5e user: mmgraham tags: v1.80 | |
Changes
Modified dbmod.scm from [88b05b876a] to [2faba88ece].
︙ | ︙ | |||
250 251 252 253 254 255 256 | (system sync-cmd)) (set! *sync-in-progress* #f))))))) (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 | | > > | > > | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | (system sync-cmd)) (set! *sync-in-progress* #f))))))) (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 (begin (handle-exceptions exn #f (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) ;; (thread-sleep! 1) ;; let things settle before syncing in needed data (dbmod:sync-gasket tables #f cachedb db dbfullname 'fromdest keys) ;; ) ;; load into cachedb |
︙ | ︙ | |||
619 620 621 622 623 624 625 | (stmt1 (conc "SELECT MAX(last_update) FROM "table";")) ;; use the highest last_update as your time reference (stmt2 (conc "SELECT no-id-fields-str FROM "table" WHERE last_update>?;")) (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 | > > > | | | | | | 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | (stmt1 (conc "SELECT MAX(last_update) FROM "table";")) ;; use the highest last_update as your time reference (stmt2 (conc "SELECT no-id-fields-str FROM "table" WHERE last_update>?;")) (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 (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;")))) |
︙ | ︙ |
Modified megatest-version.scm from [db910095d8] to [5a374d2bf1].
︙ | ︙ | |||
16 17 18 19 20 21 22 | ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; Always use two or four digit decimal ;; 1.01, 1.02...1.10,1.11,1.1101 ... 1.99,2.00.. ;; (declare (unit megatest-version)) | | | 16 17 18 19 20 21 22 23 | ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; Always use two or four digit decimal ;; 1.01, 1.02...1.10,1.11,1.1101 ... 1.99,2.00.. ;; (declare (unit megatest-version)) (define megatest-version 1.8017) |
Modified megatest.scm from [55136b63dd] to [429d7d2934].
︙ | ︙ | |||
979 980 981 982 983 984 985 | ;; a specific Megatest area. Detail are being hashed out and this may change. ;; (if (args:get-arg "-adjutant") (begin (adjutant-run) (set! *didsomething* #t))) | | > > > > > > > > > > > > | > > > | < > > | < > | < > > > > > > > > > > | > > > > > | < > > > > > > > > > > | | > > > | | > | > > > > > > > > | > > > > > > | > > > > > | < < > | < < | | | < | | < > | > > > | > > | < > > > | < < < > > > | > | | < < > > | 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 | ;; a specific Megatest area. Detail are being hashed out and this may change. ;; (if (args:get-arg "-adjutant") (begin (adjutant-run) (set! *didsomething* #t))) (if (args:get-arg "-list-servers") (let* ((tl (launch:setup)) ;; need this to initialize *toppath* (servdir (tt:get-servinfo-dir *toppath*)) (servfiles (glob (conc servdir "/*:*.db"))) (fmtstr "~10a~22a~10a~25a~25a~8a\n") (dbfiles (append (glob (conc *toppath* "/.mtdb/main.db")) (glob (conc *toppath* "/.mtdb/?.db"))(glob (conc *toppath* "/.mtdb/??.db")))) (ttdat (make-tt areapath: *toppath*)) ) (format #t fmtstr "DB" "host:port" "PID" "age" "last mod" "state") (for-each (lambda (dbfile) (let* ( (dbfname (conc (pathname-file dbfile) ".db")) (sfiles (tt:find-server *toppath* dbfname)) ) (for-each (lambda (sfile) (let ( (sinfos (tt:get-server-info-sorted ttdat dbfname)) ) (for-each (lambda (sinfo) (let* ( (db (list-ref sinfo 5)) (pid (list-ref sinfo 4)) (host (list-ref sinfo 0)) (port (list-ref sinfo 1)) (server-id (list-ref sinfo 3)) (age (seconds->hr-min-sec (- (current-seconds) (list-ref sinfo 2)))) (last-mod (seconds->string (list-ref sinfo 2))) (status (system (conc "ssh " host " ps " pid " > /dev/null"))) (state (if (> status 0) "dead" (tt:ping host port server-id 0) )) ) (format #t fmtstr db (conc host ":" port) pid age last-mod state) ) ) sinfos ) ) ) sfiles ) ) ) dbfiles ) (set! *didsomething* #t) (exit) ) ) (if (args:get-arg "-kill-servers") (let* ((tl (launch:setup)) ;; need this to initialize *toppath* (servdir (tt:get-servinfo-dir *toppath*)) (servfiles (glob (conc servdir "/*:*.db"))) (fmtstr "~10a~22a~10a~25a~25a~8a\n") (dbfiles (append (glob (conc *toppath* "/.mtdb/main.db")) (glob (conc *toppath* "/.mtdb/?.db"))(glob (conc *toppath* "/.mtdb/??.db")))) (ttdat (make-tt areapath: *toppath*)) ) (format #t fmtstr "DB" "host:port" "PID" "age" "last mod" "state") (for-each (lambda (dbfile) (let* ( (dbfname (conc (pathname-file dbfile) ".db")) (sfiles (tt:find-server *toppath* dbfname)) ) (for-each (lambda (sfile) (let ( (sinfos (tt:get-server-info-sorted ttdat dbfname)) ) (for-each (lambda (sinfo) (let* ( (db (list-ref sinfo 5)) (pid (list-ref sinfo 4)) (host (list-ref sinfo 0)) (port (list-ref sinfo 1)) (server-id (list-ref sinfo 3)) (age (seconds->hr-min-sec (- (current-seconds) (list-ref sinfo 2)))) (last-mod (seconds->string (list-ref sinfo 2))) (killed (system (conc "ssh " host " kill " pid " > /dev/null"))) (dummy2 (sleep 1)) (state (if (> (system (conc "ssh " host " ps " pid " > /dev/null")) 0) "dead" "alive")) ) (format #t fmtstr db (conc host ":" port) pid age last-mod state) (system (conc "rm " sfile)) ) ) sinfos ) ) ) sfiles ) ) ) dbfiles ) (set! *didsomething* #t) (exit) ) ) ;;====================================================================== ;; Weird special calls that need to run *after* the server has started? ;;====================================================================== (if (args:get-arg "-list-targets") (if (launch:setup) |
︙ | ︙ | |||
2587 2588 2589 2590 2591 2592 2593 | (file-copy src-db dest-db) 1) (let ((res (dbmod:db-to-db-sync src-db dest-db last-update (dbfile:db-init-proc) keys))) (if res (debug:print-info 0 *default-log-port* "Synced " res " records from "src-db" to "dest-db) (debug:print-info 0 *default-log-port* "No sync due to permissions or other issue.")) res)))) | | > > > > > > > > | | > | > > > | 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 | (file-copy src-db dest-db) 1) (let ((res (dbmod:db-to-db-sync src-db dest-db last-update (dbfile:db-init-proc) keys))) (if res (debug:print-info 0 *default-log-port* "Synced " res " records from "src-db" to "dest-db) (debug:print-info 0 *default-log-port* "No sync due to permissions or other issue.")) res)))) (start-time (current-seconds)) (synclock-mod-time (if (file-exists? lockfile) (handle-exceptions exn #f (file-modification-time synclock-file)) #f)) (age (if synclock-mod-time (- (current-seconds) synclock-mod-time) 1000)) ) (if (and src-db dest-db) (if (file-exists? src-db) (if (and (file-exists? lockfile) (< age 20)) (debug:print 0 *default-log-port* "Lock "lockfile" exists, skipping sync...") (begin (dbfile:with-simple-file-lock lockfile (lambda () (let loop ((last-changed (current-seconds)) (last-update 0)) (let* ((changes (handle-exceptions exn (begin (debug:print 0 *default-log-port* "Exception in sync: "(condition->list exn)) (delete-file lockfile) (exit)) (thesync last-update))) (now-time (current-seconds))) (if (and sync-period sync-timeout) ;; (if (and (< (- now-time start-time) 600) ;; hard limit on how long we run for (> sync-timeout (- now-time last-changed))) (begin (if sync-period (thread-sleep! sync-period)) (loop (if (> changes 0) now-time last-changed) now-time)))))))) (debug:print 0 *default-log-port* "Releasing lock file " lockfile) ) ) (debug:print 0 *default-log-port* "No sync due to unreadble or non-existant source file"src-db)) (debug:print 0 *default-log-port* "Usage for -db2db; -to and -from must be specified")) (set! *didsomething* #t))) (if (args:get-arg "-list-test-time") (let* ((toppath (launch:setup))) (task:get-test-times) |
︙ | ︙ |
Modified tcp-transportmod.scm from [7db23f7cad] to [c1e45ba013].
︙ | ︙ | |||
318 319 320 321 322 323 324 | (string>? (list-ref a 3)(list-ref b 3)) ;; if servers started at same time look at server-id (< starta startb)))))) (count 0)) (for-each (lambda (rec) (if (or (> (length sorted) 1) (common:low-noise-print 120 "server info sorted")) | | | 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | (string>? (list-ref a 3)(list-ref b 3)) ;; if servers started at same time look at server-id (< starta startb)))))) (count 0)) (for-each (lambda (rec) (if (or (> (length sorted) 1) (common:low-noise-print 120 "server info sorted")) (debug:print 2 *default-log-port* "SERVER #"count": "(string-intersperse (map conc sorted) ", "))) (set! count (+ count 1))) sorted) sorted)) (define (tt:get-current-server-info ttdat dbfname) (assert (tt-areapath ttdat) "FATAL: areapath not set in ttdat.") ;; |
︙ | ︙ | |||
481 482 483 484 485 486 487 488 489 490 491 492 493 494 | "tcp-server-thread")) (run-thread (make-thread (lambda () (tt:keep-running ttdat dbfname dbstruct))))) (thread-start! tcp-thread) (thread-start! run-thread) (thread-join! run-thread) ;; run thread will exit on timeout or other conditions (exit)))))) (define (tt:keep-running ttdat dbfname dbstruct) ;; verfiy conn for ready ;; listener socket has been started by this stage ;; wait for a port before creating the registration file ;; | > | 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | "tcp-server-thread")) (run-thread (make-thread (lambda () (tt:keep-running ttdat dbfname dbstruct))))) (thread-start! tcp-thread) (thread-start! run-thread) (thread-join! run-thread) ;; run thread will exit on timeout or other conditions (debug:print 0 *default-log-port* "Exiting now.") (exit)))))) (define (tt:keep-running ttdat dbfname dbstruct) ;; verfiy conn for ready ;; listener socket has been started by this stage ;; wait for a port before creating the registration file ;; |
︙ | ︙ | |||
597 598 599 600 601 602 603 | (dbr:dbstruct-last-update-set! dbstruct curr-secs)))) (if (< (- (current-seconds) (tt-last-access ttdat)) (tt-server-timeout-param)) (begin (thread-sleep! 5) (loop))))) (cleanup) | | | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | (dbr:dbstruct-last-update-set! dbstruct curr-secs)))) (if (< (- (current-seconds) (tt-last-access ttdat)) (tt-server-timeout-param)) (begin (thread-sleep! 5) (loop))))) (cleanup) (debug:print 0 *default-log-port* "INFO: Server timed out, exiting from tt:keep-running."))) ;; ;; given an already set up uconn start the cmd-loop ;; ;; ;; (define (tt:cmd-loop ttdat) ;; (let* ((serv-listener (-socket uconn)) ;; (listener (lambda () |
︙ | ︙ |