3 Replies Latest reply on Jun 9, 2015 3:06 PM by Philippe Marschall

    Wildfly 8.2 ResultSet hangs

    pkolaric Newbie

      Hello,

       

      We've stumbled upon a strange ?bug? that causes a ResultSet.next() to hang.

      Requirements:

      - query a table with more records than fetchSize

      - execute a second query on the _same_ connection as the previous one

       

      The first ResultSet.next() will fail (just hang, without any exception) when it reaches the "fetchSize" count.

       

       

      It is reproducable by this code snippet which works fine outside of wildfly, but not in wildfly.

       

      try (Connection conn = ds.getConnection()) {

                      try (PreparedStatement ps = conn.prepareStatement("SELECT * FROM some_table")) {

                          ps.setFetchSize(1000);

                          try (ResultSet rs = ps.executeQuery()) {

                              int i=0;

                              while (rs.next()) {

                                  i++;

                                 

                                  if (i==800) {

                                      try (PreparedStatement ps2 = conn.prepareStatement("SELECT * FROM other_table WHERE id=10")) {

                                          try(ResultSet rs2 = ps2.executeQuery()) {

                                              while (rs2.next()) {

                                                  System.out.println("got data!");

                                              }

                                          }

                                      }

                                  }

                                  if (i % 100 == 0) {

                                      System.out.println("i="+i);

                                  }

                              }

                          }

                      }

                  }

       


      I've tested in on Wildfly8.2 and Wildfly9.

      The database is postgres 9.2

      The JDBC driver is pgjdbc-ng 0.5 (http://impossibl.github.io/pgjdbc-ng/get.html)

       

       

      Is this a bug in wildfly (IronJacamar) or am i doing something wrong?