Megatest

Check-in [8639a32fde]
Login
Overview
Comment:merged in code to show detail of failure if dbopen fails
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.63-09c-candidate
Files: files | file ages | folders
SHA1: 8639a32fde26b2ee2c322a84daa19c04ecf784c3
User & Date: bjbarcla on 2017-03-07 09:44:16
Other Links: branch diff | manifest | tags
Context
2017-03-07
09:46
merged in fixes for COMPLETE/COMPLETED state wrong name, client-setup crash bug check-in: 6bdeae43f3 user: bjbarcla tags: v1.63-09c-candidate
09:44
merged in code to show detail of failure if dbopen fails check-in: 8639a32fde user: bjbarcla tags: v1.63-09c-candidate
09:42
merged in protection against being unable to write test log due to nfs lag, etc check-in: bad879cb5e user: bjbarcla tags: v1.63-09c-candidate
2017-03-02
15:45
Wrapped database open commands with detailed error handling messages. Closed-Leaf check-in: e8d3292a50 user: matt tags: condition-case-db-open
Changes

Modified db.scm from [8fbbea621c] to [3a79b14dea].

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236







237
238
239
240
241






242
243
244
245
246
247
248
	 (dir-writable (file-write-access? parent-dir))
	 (file-exists  (file-exists? fname))
	 (file-write   (if file-exists
			   (file-write-access? fname)
			   dir-writable )))
    ;;(mutex-lock! *db-open-mutex*) ;; tried this mutex, not clear it helped.
    (if file-write ;; dir-writable
	(let (;; (lock    (obtain-dot-lock fname 1 5 10))
	      (db      (sqlite3:open-database fname)))
	  (sqlite3:set-busy-handler! db (make-busy-timeout 136000))
	  ;; (db:set-sync db)
	  (sqlite3:execute db "PRAGMA synchronous = 0;")
	  (if (not file-exists)
              (begin
		(if (and (configf:lookup *configdat* "setup" "use-wal")
                         (string-match "^/tmp/.*" fname)) ;; this is a file in /tmp
		    (sqlite3:execute db "PRAGMA journal_mode=WAL;")
		    (print "Creating " fname " in NON-WAL mode."))
		(initproc db)))
	  ;; (release-dot-lock fname)
          ;;(mutex-unlock! *db-open-mutex*)
	  db)







	(begin
	  (debug:print 2 *default-log-port* "WARNING: opening db in non-writable dir " fname)
	  (let ((db (sqlite3:open-database fname)))
            ;;(mutex-unlock! *db-open-mutex*)
            db))))) ;; )












;; ;; This routine creates the db. It is only called if the db is not already opened







|
|
|
<
|
|
|
|
|
|
|
|
<
<
|
>
>
>
>
>
>
>
|
|
|
|
|
>
>
>
>
>
>







215
216
217
218
219
220
221
222
223
224

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
	 (dir-writable (file-write-access? parent-dir))
	 (file-exists  (file-exists? fname))
	 (file-write   (if file-exists
			   (file-write-access? fname)
			   dir-writable )))
    ;;(mutex-lock! *db-open-mutex*) ;; tried this mutex, not clear it helped.
    (if file-write ;; dir-writable
	(condition-case
	    (let ((db      (sqlite3:open-database fname)))
	      (sqlite3:set-busy-handler! db (make-busy-timeout 136000))

	      (sqlite3:execute db "PRAGMA synchronous = 0;")
	      (if (not file-exists)
		  (begin
		    (if (and (configf:lookup *configdat* "setup" "use-wal")
			     (string-match "^/tmp/.*" fname)) ;; this is a file in /tmp
			(sqlite3:execute db "PRAGMA journal_mode=WAL;")
			(print "Creating " fname " in NON-WAL mode."))
		    (initproc db)))


	      db)
	  (exn (io-error)  (debug:print 0 *default-log-port* "ERROR: i/o error with " fname ". Check permissions, disk space etc. and try again."))
	  (exn (corrupt)   (debug:print 0 *default-log-port* "ERROR: database " fname " is corrupt. Repair it to proceed."))
	  (exn (busy)      (debug:print 0 *default-log-port* "ERROR: database " fname " is locked. Try copying to another location, remove original and copy back."))
	  (exn (permission)(debug:print 0 *default-log-port* "ERROR: database " fname " has some permissions problem."))
	  (exn () (debug:print 0 *default-log-port* "ERROR: Unknown error with database " fname " message: " ((condition-property-accessor 'exn 'message) exn))))

	(condition-case
	    (begin
	      (debug:print 2 *default-log-port* "WARNING: opening db in non-writable dir " fname)
	      (let ((db (sqlite3:open-database fname)))
		;;(mutex-unlock! *db-open-mutex*)
		db))
	  (exn (io-error)  (debug:print 0 *default-log-port* "ERROR: i/o error with " fname ". Check permissions, disk space etc. and try again."))
	  (exn (corrupt)   (debug:print 0 *default-log-port* "ERROR: database " fname " is corrupt. Repair it to proceed."))
	  (exn (busy)      (debug:print 0 *default-log-port* "ERROR: database " fname " is locked. Try copying to another location, remove original and copy back."))
	  (exn (permission)(debug:print 0 *default-log-port* "ERROR: database " fname " has some permissions problem."))
	  (exn () (debug:print 0 *default-log-port* "ERROR: Unknown error with database " fname " message: " ((condition-property-accessor 'exn 'message) exn))))
	)))






;; ;; This routine creates the db. It is only called if the db is not already opened