Megatest

Check-in [ddb31b7dde]
Login
Overview
Comment:Improved some exception handling to fail more gracefully
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.60
Files: files | file ages | folders
SHA1: ddb31b7dde8af702d305dfda56c2f581a5427611
User & Date: matt on 2014-03-16 20:49:48
Other Links: branch diff | manifest | tags
Context
2014-03-17
23:20
Moved database into linktree/.db/ check-in: 2db911bdaf user: matt tags: v1.60
2014-03-16
20:49
Improved some exception handling to fail more gracefully check-in: ddb31b7dde user: matt tags: v1.60
06:41
Simplified client:setup based on assuming that retries for communications problems are handled in the http-client module check-in: 530e6e23bd user: matt tags: v1.60
Changes

Modified lock-queue.scm from [e008712ec5] to [5c82c36b12].

45
46
47
48
49
50
51
52

53
54



55
56





57
58
59
60
61

62
63



64
65





66
67
68
69
70
71
72
45
46
47
48
49
50
51

52
53
54
55
56
57


58
59
60
61
62
63
64
65
66

67
68
69
70
71
72


73
74
75
76
77
78
79
80
81
82
83
84







-
+


+
+
+
-
-
+
+
+
+
+




-
+


+
+
+
-
-
+
+
+
+
+







              id         INTEGER PRIMARY KEY,
              test_id    INTEGER,
              run_lock   TEXT,
              CONSTRAINT runlock_constraint UNIQUE (run_lock));")))
    (sqlite3:set-busy-handler! db handler)
    db))

(define (lock-queue:set-state db test-id newstate)
(define (lock-queue:set-state db test-id newstate #!key (remtries 10))
  (handle-exceptions
   exn
   (if (> remtries 0)
       (begin
	 (debug:print 0 "WARNING: exception on lock-queue:set-state. Trying again in 30 seconds.")
   (thread-sleep! 30)
   (lock-queue:set-state db test-id newstate)
	 (thread-sleep! 30)
	 (lock-queue:set-state db test-id newstate remtries: (- remtries 1)))
       (begin
	 (debug:print 0 "ERROR:  Failed to set lock state for test with id " test-id ", error: " ((condition-property-accessor 'exn 'message) exn) ", giving up.")
	 #f))
   (sqlite3:execute db "UPDATE queue SET state=? WHERE test_id=?;"
		    newstate
		    test-id)))

(define (lock-queue:any-younger? db mystart test-id)
(define (lock-queue:any-younger? db mystart test-id #!key (remtries 10))
  (handle-exceptions
   exn
   (if (> remtries 0)
       (begin
	 (debug:print 0 "WARNING: exception on lock-queue:any-younger. Trying again in 30 seconds.")
   (thread-sleep! 30)
   (lock-queue:any-younger? db mystart test-id)
	 (thread-sleep! 30)
	 (lock-queue:any-younger? db mystart test-id remtries: (- remtries 1)))
       (begin
	 (debug:print 0 "ERROR:  Failed to find younger locks for test with id " test-id ", error: " ((condition-property-accessor 'exn 'message) exn) ", giving up.")
	 #f))
   (let ((res #f))
     (sqlite3:for-each-row
      (lambda (tid)
	;; Actually this should not be needed as mystart cannot be simultaneously less than and test-id same as 
	(if (not (equal? tid test-id)) 
	    (set! res tid)))
      db

Modified tdb.scm from [fd0c5aa4a1] to [de69c98c94].

53
54
55
56
57
58
59
60


61
62
63
64
65
66
67
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67
68







-
+
+







					       (string->number (args:get-arg "-override-timeout"))
					       136000))))
	(handle-exceptions
	 exn
	 (begin
	   (debug:print 2 "ERROR: problem accessing test db " work-area ", you probably should clean and re-run this test"
			((condition-property-accessor 'exn 'message) exn))
	   (set! db (sqlite3:open-database ":memory:"))) ;; open an in-memory db to allow readonly access 
	   (set! db (sqlite3:open-database ":memory:")) ;; open an in-memory db to allow readonly access 
	   (set! dbexists #f)) ;; must force re-creation of tables, more tom-foolery
	 (set! db (sqlite3:open-database dbpath)))
	(if *db-write-access* (sqlite3:set-busy-handler! db handler))
	(if (not dbexists)
	    (begin
	      (sqlite3:execute db "PRAGMA synchronous = FULL;")
	      (debug:print-info 11 "Initialized test database " dbpath)
	      (tdb:testdb-initialize db)))