Megatest

Check-in [049806b5f6]
Login
Overview
Comment:Disable mutex in dbmod:with-db as it was blocking forever
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.90
Files: files | file ages | folders
SHA1: 049806b5f65d44eccc7a77f7dd13b23376a2583a
User & Date: matt on 2024-02-15 20:43:40
Other Links: branch diff | manifest | tags
Context
2024-03-10
20:49
Preparing to implement dedicated process for caching configs, http transport and new server start handshake Leaf check-in: 69fa6b4201 user: matt tags: v1.90
2024-02-15
20:43
Disable mutex in dbmod:with-db as it was blocking forever check-in: 049806b5f6 user: matt tags: v1.90
19:32
Removed few more non-module compilation unit files check-in: 6ccaee78f1 user: matt tags: v1.90
Changes

Modified dbmod.scm from [c78d2e0924] to [af102aa97d].

28
29
30
31
32
33
34

35
36
37
38
39
40
41
(declare (uses mtmod))

(module dbmod
	(
	 ;; for debug, can be commented out in production
	 dbmod:safely-open-db
	 dbmod:with-db


	 ;; used elsewhere, keep
	 dbmod:db-to-db-sync
	 
	 db:test-get-event_time
	 db:test-get-item-path
	 db:test-get-testname







>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(declare (uses mtmod))

(module dbmod
	(
	 ;; for debug, can be commented out in production
	 dbmod:safely-open-db
	 dbmod:with-db
	 dbmod:open-db

	 ;; used elsewhere, keep
	 dbmod:db-to-db-sync
	 
	 db:test-get-event_time
	 db:test-get-item-path
	 db:test-get-testname
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
	  (begin
	    (sync-proc last-update)

	    ;; MOVE THIS CALL TO INSIDE THE sync-proc CALL
	    (dbr:dbstruct-last-update-set! dbstruct curr-secs)
	    )))
    (assert (sqlite3:database? dbh) "FATAL: bad db handle in dbmod:with-db") 
    (if use-mutex (mutex-lock! *db-with-db-mutex*))
    (let* ((res (let loop ((count 10))
		  (condition-case
		   (apply proc dbdat dbh params)
		   (exn (sqlite3) ;; was 'busy', but never got hit
			(if (> count 0)
			    (begin
			      (debug:print-info 0 *default-log-port* "dbmod:with-db, database is busy, will try "count" more times.")
			      (thread-sleep! 1)
			      (loop (- count 1)))
			    (begin
			      (debug:print-info 0 *default-log-port* "dbmod:with-db, database is busy, giving up. params: "params)
			      (exit 1))))
		   (exn (locked)
			(dbfile:print-err exn "ERROR: dbmod:with-db: database locked for run-id "run-id", params "params", message: "
					  ((condition-property-accessor 'exn 'message) exn)))
		   (exn ()
			(dbfile:print-err exn "ERROR: dbmod:with-db: Unknown error with database for run-id "run-id", params "params", message: "
					  ((condition-property-accessor 'exn 'message) exn))
			(exit 2))))))
      (if use-mutex (mutex-unlock! *db-with-db-mutex*))
      res)))

(define (db:with-db dbstruct run-id w/r proc . params)
  (dbmod:with-db dbstruct run-id w/r proc params))

;; 
(define (dbmod:open-cachedb-db init-proc dbfullname)







|



















|







297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
	  (begin
	    (sync-proc last-update)

	    ;; MOVE THIS CALL TO INSIDE THE sync-proc CALL
	    (dbr:dbstruct-last-update-set! dbstruct curr-secs)
	    )))
    (assert (sqlite3:database? dbh) "FATAL: bad db handle in dbmod:with-db") 
    ;; (if use-mutex (mutex-lock! *db-with-db-mutex*)) ;; this mutex was causing deadlock. Found in fullrun test.
    (let* ((res (let loop ((count 10))
		  (condition-case
		   (apply proc dbdat dbh params)
		   (exn (sqlite3) ;; was 'busy', but never got hit
			(if (> count 0)
			    (begin
			      (debug:print-info 0 *default-log-port* "dbmod:with-db, database is busy, will try "count" more times.")
			      (thread-sleep! 1)
			      (loop (- count 1)))
			    (begin
			      (debug:print-info 0 *default-log-port* "dbmod:with-db, database is busy, giving up. params: "params)
			      (exit 1))))
		   (exn (locked)
			(dbfile:print-err exn "ERROR: dbmod:with-db: database locked for run-id "run-id", params "params", message: "
					  ((condition-property-accessor 'exn 'message) exn)))
		   (exn ()
			(dbfile:print-err exn "ERROR: dbmod:with-db: Unknown error with database for run-id "run-id", params "params", message: "
					  ((condition-property-accessor 'exn 'message) exn))
			(exit 2))))))
      ;; (if use-mutex (mutex-unlock! *db-with-db-mutex*))
      res)))

(define (db:with-db dbstruct run-id w/r proc . params)
  (dbmod:with-db dbstruct run-id w/r proc params))

;; 
(define (dbmod:open-cachedb-db init-proc dbfullname)