Skip to content
Permalink
Browse files
fix unstable test. Originally this would loop creating many statement…
…s, now it should timeout properly (#1650)
  • Loading branch information
davecramer committed Dec 16, 2019
1 parent 617f048 commit aaccf431f444df80cfed7633a12bd77d63a4b1fc
Showing with 2 additions and 2 deletions.
  1. +2 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/StatementTest.java
@@ -722,15 +722,15 @@ public void testLongQueryTimeout() throws SQLException {
public void testShortQueryTimeout() throws SQLException {
assumeLongTest();

long deadLine = System.nanoTime() + 10000 * 1000000;
long deadLine = System.nanoTime() + (long)(10 * 1E9);
Statement stmt = con.createStatement();
((PgStatement) stmt).setQueryTimeoutMs(1);
Statement stmt2 = con.createStatement();
while (System.nanoTime() < deadLine) {
try {
// This usually won't time out but scheduler jitter, server load
// etc can cause a timeout.
stmt.executeQuery("select 1;");
stmt.executeQuery("select pg_sleep(1);");
} catch (SQLException e) {
// Expect "57014 query_canceled" (en-msg is "canceling statement due to statement timeout")
// but anything else is fatal. We can't differentiate other causes of statement cancel like

0 comments on commit aaccf43

Please sign in to comment.