Overview
Comment: | Sync back implemented, compiles but not tested |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.80-tcp-inmem |
Files: | files | file ages | folders |
SHA1: |
c70de6806c081266ac8c39415857f28b |
User & Date: | matt on 2023-02-19 21:23:06 |
Other Links: | branch diff | manifest | tags |
Context
2023-02-19
| ||
22:01 | misc needed fixes check-in: 263e0fe253 user: matt tags: v1.80-tcp-inmem | |
21:23 | Sync back implemented, compiles but not tested check-in: c70de6806c user: matt tags: v1.80-tcp-inmem | |
20:14 | list runs now working with data sync'd from ondisk to inmem (but no last_update support). check-in: 12db00e83a user: matt tags: v1.80-tcp-inmem | |
Changes
Modified dbfile.scm from [bad40329ba] to [90e09d3f1a].
︙ | ︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 74 75 | ;; ;; for the inmem approach (see dbmod.scm) ;; this is one db per server (inmem #f) ;; handle for the in memory copy (dbfile #f) ;; path to the db file on disk (ondiskdb #f) ;; handle for the on-disk file (dbdat #f) ;; create a dbdat for the downstream calls such as db:with-db ) ;; NOTE: Need one dbr:subdb per main.db, 1.db ... ;; (defstruct dbr:subdb (dbname #f) ;; .megatest/1.db (mtdbfile #f) ;; mtrah/.megatest/1.db | > > | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | ;; ;; for the inmem approach (see dbmod.scm) ;; this is one db per server (inmem #f) ;; handle for the in memory copy (dbfile #f) ;; path to the db file on disk (ondiskdb #f) ;; handle for the on-disk file (dbdat #f) ;; create a dbdat for the downstream calls such as db:with-db (last-update 0) (syncback-proc #f) ) ;; NOTE: Need one dbr:subdb per main.db, 1.db ... ;; (defstruct dbr:subdb (dbname #f) ;; .megatest/1.db (mtdbfile #f) ;; mtrah/.megatest/1.db |
︙ | ︙ |
Modified dbmod.scm from [d5396ce900] to [5da8a7fe52].
︙ | ︙ | |||
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | (if write-access (init-proc db)) db)))) (tables (db:sync-all-tables-list keys))) (dbr:dbstruct-inmem-set! dbstruct inmem) (dbr:dbstruct-ondiskdb-set! dbstruct db) (dbr:dbstruct-dbfile-set! dbstruct dbfullname) (dbmod:sync-tables tables #f db inmem) dbstruct)) (define (dbmod:close-db dbstruct) ;; do final sync to disk file ;; (do-sync ...) (sqlite3:finalize! (dbr:dbstruct-ondiskdb dbstruct))) | > > > | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | (if write-access (init-proc db)) db)))) (tables (db:sync-all-tables-list keys))) (dbr:dbstruct-inmem-set! dbstruct inmem) (dbr:dbstruct-ondiskdb-set! dbstruct db) (dbr:dbstruct-dbfile-set! dbstruct dbfullname) (dbr:dbstruct-syncback-proc-set! dbstruct (lambda (last-update) (dbmod:sync-tables tables last-update inmem db))) (dbmod:sync-tables tables #f db inmem) (dbr:dbstruct-last-update-set! dbstruct (current-seconds)) ;; should this be offset back in time by one second? dbstruct)) (define (dbmod:close-db dbstruct) ;; do final sync to disk file ;; (do-sync ...) (sqlite3:finalize! (dbr:dbstruct-ondiskdb dbstruct))) |
︙ | ︙ |
Modified tcp-transportmod.scm from [0ef29c3cc2] to [ced741c85e].
︙ | ︙ | |||
269 270 271 272 273 274 275 | (tt-handler-set! ttdat (handler dbstruct)) (let* ((tcp-thread (make-thread (lambda () (tt:start-tcp-server ttdat)) ;; start the tcp-server which applies handler to incoming data "tcp-server-thread")) (run-thread (make-thread (lambda () | | | > > > | > > | 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 309 310 311 312 313 314 315 316 317 318 | (tt-handler-set! ttdat (handler dbstruct)) (let* ((tcp-thread (make-thread (lambda () (tt:start-tcp-server ttdat)) ;; start the tcp-server which applies handler to incoming data "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 ;; ;; set a flag here to tell tcp-thread to stop running ;; ;; (thread-join! tcp-thread) ;; can't wait ;; ;; remove the servinfo file ;; ;; close the database, remove lock in on-disk db ;; ;; close the listener ports ;; (exit))) (begin (debug:print 0 *default-log-port* "INFO: found server(s) already running for db "dbfname", "(string-intersperse servers ",")" Exiting.") (exit))))) (define (tt:keep-running ttdat dbfname dbstruct) ;; verfiy conn for ready ;; listener socket has been started by this stage (thread-sleep! 1) (let loop ((count 0)) (if (> count 60) (begin (debug:print 0 *default-log-port* "FATAL: Could not start a tcp server, giving up.") (exit 1)) (if (not (tt-port ttdat)) ;; no connection yet (let* ((last-update (dbr:dbstruct-last-update dbstruct)) (curr-secs (current-seconds))) (if (> (- curr-secs last-update) 3) ;; every 3-4 seconds (begin ((dbr:dbstruct-syncback-proc) last-update) (dbr:dbstruct-last-update-set! curr-secs))) (thread-sleep! 1) (loop (+ count 1)))))) (tt:create-server-registration-file ttdat dbfname) ;; now start watching the last-access, if it hasn't been touched ;; in over ten seconds we exit (let loop () |
︙ | ︙ |