()
| 1586 | #[mz_ore::test(tokio::test(flavor = "multi_thread", worker_threads = 2))] |
| 1587 | #[allow(clippy::disallowed_methods)] |
| 1588 | async fn test_github_12546() { |
| 1589 | let server = test_util::TestHarness::default() |
| 1590 | .with_propagate_crashes(false) |
| 1591 | .unsafe_mode() |
| 1592 | .start() |
| 1593 | .await; |
| 1594 | server |
| 1595 | .enable_feature_flags(&["unsafe_enable_unsafe_functions"]) |
| 1596 | .await; |
| 1597 | |
| 1598 | let (client, conn_task) = server.connect().with_handle().await.unwrap(); |
| 1599 | |
| 1600 | client |
| 1601 | .batch_execute("CREATE TABLE test(a text);") |
| 1602 | .await |
| 1603 | .unwrap(); |
| 1604 | client |
| 1605 | .batch_execute("INSERT INTO test VALUES ('a');") |
| 1606 | .await |
| 1607 | .unwrap(); |
| 1608 | |
| 1609 | let query = client.query("SELECT mz_unsafe.mz_panic(a) FROM test", &[]); |
| 1610 | let timeout = tokio::time::timeout(Duration::from_secs(2), query); |
| 1611 | // We expect the timeout to trigger because the query should be crashing the |
| 1612 | // compute instance. |
| 1613 | assert_eq!( |
| 1614 | timeout.await.unwrap_err().to_string(), |
| 1615 | "deadline has elapsed" |
| 1616 | ); |
| 1617 | |
| 1618 | // Aborting the connection should cause its pending queries to be cancelled, |
| 1619 | // allowing the compute instances to stop crashing while trying to execute |
| 1620 | // them. |
| 1621 | // |
| 1622 | // We need to await `conn_task` to actually deliver the `abort`. |
| 1623 | conn_task.abort_and_wait().await; |
| 1624 | |
| 1625 | // Make a new connection to verify the compute instance can now start. |
| 1626 | let client = server.connect().await.unwrap(); |
| 1627 | assert_eq!( |
| 1628 | client |
| 1629 | .query_one("SELECT count(*) FROM test", &[]) |
| 1630 | .await |
| 1631 | .unwrap() |
| 1632 | .get::<_, i64>(0), |
| 1633 | 1, |
| 1634 | ); |
| 1635 | } |
| 1636 | |
| 1637 | /// Regression test for database-issues#3721. |
| 1638 | #[mz_ore::test] |
nothing calls this directly
no test coverage detected