-
-
Notifications
You must be signed in to change notification settings - Fork 82
Actually fix #347 #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Actually fix #347 #353
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #353 +/- ##
==========================================
+ Coverage 41.20% 41.83% +0.63%
==========================================
Files 117 117
Lines 9657 9668 +11
==========================================
+ Hits 3979 4045 +66
+ Misses 5678 5623 -55
|
@fabianfett No crash so far. 👍 But cancelled queries now return |
@trasch What did you get before? |
@fabianfett Nothing because it crashed before it could return an error... But my question was stupid anyway, I didn't properly look at the |
It would be nice if the |
@fabianfett
func testCancelTaskWhileLongRunningQuery() async throws {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer { XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully()) }
let eventLoop = eventLoopGroup.next()
let start = 1
let end = 1000000
let connectionClosesAfterCancel = self.expectation(description: "connection closes after cancel")
Task {
try await withTestConnection(on: eventLoop) { connection -> () in
// Uncommenting this will also crash:
// try await connection.query("SET statement_timeout=1000;", logger: .psqlTest)
let longRunningQuery = Task {
let rows = try await connection.query("SELECT generate_series(\(start), \(end));", logger: .psqlTest)
var counter = 0
do {
for try await element in rows.decode(Int.self, context: .default) {
XCTAssertEqual(element, counter + 1)
counter += 1
}
XCTFail("Expected to get cancelled while reading the query")
} catch is CancellationError {
// Expected
} catch {
XCTFail("Unexpected error: \(error)")
}
XCTAssertFalse(connection.isClosed, "Connection should survive!")
print("longRunningQuery done")
}
Task {
let delay = UInt64(0.2 * 1_000_000_000)
try await Task<Never, Never>.sleep(nanoseconds: delay)
print("Cancel!")
longRunningQuery.cancel()
}
try await longRunningQuery.value
}
connectionClosesAfterCancel.fulfill()
}
await fulfillment(of: [connectionClosesAfterCancel], timeout: 1.0)
} |
f23fd6a
to
9d80a9d
Compare
@trasch Can you give this another spin?! |
@fabianfett Awesome, short test worked, I will do a longer test run tomorrow |
9d80a9d
to
43a444a
Compare
The CI failures here are caused by this issue: |
In #351 we only landed a simple bandaid that didn't fix the underlying issue. Let's fix the real issue inside the state machine now.
cc @trasch can you very this please?
Fixes #347