Overview
Comment: | Part of the read-only fixes to local access in rmt.scm |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | matt-db-sync-2 | v1.62-side |
Files: | files | file ages | folders |
SHA1: |
ba3d839090a9ba16256ec26f3015c5bb |
User & Date: | mrwellan on 2016-10-31 10:42:21 |
Other Links: | branch diff | manifest | tags |
Context
2016-11-04
| ||
18:05 | Merged in ba3d matt-db-sync-2 check-in: 0b35c5d875 user: matt tags: v1.62-side | |
2016-10-31
| ||
10:50 | Minor clean up of local access in rmt.scm check-in: f4f12cde04 user: mrwellan tags: matt-db-sync-2, v1.62-side | |
10:42 | Part of the read-only fixes to local access in rmt.scm check-in: ba3d839090 user: mrwellan tags: matt-db-sync-2, v1.62-side | |
10:21 | Refactoring commit 92a15e into matt-db-sync-2. Updated api list of read-only queries. check-in: 80c6955310 user: mrwellan tags: matt-db-sync-2, v1.62-side | |
Changes
Modified rmt.scm from [bb562bf1d7] to [c93ba3276b].
︙ | ︙ | |||
225 226 227 228 229 230 231 | (cons newmax-cmd currmax) (cons 'none 0)) (loop (car tal)(cdr tal) newmax-cmd currmax))))))) (mutex-unlock! *db-stats-mutex*) res)) (define (rmt:open-qry-close-locally cmd run-id params #!key (remretries 5)) | > > | < | < | > | > > > > > | < < | | | 225 226 227 228 229 230 231 232 233 234 235 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 | (cons newmax-cmd currmax) (cons 'none 0)) (loop (car tal)(cdr tal) newmax-cmd currmax))))))) (mutex-unlock! *db-stats-mutex*) res)) (define (rmt:open-qry-close-locally cmd run-id params #!key (remretries 5)) (let* ((qry-is-write (not (member cmd api:read-only-queries))) (dbdir (db:dbfile-path #f)) (dbstruct-local (if *dbstruct-db* *dbstruct-db* (let* ((db (make-dbr:dbstruct path: dbdir local: #t))) (set! *dbstruct-db* db) db))) (read-only (not (file-write-access? dbdir))) (start (current-milliseconds)) (resdat (if (not (and read-only qry-is-write)) (api:execute-requests dbstruct-local (vector (symbol->string cmd) params)) (vector #t '()))) (success (vector-ref resdat 0)) (res (vector-ref resdat 1)) (duration (- (current-milliseconds) start))) (if (and read-only qry-is-write) (begin (debug:print 0 *default-log-port* "ERROR: attempt to write to read-only database ignored. cmd=" cmd) )) (if (not success) (if (> remretries 0) (begin (debug:print-error 0 *default-log-port* "local query failed. Trying again.") (thread-sleep! (/ (random 5000) 1000)) ;; some random delay (rmt:open-qry-close-locally cmd run-id params remretries: (- remretries 1))) (begin (debug:print-error 0 *default-log-port* "too many retries in rmt:open-qry-close-locally, giving up") #f)) (begin ;; (rmt:update-db-stats run-id cmd params duration) ;; mark this run as dirty if this was a write (if qry-is-write (let ((start-time (current-seconds))) (mutex-lock! *db-multi-sync-mutex*) (hash-table-set! *db-local-sync* (or run-id 0) start-time) ;; the oldest "write" (mutex-unlock! *db-multi-sync-mutex*))))) res)) (define (rmt:send-receive-no-auto-client-setup connection-info cmd run-id params) (let* ((run-id (if run-id run-id 0)) ;; (jparams (db:obj->string params)) ;; (rmt:dat->json-str params)) (res (handle-exceptions exn #f |
︙ | ︙ |