Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -1271,11 +1271,12 @@ (let* ((dbname (db:run-id->dbname run-id)) (mtdb (dbr:subdb-mtdb subdb)) (tmpdb (db:get-subdb dbstruct run-id)) (refndb (dbr:subdb-refndb subdb)) (newres (db:sync-tables (db:sync-all-tables-list dbstruct) last-update tmpdb refndb mtdb))) - (stack-push! (dbr:subdb-dbstack subdb) tmpdb) + ;; (stack-push! (dbr:subdb-dbstack subdb) tmpdb) + (dbfile:add-dbdat dbstruct run-id tmpdb) (set! res (cons newres res)))) subdbs) res)) ;;;; run-ids @@ -5125,11 +5126,11 @@ #t))) (debug:print-info 0 *default-log-port* "Exiting readonly-watchdog timer, *time-to-exit* = " *time-to-exit*" pid="(current-process-id)" mtpath="golden-mtpath))) ;;====================================================================== ;; TODO: for multiple areas, we will have multiple watchdogs; and multiple threads to manage -(define (common:watchdog) +#;(define (common:watchdog) (debug:print-info 13 *default-log-port* "common:watchdog entered.") (if (launch:setup) (if (common:on-homehost?) (let ((dbstruct (db:setup #t))) ;; (db:setup-db *dbstruct-dbs* *toppath* #f))) ;; #t))) (debug:print-info 13 *default-log-port* "after db:setup with dbstruct=" dbstruct) @@ -5154,11 +5155,11 @@ ))) (debug:print-info 13 *default-log-port* "watchdog done.")) (debug:print-info 13 *default-log-port* "no need for watchdog on non-homehost")))) -(define (db:do-sync no-sync-db) +#;(define (db:do-sync no-sync-db) (let* ((syncer (or (configf:lookup *configdat* "server" "sync-method") "delta-sync")) (dbstruct (db:setup #t))) (debug:print 0 *default-log-port* "db:do-sync: sync-method: " syncer) (cond @@ -5201,11 +5202,11 @@ ) -(define (server:writable-watchdog-bruteforce dbstruct) +#;(define (server:writable-watchdog-bruteforce dbstruct) (thread-sleep! 1) ;; delay for startup #;(let* ((do-a-sync (server:get-bruteforce-syncer dbstruct)) (final-sync (server:get-bruteforce-syncer dbstruct fork-to-background: #t persist-until-sync: #t))) (when (and (not (args:get-arg "-sync-to-megatest.db")) ;; conditions under which we do not run the sync (args:get-arg "-server")) Index: dbfile.scm ================================================================== --- dbfile.scm +++ dbfile.scm @@ -202,10 +202,12 @@ (hash-table-ref/default (dbr:dbstruct-subdbs dbstruct) dbfname #f))) (define (dbfile:set-subdb dbstruct run-id subdb) (hash-table-set! (dbr:dbstruct-subdbs dbstruct) (dbfile:run-id->dbname run-id) subdb)) +(define *dbfile:num-handles-in-use* 0) + ;; Get/open a database ;; if run-id => get run specific db ;; if #f => get main db ;; if run-id is a string treat it as a filename ;; if db already open - return inmem @@ -213,16 +215,19 @@ ;; inuse gets set automatically for rundb's ;; (define (dbfile:get-dbdat dbstruct run-id) (let* ((subdb (dbfile:get-subdb dbstruct run-id))) (if (stack-empty? (dbr:subdb-dbstack subdb)) - #f - (stack-pop! (dbr:subdb-dbstack subdb))))) + #f + (begin + (set! *dbfile:num-handles-in-use* (+ *dbfile:num-handles-in-use* 1)) + (stack-pop! (dbr:subdb-dbstack subdb)))))) ;; return a previously opened db handle to the stack of available handles (define (dbfile:add-dbdat dbstruct run-id dbdat) (let* ((subdb (dbfile:get-subdb dbstruct run-id))) + (set! *dbfile:num-handles-in-use* (- *dbfile:num-handles-in-use* 1)) (stack-push! (dbr:subdb-dbstack subdb) dbdat))) ;; set up a subdb ;; (define (dbfile:init-subdb dbstruct run-id init-proc) @@ -247,10 +252,14 @@ ;; 2. if there is no existing db handle in the stack ;; create a new handle and return it (do NOT add ;; it to the stack). ;; (define (dbfile:open-db dbstruct run-id init-proc) + (if (> *dbfile:num-handles-in-use* 10) + (let* ((wait-delay (- *dbfile:num-handles-in-use* 9))) + (dbfile:print-err "INFO: over ten dbfile handle threads in use ("*dbfile:num-handles-in-use*") delaying "wait-delay" second") + (thread-sleep! wait-delay))) (let* ((subdb (dbfile:get-subdb dbstruct run-id))) (if (not subdb) ;; not yet defined (begin (dbfile:init-subdb dbstruct run-id init-proc) (dbfile:open-db dbstruct run-id init-proc)) Index: http-transport.scm ================================================================== --- http-transport.scm +++ http-transport.scm @@ -531,12 +531,12 @@ (begin (debug:print 0 *default-log-port* "Server stats:") (db:print-current-query-stats))) (let* ((hrs-since-start (/ (- (current-seconds) server-start-time) 3600))) (cond - ((and *server-run* - (> (- (current-seconds) server-start-time) 120)) ;; let's try server replacement + #;((and *server-run* + (> (- (current-seconds) server-start-time) 420)) ;; let's try server replacement ;; ((adj-proc-load . 0.056875) (adj-core-load . 0.11375) (1m-load . 0.91) (5m-load . 0.77) (15m-load . 1.0) (proc . 16) (core . 8) (phys . 1)) (let* ((loaddat (common:get-normalized-cpu-load #f)) (adj-proc-load (alist-ref 'adj-proc-load loaddat)) (adj-core-load (alist-ref 'adj-core-load loaddat)) (adj-load (max adj-proc-load adj-core-load)))