Megatest

Check-in [5c03cce6b3]
Login
Overview
Comment:new2old needed to handle multi sync in megatest.scm correctly
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.60
Files: files | file ages | folders
SHA1: 5c03cce6b3aa890c0f7008d0fd2af67e88d599bb
User & Date: mrwellan on 2014-10-08 13:07:08
Other Links: branch diff | manifest | tags
Context
2014-10-09
00:03
Merged in refactor-sqlite3-calls. Can refactor in small steps from here on out check-in: c03075b49a user: matt tags: v1.60
2014-10-08
22:46
Merged in fixes from v1.60 branch check-in: 7636717b91 user: matt tags: refactor-sqlite3-calls
13:07
new2old needed to handle multi sync in megatest.scm correctly check-in: 5c03cce6b3 user: mrwellan tags: v1.60
12:54
new2old needed to handle sync in rmt correctly check-in: 6ad4f305ae user: mrwellan tags: v1.60
Changes

Modified common.scm from [3b338cd1db] to [c65e994a50].

50
51
52
53
54
55
56

57
58
59
60
61
62
63
(define *alt-log-file* #f)  ;; used by -log

;; DATABASE
(define *dbstruct-db*  #f)
(define *db-stats* (make-hash-table)) ;; hash of vectors < count duration-total >
(define *db-stats-mutex*      (make-mutex))
(define *db-sync-mutex*       (make-mutex))

(define *db-local-sync*       (make-hash-table)) ;; used to record last touch of db
(define *megatest-db*         #f)
(define *last-db-access*      (current-seconds))  ;; update when db is accessed via server
(define *db-write-access*     #t)
(define *inmemdb*             #f)
(define *task-db*             #f) ;; (vector db path-to-db)








>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(define *alt-log-file* #f)  ;; used by -log

;; DATABASE
(define *dbstruct-db*  #f)
(define *db-stats* (make-hash-table)) ;; hash of vectors < count duration-total >
(define *db-stats-mutex*      (make-mutex))
(define *db-sync-mutex*       (make-mutex))
(define *db-multi-sync-mutex* (make-mutex))
(define *db-local-sync*       (make-hash-table)) ;; used to record last touch of db
(define *megatest-db*         #f)
(define *last-db-access*      (current-seconds))  ;; update when db is accessed via server
(define *db-write-access*     #t)
(define *inmemdb*             #f)
(define *task-db*             #f) ;; (vector db path-to-db)

Modified rmt.scm from [94b2588122] to [d4f16a53b3].

148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
    (let* ((start         (current-milliseconds))
	   (res           (api:execute-requests dbstruct-local (symbol->string cmd) params))
	   (duration      (- (current-milliseconds) start)))
      (rmt:update-db-stats cmd params duration)
      ;; mark this run as dirty if this was a write
      (if (not (member cmd api:read-only-queries))
	  (let ((start-time (current-seconds)))
	    (mutex-lock! *db-sync-mutex*)
	    (let ((last-sync (hash-table-ref/default *db-local-sync* run-id 0)))
	      (if (> (- start-time last-sync) 5) ;; every five seconds
		  (begin
		    (db:multi-db-sync (list run-id) 'new2old)
		    (debug:print-info 0 "Sync of newdb to olddb for run-id " run-id " completed in " (- (current-seconds) start-time) " seconds")
		    (hash-table-set! *db-local-sync* run-id start-time))))
	    (mutex-unlock! *db-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 (http-transport:client-api-send-receive run-id connection-info cmd jparams)))
    (if res







|






|







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
    (let* ((start         (current-milliseconds))
	   (res           (api:execute-requests dbstruct-local (symbol->string cmd) params))
	   (duration      (- (current-milliseconds) start)))
      (rmt:update-db-stats cmd params duration)
      ;; mark this run as dirty if this was a write
      (if (not (member cmd api:read-only-queries))
	  (let ((start-time (current-seconds)))
	    (mutex-lock! *db-multi-sync-mutex*)
	    (let ((last-sync (hash-table-ref/default *db-local-sync* run-id 0)))
	      (if (> (- start-time last-sync) 5) ;; every five seconds
		  (begin
		    (db:multi-db-sync (list run-id) 'new2old)
		    (debug:print-info 0 "Sync of newdb to olddb for run-id " run-id " completed in " (- (current-seconds) start-time) " seconds")
		    (hash-table-set! *db-local-sync* run-id start-time))))
	    (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 (http-transport:client-api-send-receive run-id connection-info cmd jparams)))
    (if res