Overview
Comment: | wip, close idle db connections |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.80-close-idle-connections |
Files: | files | file ages | folders |
SHA1: |
97a3c4ad117281ac58073e623e277189 |
User & Date: | matt on 2023-02-05 08:36:51 |
Other Links: | branch diff | manifest | tags |
Context
2023-02-07
| ||
16:24 | fix for assert check-in: a7577f7a9b user: pjhatwal tags: v1.80-close-idle-connections | |
2023-02-05
| ||
08:36 | wip, close idle db connections check-in: 97a3c4ad11 user: matt tags: v1.80-close-idle-connections | |
2023-02-02
| ||
12:54 | Use an actual droop check-in: 19861e6399 user: matt tags: v1.80 | |
Changes
Modified api.scm from [0676a2f9d1] to [e4088e0a3d].
︙ | |||
16 17 18 19 20 21 22 | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | - + | ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; ;;====================================================================== |
︙ | |||
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | + + + + + + + + + + + - + - - - - - - - - - - | ;; TASKS tasks-add tasks-set-state-given-param-key )) (define *db-write-mutexes* (make-hash-table)) (define *api-watchdog* #f) (define (api:watchdog dbstruct) ;; trim not-used sqlite3 db handles (let* ((th1 (make-thread (lambda () (let loop () (thread-sleep! 60) ;; 2x the age we close at (db:close-old dbstruct) (loop))) "api:watchdog thread"))) (thread-start! th1) (set! *api-watchdog* th1))) ;; These are called by the server on recipt of /api calls ;; - keep it simple, only return the actual result of the call, i.e. no meta info here ;; ;; - returns #( flag result ) ;; (define (api:execute-requests dbstruct dat) (db:open-no-sync-db) ;; sets *no-sync-db* |
︙ |
Modified db.scm from [66cca5d3c4] to [9fa55aaa76].
︙ | |||
549 550 551 552 553 554 555 | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | - - + - + - - | ;; (> (- (current-seconds) time1) 3)) ;; if file is changed and three seconds have passed. #t) ((and changed *time-to-exit*) ;; last sync #t) (else #f)))) (if (or dejunk do-cp) |
︙ | |||
4347 4348 4349 4350 4351 4352 4353 | 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + | ;; moving watch dogs here due to dependencies ;;====================================================================== ;;====================================================================== ;; currently the primary job of the watchdog is to run the sync back to megatest.db from the db in /tmp ;; if we are on the homehost and we are a server (by definition we are on the homehost if we are a server) ;; |
︙ |
Modified dbfile.scm from [25f8271ef2] to [8d67468750].
︙ | |||
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | + - + + + | (dbname #f) ;; .megatest/1.db (mtdbfile #f) ;; mtrah/.megatest/1.db (mtdbdat #f) ;; only need one of these for syncing ;; (dbdats (make-hash-table)) ;; id => dbdat (tmpdbfile #f) ;; /tmp/.../.megatest/1.db ;; (refndbfile #f) ;; /tmp/.../.megatest/1.db_ref (dbstack (make-stack)) ;; stack for tmp dbr:dbdat, (stack-mutex (make-mutex)) ;; gate pop, push, peek and replace with this mutex (allows safe clean up of old handles) (homehost #f) ;; not used yet (on-homehost #f) ;; not used yet (read-only #f) (last-sync 0) (last-write (current-seconds)) ) ;; goal is to converge on one struct for an area but for now it is too confusing ;; need to keep dbhandles and cached statements together (defstruct dbr:dbdat (dbfile #f) (dbh #f) (stmt-cache (make-hash-table)) (read-only #f) |
︙ | |||
126 127 128 129 130 131 132 | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | - + - - - - - - - - - - - + + + + + + - - - - - - - - + + + + + + - - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - | (dbfile:print-err "db:safely-close-sqlite3-db: " db " is not an sqlite3 db") #f ) )))) ;; close all opened run-id dbs (define (db:close-all dbstruct) |
︙ | |||
232 233 234 235 236 237 238 | 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 | + - - + + - - + + + + + + + | ;; if run-id is a string treat it as a filename ;; if db already open - return inmem ;; if db not open, open inmem, rundb and sync then return inmem ;; inuse gets set automatically for rundb's ;; (define (dbfile:get-dbdat dbstruct run-id) (let* ((subdb (dbfile:get-subdb dbstruct run-id))) (mutex-lock! (dbr:subdb-stack-mutex subdb)) |
︙ |