Skip to content

Commit 09bed8e

Browse files
committed
envd: fix a flaky unit test
This commit unflakes a unit test (previously `test_github_12951`, now renamed to match the current database-issues numbers). The test would start a subscribe, then drop the subscribe's cluster, then cancel the subscribe. This was necessary because adapter used to not abort subscribes when their cluster was dropped. Without canceling the subscribe, it would simply hang forever. We since fixed this behavior, so now the subscribe is canceled when its cluster is dropped, making the cancellation unnecessary. What's worse, the cancellation now also makes the test flaky. The postgres client issues the cancellation by spawning a new thread, creating a new database connection, and issuing a cancel request on that connection. It does not wait for the cancellation to be successful. So in the test, an arbitrary query following the subscribe could be canceled, causing the test to fail. The fix is to remove the cancellation request, as it's not needed anymore.
1 parent 8736312 commit 09bed8e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/environmentd/tests/sql.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,15 +1589,15 @@ async fn test_github_12546() {
15891589
);
15901590
}
15911591

1592+
/// Regression test for database-issues#3721.
15921593
#[mz_ore::test]
1593-
fn test_github_12951() {
1594+
fn test_github_3721() {
15941595
let server = test_util::TestHarness::default().start_blocking();
15951596

15961597
// Verify sinks (SUBSCRIBE) are correctly handled for a dropped cluster.
15971598
{
15981599
let mut client1 = server.connect(postgres::NoTls).unwrap();
15991600
let mut client2 = server.connect(postgres::NoTls).unwrap();
1600-
let client2_cancel = client2.cancel_token();
16011601

16021602
client1
16031603
.batch_execute("CREATE CLUSTER foo REPLICAS (r1 (size 'scale=1,workers=1'))")
@@ -1610,7 +1610,6 @@ fn test_github_12951() {
16101610
)
16111611
.unwrap();
16121612
client1.batch_execute("DROP CLUSTER foo CASCADE").unwrap();
1613-
client2_cancel.cancel_query(postgres::NoTls).unwrap();
16141613
client2
16151614
.batch_execute("ROLLBACK; SET CLUSTER = default")
16161615
.unwrap();

0 commit comments

Comments
 (0)