swaroopak commented on a change in pull request #746: PHOENIX-5802: Connection
leaks in UPSERT SELECT/DELETE paths due to MutatingParallelIteratorFactory
iterator not being closed
URL: https://github.com/apache/phoenix/pull/746#discussion_r399414732
##########
File path:
phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java
##########
@@ -1353,49 +1504,58 @@ public void
testUpsertSelectWithFixedWidthNullByteSizeArray() throws Exception {
Properties props = new Properties();
props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS,
allowServerSideMutations);
- Connection conn = DriverManager.getConnection(getUrl(), props);
String t1 = generateUniqueName();
- conn.createStatement().execute(
- "create table " + t1 + " (id bigint not null primary key, ca
char(3)[])");
- conn.close();
+ ResultSet rs;
- conn = DriverManager.getConnection(getUrl(), props);
- conn.createStatement().execute("upsert into " + t1 + " values (1,
ARRAY['aaa', 'bbb'])");
- conn.commit();
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ conn.createStatement().execute(
+ "create table " + t1 + " (id bigint not null primary key,
ca char(3)[])");
+ }
- conn = DriverManager.getConnection(getUrl(), props);
- conn.createStatement().execute(
- "upsert into " + t1 + " (id, ca) select id, ARRAY['ccc',
'ddd'] from " + t1 + " WHERE id = 1");
- conn.commit();
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ conn.createStatement().execute("upsert into " + t1 +
+ " values (1, ARRAY['aaa', 'bbb'])");
+ conn.commit();
+ }
- conn = DriverManager.getConnection(getUrl(), props);
- ResultSet rs = conn.createStatement().executeQuery("select * from " +
t1);
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ conn.createStatement().execute("upsert into " + t1 + " (id, ca)
select id, " +
+ "ARRAY['ccc', 'ddd'] from " + t1 + " WHERE id = 1");
+ conn.commit();
+ }
- assertTrue(rs.next());
- assertEquals(1, rs.getLong(1));
- assertEquals("['ccc', 'ddd']", rs.getArray(2).toString());
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ rs = conn.createStatement().executeQuery("select * from " + t1);
+ assertTrue(rs.next());
+ assertEquals(1, rs.getLong(1));
+ assertEquals("['ccc', 'ddd']", rs.getArray(2).toString());
+
+ }
- conn = DriverManager.getConnection(getUrl(), props);
String t2 = generateUniqueName();
- conn.createStatement().execute(
- "create table " + t2 + " (id bigint not null primary key, ba
binary(4)[])");
- conn.close();
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ conn.createStatement().execute("create table " + t2 +
+ " (id bigint not null primary key, ba binary(4)[])");
+ }
- conn = DriverManager.getConnection(getUrl(), props);
- conn.createStatement().execute("upsert into " + t2 + " values (2,
ARRAY[1, 27])");
- conn.commit();
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ conn.createStatement().execute("upsert into " + t2 + " values (2,
ARRAY[1, 27])");
+ conn.commit();
+ }
- conn = DriverManager.getConnection(getUrl(), props);
- conn.createStatement().execute(
- "upsert into " + t2 + " (id, ba) select id, ARRAY[54, 1024]
from " + t2 + " WHERE id = 2");
- conn.commit();
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ conn.createStatement().execute("upsert into " + t2 + " (id, ba)
select id, " +
+ "ARRAY[54, 1024] from " + t2 + " WHERE id = 2");
+ conn.commit();
+ }
- conn = DriverManager.getConnection(getUrl(), props);
- rs = conn.createStatement().executeQuery("select * from " + t2);
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ rs = conn.createStatement().executeQuery("select * from " + t2);
Review comment:
why is this space diff different from other space diffs?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services