Megatest

Check-in [9062c1c10d]
Login
Overview
Comment:Added exception handlers on transactions on sync and in one additional with-input in simple locks.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.80
Files: files | file ages | folders
SHA1: 9062c1c10d1b5780df5fd8dd596fe656c7777810
User & Date: matt on 2023-05-24 04:16:27
Other Links: branch diff | manifest | tags
Context
2023-05-24
18:39
guarded a create-directory with directory-exists? check-in: 60290c5f00 user: mmgraham tags: v1.80
06:24
Separate dbs for dashboard. check-in: ea08cd04fb user: matt tags: v1.80-dboard-dbs
04:16
Added exception handlers on transactions on sync and in one additional with-input in simple locks. check-in: 9062c1c10d user: matt tags: v1.80
2023-05-23
20:48
Simplify the locking scenario for sync check-in: cdf8c77efe user: matt tags: v1.80
Changes

Modified dbfile.scm from [dc50b23038] to [5c3217f805].

1406
1407
1408
1409
1410
1411
1412



1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
        )
    (if gotlock
	(let ((res (proc)))
	  (dbfile:simple-file-release-lock fname)
	  res)
        (begin
          (dbfile:print-err "dbfile:with-simple-file-lock: " fname " is locked by "



			    (with-input-from-file fname
			      (lambda ()
				(dbfile:print-err (read-line)))))
          (dbfile:print-err "wait time = " (- end-time start-time))
	  (dbfile:print-err "ERROR: simple file lock could not get a lock for " fname " in " expire-time " seconds")
	  (if run-anyway
	      (let ((res (proc)))
		(dbfile:simple-file-release-lock fname)
		res)
	      #f)))))







>
>
>
|
|
|







1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
        )
    (if gotlock
	(let ((res (proc)))
	  (dbfile:simple-file-release-lock fname)
	  res)
        (begin
          (dbfile:print-err "dbfile:with-simple-file-lock: " fname " is locked by "
			    (handle-exceptions
				exn
				"unreadable"
			      (with-input-from-file fname
				(lambda ()
				  (read-line)))))
          (dbfile:print-err "wait time = " (- end-time start-time))
	  (dbfile:print-err "ERROR: simple file lock could not get a lock for " fname " in " expire-time " seconds")
	  (if run-anyway
	      (let ((res (proc)))
		(dbfile:simple-file-release-lock fname)
		res)
	      #f)))))

Modified dbmod.scm from [72e5b21e7c] to [9a189716e8].

529
530
531
532
533
534
535



536
537
538
539
540
541

542



543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
		    (changedrec (conc "SELECT "fromdb table".id FROM "fromdb table" join "todb table" on "fromdb table".id="todb table".id WHERE "fromdb table".last_update > "todb table".last_update;"))
                                    ;; SELECT main.tests.id FROM main.tests join auxdb.tests on main.tests.id=auxdb.tests.id WHERE main.tests.last_update > auxdb.tests.last_update;"
		    (start-ms   (current-milliseconds))
		    (new-ids    (sqlite3:fold-row (lambda (res id)(cons id res)) '() dbh newrec)))
	       ;; (debug:print 0 *default-log-port* "Got "(length aux-ids)" in aux-ids and "(length main-ids)" in main-ids")
	       (update-changed (length new-ids) table "new records")
	       (mutex-lock! *db-transaction-mutex*)



	       (sqlite3:with-transaction
		dbh
		(lambda ()
		  (for-each (lambda (id)
			      (sqlite3:execute dbh stmt2 id))
			    new-ids)))

	       (if (member "last_update" fields)



		   (sqlite3:with-transaction
		    dbh
		    (lambda ()
		      (let* ((changed-ids  (sqlite3:fold-row (lambda (res id)(cons id res)) '() dbh changedrec)))
			(update-changed (length changed-ids) table "changed records")
			(for-each (lambda (id)
				    (sqlite3:execute dbh stmt9 id id))
				  changed-ids)))))
	       
	       (mutex-unlock! *db-transaction-mutex*)
	       
	       (debug:print 0 *default-log-port* "Synced table "table
	        	    " in "(- (current-milliseconds) start-ms)"ms")
	       
	       ))
	   table-names)







>
>
>
|
|
|
|
|
|
>

>
>
>
|
|
|
|
|
|
|
|
|







529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
		    (changedrec (conc "SELECT "fromdb table".id FROM "fromdb table" join "todb table" on "fromdb table".id="todb table".id WHERE "fromdb table".last_update > "todb table".last_update;"))
                                    ;; SELECT main.tests.id FROM main.tests join auxdb.tests on main.tests.id=auxdb.tests.id WHERE main.tests.last_update > auxdb.tests.last_update;"
		    (start-ms   (current-milliseconds))
		    (new-ids    (sqlite3:fold-row (lambda (res id)(cons id res)) '() dbh newrec)))
	       ;; (debug:print 0 *default-log-port* "Got "(length aux-ids)" in aux-ids and "(length main-ids)" in main-ids")
	       (update-changed (length new-ids) table "new records")
	       (mutex-lock! *db-transaction-mutex*)
	       (handle-exceptions
		   exn
		   (debug:print 0 *default-log-port* "Transaction update of "table" failed.")
		 (sqlite3:with-transaction
		  dbh
		  (lambda ()
		    (for-each (lambda (id)
				(sqlite3:execute dbh stmt2 id))
			      new-ids))))
	       
	       (if (member "last_update" fields)
		   (handle-exceptions
		       exn
		       (debug:print 0 *default-log-port* "Transaction update of "table" failed.")
		     (sqlite3:with-transaction
		      dbh
		      (lambda ()
			(let* ((changed-ids  (sqlite3:fold-row (lambda (res id)(cons id res)) '() dbh changedrec)))
			  (update-changed (length changed-ids) table "changed records")
			  (for-each (lambda (id)
				      (sqlite3:execute dbh stmt9 id id))
				    changed-ids))))))
		   
	       (mutex-unlock! *db-transaction-mutex*)
	       
	       (debug:print 0 *default-log-port* "Synced table "table
	        	    " in "(- (current-milliseconds) start-ms)"ms")
	       
	       ))
	   table-names)