Skip to content

Commit ac700fa

Browse files
committed
Leak the database connection and thread upon rollback error
It should be possible to handle this much better in diesel 2.0.
1 parent 898d3dd commit ac700fa

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/swirl/runner.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,18 @@ impl Runner {
190190
break;
191191
}
192192
warn!("Rolling back a transaction due to a panic in a background task");
193-
let _ = transaction_manager
193+
match transaction_manager
194194
.rollback_transaction(conn)
195-
.map_err(|e| error!("Error while rolling back transaction: {e}"));
195+
{
196+
Ok(_) => (),
197+
Err(e) => {
198+
error!("Leaking a thread and database connection because of an error while rolling back transaction: {e}");
199+
loop {
200+
std::thread::sleep(Duration::from_secs(24 * 60 * 60));
201+
error!("How am I still alive?");
202+
}
203+
}
204+
}
196205
}
197206

198207
match result {

0 commit comments

Comments
 (0)