diff --git a/Tests/GRDBTests/DatabasePoolReleaseMemoryTests.swift b/Tests/GRDBTests/DatabasePoolReleaseMemoryTests.swift index c3219279e..0b988c147 100644 --- a/Tests/GRDBTests/DatabasePoolReleaseMemoryTests.swift +++ b/Tests/GRDBTests/DatabasePoolReleaseMemoryTests.swift @@ -93,6 +93,27 @@ class DatabasePoolReleaseMemoryTests: GRDBTestCase { XCTAssertNotEqual(0, dbPool.numberOfReaders) } } + + // Regression test for + func testDatabasePoolDoesNotPreventConcurrentReadsOnPressureEvent() throws { + let dbPool = try makeDatabasePool() + + // Start a read that blocks + let semaphore = DispatchSemaphore(value: 0) + dbPool.asyncRead { _ in + semaphore.wait() + } + + // Simulate memory warning. + NotificationCenter.default.post(name: UIApplication.didReceiveMemoryWarningNotification, object: nil) + + // Make sure we can read + try dbPool.read { _ in } + + // Cleanup + semaphore.signal() + } + #endif // TODO: fix flaky test