     func async(_ block: @escaping (Database) -> Void) {
         queue.async {
             block(self.db)
-            self.preconditionNoTransactionLeft(self.db)
+            self.preconditionNoUnsafeTransactionLeft(self.db)
         }
     }
     

        //
        // 1. A database is invoked from some queue like the main queue:
        //
        //      dbQueue.inDatabase { db in       // <-- we're here
        //      }
        //
        // 2. A database is invoked in a reentrant way:
        //
        //      dbQueue.inDatabase { db in
        //          dbQueue.inDatabase { db in   // <-- we're here
        //          }
        //      }
        //
        // 3. A database in invoked from another database:
        //
        //      dbQueue1.inDatabase { db1 in
        //          dbQueue2.inDatabase { db2 in // <-- we're here
        //          }
        //      }
        
        guard let watchdog = SchedulingWatchdog.current else {
            // Case 1
            return try queue.sync {
                defer { preconditionNoTransactionLeft(db) }
                return try block(db)
            }
        }
        
        // Case 2
        if watchdog.allows(db) {
            defer { preconditionNoTransactionLeft(db) }
            return try block(db)
        }
        
        // Case 3
        return try queue.sync {
            try SchedulingWatchdog.current!.inheritingAllowedDatabases(from: watchdog) {
                defer { preconditionNoTransactionLeft(db) }
                return try block(db)
            }
        }
    }

    }
    
    /// Fatal error if a transaction has been left opened.
    private func preconditionNoUnsafeTransactionLeft(_ db: Database, _ message: @autoclosure() -> String = "A transaction has been left opened at the end of a database access", file: StaticString = #file, line: UInt = #line) {
        GRDBPrecondition(configuration.allowsUnsafeTransactions || !db.isInsideTransaction, message, file: file, line: line)
    }
}
