Overview
Comment: | Restored homehost functions to 1.80. Set the homehost when starting dashboard or megatest -run. Abort if an attempt is made to start a server on a non-homehost. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.80 |
Files: | files | file ages | folders |
SHA1: |
3019408957c95ac9d5a9b2837ea5cc49 |
User & Date: | mmgraham on 2024-06-05 18:36:29 |
Other Links: | branch diff | manifest | tags |
Context
2024-06-05
| ||
18:38 | merged fork Closed-Leaf check-in: 17856ae5a8 user: mmgraham tags: v1.80 | |
18:36 | Restored homehost functions to 1.80. Set the homehost when starting dashboard or megatest -run. Abort if an attempt is made to start a server on a non-homehost. check-in: 3019408957 user: mmgraham tags: v1.80 | |
2024-05-21
| ||
11:46 | added list of preq-fail tests to messages and db comments check-in: e8d7732e53 user: mmgraham tags: v1.80 | |
Changes
Modified api.scm from [13a08c65d1] to [800ec32af5].
︙ | ︙ | |||
236 237 238 239 240 241 242 | (set! *api-threads* (filter (lambda (thdat) (not (member (thread-state (car thdat)) '(terminated dead)))) *api-threads*))) (define (api:get-count-threads-alive) (length *api-threads*)) | | > > > > > > > > > > > > | > | > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | (set! *api-threads* (filter (lambda (thdat) (not (member (thread-state (car thdat)) '(terminated dead)))) *api-threads*))) (define (api:get-count-threads-alive) (length *api-threads*)) ;; ========================================================================================================================================== ;; api:tcp-dispatch-request-make-handler is a complex TCP request handler that manages server load, dispatches requests, and ensures that the ;; server's state is consistent with the incoming requests. It is designed to be used in a concurrent environment where multiple requests are ;; being handled simultaneously. ;; ;; It processes incoming requests and dispatches them accordingly. ;; The function takes a dbstruct argument, which is a structure representing the database. ;; ;; 1. The function asserts that global variable `*toppath*` is set. ;; ;; 2. It checks if `*server-signature*` is not set, and if so, it sets it using the `tt:mk-signature` function with `*toppath*` as an argument. ;; The `*server-signature*` is used to identify the server instance. ;; ;; 3. The function returns a lambda function that takes `indat` as an argument. indat is (cmd run-id params meta) This lambda is the actual ;; request handler that will be called with the incoming data. ;; ;; 4. Inside the lambda, the current thread is registered with `api:register-thread`. ;; ;; 5. Several local variables are initialized: ;; - `newcount`: A counter for the number of requests being processed. ;; - `numthreads`: The number of alive threads handling requests. ;; - `delay-wait`: A calculated delay based on the number of requests. ;; ;; 6. A `normal-proc` lambda is defined to handle the incoming command (`cmd`), `run-id`, and `params`. It uses a `case` statement to handle ;; different commands. If the command is "ping", it returns the server signature. Otherwise, it dispatches the request using ;; `api:dispatch-request`. ;; ;; 7. The function updates the `*api-process-request-count*` and `*db-last-access*` global variables. ;; ;; 8. It checks if the number of requests (`newcount`) does not match the number of threads (`numthreads`) and performs cleanup and debugging ;; if necessary. ;; ;; 9. The `match` expression is used to destructure `indat` into its components (`cmd`, `run-id`, `params`, `meta`). ;; ;; 10. Several local variables are set based on the destructured data and the current server state: ;; - `db-ok`: Checks if the database file name matches the expected one for the given `run-id`. ;; - `ttdat`: Retrieves server information. ;; - `server-state`: Gets the current state of the server. ;; - `status`: Determines the server's load status based on `newcount`. ;; - `errmsg`: Generates an error message based on the server's status. ;; - `result`: Processes the command based on the server's status. ;; ;; 11. The `meta` variable is updated with additional information based on the command. ;; ;; 12. The `payload` is constructed, which includes the status, error message, result, and meta information. ;; ;; 13. The `*api-process-request-count*` is decremented, as the request has been processed. ;; ;; 14. The current thread is unregistered with `api:unregister-thread`. ;; ;; 15. Finally, the `payload` is returned, which would be the response to the incoming request. ;; ;; Nothing should be printed within the lambda because it interacts with the current input/output ports, which could interfere with the ;; request/response flow. ;; ;; The `else` clause at the end of the `match` expression asserts a fatal error if `indat` cannot be deserialized, indicating that the incoming ;; data is not in the expected format. ;; (define (api:tcp-dispatch-request-make-handler dbstruct) ;; cmd run-id params) (assert *toppath* "FATAL: api:tcp-dispatch-request-make-handler called but *toppath* not set.") (if (not *server-signature*) (set! *server-signature* (tt:mk-signature *toppath*))) (lambda (indat) (api:register-thread (current-thread)) (let* (;; (indat (deserialize)) |
︙ | ︙ |
Modified common.scm from [a6df612234] to [49835e4bfe].
︙ | ︙ | |||
300 301 302 303 304 305 306 | ;; (defstruct remote ;; transport to be used ;; http - use http-transport ;; http-read-cached - use http-transport for writes but in-mem cached for reads (rmode 'http) | | < < < | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | ;; (defstruct remote ;; transport to be used ;; http - use http-transport ;; http-read-cached - use http-transport for writes but in-mem cached for reads (rmode 'http) (hh-dat (common:get-homehost)) ;; homehost record ( addr . hhflag ) (server-url #f) ;; (server:check-if-running *toppath*) #f)) (server-id #f) (server-info #f) ;; (if *toppath* (server:check-if-running *toppath*) #f)) (last-server-check 0) ;; last time we checked to see if the server was alive (connect-time (current-seconds)) ;; when we first connected (last-access (current-seconds)) ;; last time we talked to server ;; (conndat #f) ;; iface port api-uri api-url api-req seconds server-id |
︙ | ︙ | |||
1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 | #f)) ;;====================================================================== ;; logic for getting homehost. Returns (host . at-home) ;; IF *toppath* is not set, wait up to five seconds trying every two seconds ;; (this is to accomodate the watchdog) ;; ;;====================================================================== ;; do we honor the caches of the config files? ;; (define (common:use-cache?) (let ((res #t)) ;; priority by order of evaluation (if *configdat* ;; sillyness here. can't use setup/use-cache to know if we can use the cached files! | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 | #f)) ;;====================================================================== ;; logic for getting homehost. Returns (host . at-home) ;; IF *toppath* is not set, wait up to five seconds trying every two seconds ;; (this is to accomodate the watchdog) ;; (define (common:get-homehost #!key (trynum 5)) ;; called often especially at start up. use mutex to eliminate collisions (mutex-lock! *homehost-mutex*) (cond (*home-host* (mutex-unlock! *homehost-mutex*) *home-host*) ((not *toppath*) (mutex-unlock! *homehost-mutex*) (launch:setup) ;; safely mutexed now (if (> trynum 0) (begin (thread-sleep! 2) (common:get-homehost trynum: (- trynum 1))) #f)) (else (let* ((currhost (get-host-name)) (bestadrs (server:get-best-guess-address currhost)) ;; first look in config, then look in file .homehost, create it if not found (homehost (or (configf:lookup *configdat* "server" "homehost" ) (handle-exceptions exn (if (> trynum 0) (let ((delay-time (* (- 5 trynum) 5))) (mutex-unlock! *homehost-mutex*) (debug:print 0 *default-log-port* "ERROR: ["(common:human-time)"] Failed to read .homehost file, delaying " delay-time " seconds and trying again, message: " ((condition-property-accessor 'exn 'message) exn) ", exn=" exn) (thread-sleep! delay-time) (common:get-homehost trynum: (- trynum 1))) (begin (mutex-unlock! *homehost-mutex*) (debug:print 0 *default-log-port* "ERROR: ["(common:human-time) "] Failed to read .homehost file after trying five times. Giving up and exiting, message: " ((condition-property-accessor 'exn 'message) exn)) (exit 1))) (let ((hhf (conc *toppath* "/.homehost"))) (if (common:file-exists? hhf) (with-input-from-file hhf read-line) (if (file-write-access? *toppath*) (begin (debug:print 0 *default-log-port* "No .homehost file found. Setting it to the current machine") (with-output-to-file hhf (lambda () (print bestadrs))) (begin (mutex-unlock! *homehost-mutex*) (car (common:get-homehost)))) #f)))))) (at-home (or (equal? homehost currhost) (equal? homehost bestadrs)))) (set! *home-host* (cons homehost at-home)) (mutex-unlock! *homehost-mutex*) *home-host*)))) ;;====================================================================== ;; am I on the homehost? ;; (define (common:on-homehost?) (let ((hh (common:get-homehost))) (if hh (cdr hh) #f))) ;;====================================================================== ;; do we honor the caches of the config files? ;; (define (common:use-cache?) (let ((res #t)) ;; priority by order of evaluation (if *configdat* ;; sillyness here. can't use setup/use-cache to know if we can use the cached files! |
︙ | ︙ |
Modified dashboard.scm from [023ac3626d] to [e2e9d0eb23].
︙ | ︙ | |||
3840 3841 3842 3843 3844 3845 3846 | (if (not (launch:setup)) (begin (debug:print 0 *default-log-port* "Failed to find megatest.config, exiting") (exit 1) ) ) | | | < > > > | 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 | (if (not (launch:setup)) (begin (debug:print 0 *default-log-port* "Failed to find megatest.config, exiting") (exit 1) ) ) (if (not (common:on-homehost?)) (begin (debug:print 0 *default-log-port* "WARNING: You are starting the dashboard on a machine that is not the homehost:" (car (common:get-homehost))) (debug:print 0 *default-log-port* "It will be slower.") ) (debug:print 0 *default-log-port* "Dashboard started on the homehost: " (car (common:get-homehost))) ) (if (and (common:file-exists? mtdb-path) (file-write-access? mtdb-path)) (if (not (args:get-arg "-skip-version-check")) (common:exit-on-version-changed))) |
︙ | ︙ |
Modified megatest.scm from [f4be8baece] to [bb25ae0786].
︙ | ︙ | |||
971 972 973 974 975 976 977 978 979 980 981 982 983 984 | ;; Server? Start up here. ;; (if (args:get-arg "-server") (let* (;; (run-id (args:get-arg "-run-id")) (dbfname (args:get-arg "-db")) (tl (launch:setup)) (keys (keys:config-get-fields *configdat*))) (case (rmt:transport-mode) ((tcp) (let* ((timeout (server:expiration-timeout))) (debug:print 0 *default-log-port* "INFO: Starting server for " dbfname " using tcp method with server timeout of "timeout) (tt-server-timeout-param timeout) (if dbfname (tt:start-server tl #f dbfname api:tcp-dispatch-request-make-handler keys) | > > > > > | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 | ;; Server? Start up here. ;; (if (args:get-arg "-server") (let* (;; (run-id (args:get-arg "-run-id")) (dbfname (args:get-arg "-db")) (tl (launch:setup)) (keys (keys:config-get-fields *configdat*))) (if (not (common:on-homehost?)) (begin (debug:print 0 *default-log-port* "Attempt to start a server on a machine that is not the homehost. Aborting") (exit ))) (case (rmt:transport-mode) ((tcp) (let* ((timeout (server:expiration-timeout))) (debug:print 0 *default-log-port* "INFO: Starting server for " dbfname " using tcp method with server timeout of "timeout) (tt-server-timeout-param timeout) (if dbfname (tt:start-server tl #f dbfname api:tcp-dispatch-request-make-handler keys) |
︙ | ︙ | |||
1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 | ;; run all tests are are Not COMPLETED and PASS or CHECK (if (or (args:get-arg "-runall") (args:get-arg "-run") (args:get-arg "-rerun-clean") (args:get-arg "-rerun-all") (args:get-arg "-runtests") (args:get-arg "-kill-rerun")) (let ((need-clean (or (args:get-arg "-rerun-clean") (args:get-arg "-rerun-all"))) (orig-cmdline (string-intersperse (argv) " "))) (general-run-call "-runall" "run all tests" (lambda (target runname keys keyvals) | > > | 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 | ;; run all tests are are Not COMPLETED and PASS or CHECK (if (or (args:get-arg "-runall") (args:get-arg "-run") (args:get-arg "-rerun-clean") (args:get-arg "-rerun-all") (args:get-arg "-runtests") (args:get-arg "-kill-rerun")) (begin (common:get-homehost) ;; set the .homehost if it's not set. (let ((need-clean (or (args:get-arg "-rerun-clean") (args:get-arg "-rerun-all"))) (orig-cmdline (string-intersperse (argv) " "))) (general-run-call "-runall" "run all tests" (lambda (target runname keys keyvals) |
︙ | ︙ | |||
1997 1998 1999 2000 2001 2002 2003 | (conc "runname " runname) (conc "runname " (simple-run-runname spec)) orig-cmdline))))) (debug:print 0 *default-log-port* "ORIG: " orig-cmdline) (debug:print 0 *default-log-port* "NEW: " newcmdline) (system newcmdline))) run-specs)) | | | 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 | (conc "runname " runname) (conc "runname " (simple-run-runname spec)) orig-cmdline))))) (debug:print 0 *default-log-port* "ORIG: " orig-cmdline) (debug:print 0 *default-log-port* "NEW: " newcmdline) (system newcmdline))) run-specs)) (handle-run-requests target runname keys keyvals need-clean))))))) ;;====================================================================== ;; run one test ;;====================================================================== ;; 1. find the config file ;; 2. change to the test directory |
︙ | ︙ |