Overview
Comment: | Added very conservative (and slow) encode/decode serialization to be resiliant over transport problems. Fixed transport problem created by use of print. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v2.0001-inmem |
Files: | files | file ages | folders |
SHA1: |
e4218567cc2a665d6932f47eb274d90a |
User & Date: | matt on 2022-01-19 13:25:54 |
Other Links: | branch diff | manifest | tags |
Context
2022-01-19
| ||
13:27 | Added inmem check-in: f1db41ee97 user: matt tags: v2.0001 | |
13:25 | Added very conservative (and slow) encode/decode serialization to be resiliant over transport problems. Fixed transport problem created by use of print. Leaf check-in: e4218567cc user: matt tags: v2.0001-inmem | |
2022-01-18
| ||
19:14 | WIP: Enabled inmem. Works for somecases, smashes the heap on megatest -run check-in: 871f527729 user: matt tags: v2.0001-inmem | |
Changes
Modified dbmod.scm from [c50dc3ce24] to [a59a7c6f2f].
︙ | ︙ | |||
1712 1713 1714 1715 1716 1717 1718 | id INTEGER PRIMARY KEY, test_id INTEGER, state TEXT DEFAULT 'new', status TEXT DEFAULT 'n/a', archive_type TEXT DEFAULT 'bup', du INTEGER, archive_path TEXT);"))) | | | | | 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 | id INTEGER PRIMARY KEY, test_id INTEGER, state TEXT DEFAULT 'new', status TEXT DEFAULT 'n/a', archive_type TEXT DEFAULT 'bup', du INTEGER, archive_path TEXT);"))) (debug:print 0 *default-log-port* "creating triggers from init") (db:create-triggers db) db)) ;; ) ;;====================================================================== ;; A R C H I V E S ;;====================================================================== ;; dneeded is minimum space needed, scan for existing archives that ;; are on disks with adequate space and already have this test/itempath |
︙ | ︙ | |||
3027 3028 3029 3030 3031 3032 3033 | (define (db:set-run-state-status dbstruct run-id state status ) (db:with-db dbstruct #f #f (lambda (db) (sqlite3:execute db "UPDATE runs SET status=?,state=? WHERE id=?;" status state run-id)))) | < < | 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 | (define (db:set-run-state-status dbstruct run-id state status ) (db:with-db dbstruct #f #f (lambda (db) (sqlite3:execute db "UPDATE runs SET status=?,state=? WHERE id=?;" status state run-id)))) (define (db:get-run-status dbstruct run-id) (let ((res "n/a")) (db:with-db dbstruct #f #f (lambda (db) (sqlite3:for-each-row (lambda (status) |
︙ | ︙ | |||
4273 4274 4275 4276 4277 4278 4279 | (list newstate newstatus)))) (define (db:set-state-status-and-roll-up-run dbstruct run-id curr-state curr-status) ;; (mutex-lock! *db-transaction-mutex*) (db:with-db dbstruct #f #f (lambda (db) | | > | > > > | | 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 | (list newstate newstatus)))) (define (db:set-state-status-and-roll-up-run dbstruct run-id curr-state curr-status) ;; (mutex-lock! *db-transaction-mutex*) (db:with-db dbstruct #f #f (lambda (db) ;; (let ((tr-res (sqlite3:with-transaction db (lambda () (let* ((state-status-counts (db:get-all-state-status-counts-for-run dbstruct run-id)) (state-statuses (db:roll-up-rules state-status-counts #f #f )) (newstate (car state-statuses)) (newstatus (cadr state-statuses))) (if (or (not (eq? newstate curr-state)) (not (eq? newstatus curr-status))) (begin (db:set-run-state-status dbstruct run-id newstate newstatus) #t) ;; changes made #f) ;; no changes )))))) ;; (mutex-unlock! *db-transaction-mutex*) ;; tr-res)))) (define (db:get-all-state-status-counts-for-run dbstruct run-id) (let* ((test-count-recs (db:with-db dbstruct #f #f (lambda (db) (sqlite3:map-row |
︙ | ︙ |
Modified ulex-simple/ulex.scm from [24167fae4d] to [4e7e7a6994].
︙ | ︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 | (import scheme chicken.base chicken.file chicken.io chicken.time chicken.condition chicken.string chicken.sort chicken.pretty-print chicken.tcp address-info mailbox | > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | (import scheme chicken.base chicken.file chicken.io chicken.time chicken.condition chicken.port chicken.string chicken.sort chicken.pretty-print chicken.tcp address-info mailbox |
︙ | ︙ | |||
82 83 84 85 86 87 88 89 90 91 92 93 94 95 | srfi-18 srfi-4 srfi-69 system-information ;; tcp6 tcp-server typed-records ) ;; udat struct, used by both caller and callee ;; instantiated as uconn by convention ;; (defstruct udat ;; the listener side | > > > > > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | srfi-18 srfi-4 srfi-69 system-information ;; tcp6 tcp-server typed-records md5 message-digest (prefix base64 base64:) z3 ) ;; udat struct, used by both caller and callee ;; instantiated as uconn by convention ;; (defstruct udat ;; the listener side |
︙ | ︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 | (avail-cmboxes '()) ;; list of (<cookie> . <mbox>) for re-use ;; threads (numthreads 10) (cmd-thread #f) (work-queue-thread #f) (num-threads-running 0) ) ;;====================================================================== ;; listener ;;====================================================================== ;; is uconn a ulex connector (listener) ;; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 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 | (avail-cmboxes '()) ;; list of (<cookie> . <mbox>) for re-use ;; threads (numthreads 10) (cmd-thread #f) (work-queue-thread #f) (num-threads-running 0) ) ;;====================================================================== ;; serialization ;; NOTE: I've had problems with read/write and s11n serialize, deserialize ;; thus the inefficient method here ;;====================================================================== (define serializing-method (make-parameter 'complex)) ;; NOTE: Can remove the regex and base64 encoding for zmq (define (obj->string obj) (case (serializing-method) ((complex) (string-substitute (regexp "=") "_" (base64:base64-encode (z3:encode-buffer (with-output-to-string (lambda ()(serialize obj))))) ;; BB: serialize - this is ;; what causes problems ;; between different builds of ;; megatest communicating. ;; serialize is sensitive to ;; binary image of mtest. #t)) ((write)(with-output-to-string (lambda ()(write obj)))) ((s11n) (with-output-to-string (lambda ()(serialize obj)))) (else obj))) ;; rpc (define (string->obj msg #!key (transport 'http)) (case (serializing-method) ((complex) (if (string? msg) (with-input-from-string (z3:decode-buffer (base64:base64-decode (string-substitute (regexp "_") "=" msg #t))) (lambda ()(deserialize))) (begin (print "ULEX ERROR: cannot translate received data \""msg"\"") (print-call-chain (current-error-port)) msg))) ;; crude reply for when things go awry ((write)(with-input-from-string msg (lambda ()(read)))) ((s11n)(with-input-from-string msg (lambda ()(deserialize)))) (else msg))) ;; rpc ;;====================================================================== ;; listener ;;====================================================================== ;; is uconn a ulex connector (listener) ;; |
︙ | ︙ | |||
151 152 153 154 155 156 157 | (define (run-listener handler-proc #!optional (port-suggestion 4242)) (let* ((uconn (make-udat))) (udat-work-proc-set! uconn handler-proc) (if (setup-listener uconn port-suggestion) ((make-tcp-server (udat-socket uconn) (lambda () | | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | (define (run-listener handler-proc #!optional (port-suggestion 4242)) (let* ((uconn (make-udat))) (udat-work-proc-set! uconn handler-proc) (if (setup-listener uconn port-suggestion) ((make-tcp-server (udat-socket uconn) (lambda () (let* ((rdat (string->obj (read)) #;(deserialize)) ;; '(my-host-port qrykey cmd params) (resp (do-work uconn rdat))) (write (obj->string resp)) #;(serialize resp))))) (assert #f "ERROR: run-listener called without proper setup.")))) (define (wait-and-close uconn) (thread-join! (udat-cmd-thread uconn)) (tcp-close (udat-socket uconn))) ;;====================================================================== |
︙ | ︙ | |||
185 186 187 188 189 190 191 | (isme (equal? host-port my-host-port)) ;; calling myself? ;; dat is a self-contained work block that can be sent or handled locally (dat (list my-host-port 'qrykey cmd params #;(cons (current-seconds)(current-milliseconds))))) (cond (isme (do-work udata dat)) ;; no transmission needed (else (handle-exceptions ;; TODO - MAKE THIS EXCEPTION CMD SPECIFIC? | | > > | | | | | | | | | | | | > | | | | 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 | (isme (equal? host-port my-host-port)) ;; calling myself? ;; dat is a self-contained work block that can be sent or handled locally (dat (list my-host-port 'qrykey cmd params #;(cons (current-seconds)(current-milliseconds))))) (cond (isme (do-work udata dat)) ;; no transmission needed (else (handle-exceptions ;; TODO - MAKE THIS EXCEPTION CMD SPECIFIC? exn (begin (print "ULEX send-receive: exn="exn) (message exn)) (begin ;; (mutex-lock! *send-mutex*) ;; DOESN'T SEEM TO HELP (let-values (((inp oup)(tcp-connect host port))) (let ((res (if (and inp oup) (begin (write (obj->string dat) oup) ;; (write dat oup);; (serialize dat oup) (close-output-port oup) (string->obj (read inp))) ;; (deserialize inp)) (begin (print "ERROR: send called but no receiver has been setup. Please call setup first!") #f)))) ;; (close-output-port oup) (close-input-port inp) ;; (mutex-unlock! *send-mutex*) ;; DOESN'T SEEM TO HELP res)))))))) ;; res will always be 'ack unless return-method is direct ;;====================================================================== ;; work queues - this is all happening on the listener side ;;====================================================================== ;; move the logic to return the result somewhere else? ;; |
︙ | ︙ |