HBASE-24788: Fix the connection leaks on getting hbase admin from unclosed connection (#2170)
Rewrote the patch for branch-1 since master has significanly diverged. (cherry picked from commit dc5ef7af1f8b9e386495a73924c9442203f65a77) Co-authored-by: Bharath Vissapragada <bharathv@apache.org> Signed-off-by: Bharath Vissapragada <bharathv@apache.org> Signed-off-by: Sandeep Pal <50725353+sandeepvinayak@users.noreply.github.com> Co-authored-by: Sandeep Pal <50725353+sandeepvinayak@users.noreply.github.com>
This commit is contained in:
parent
daeccb1c46
commit
ac576d23e5
|
@ -173,8 +173,8 @@ implements Configurable {
|
|||
@Override
|
||||
public void checkOutputSpecs(JobContext context) throws IOException,
|
||||
InterruptedException {
|
||||
|
||||
try (Admin admin = ConnectionFactory.createConnection(getConf()).getAdmin()) {
|
||||
try (Connection conn = ConnectionFactory.createConnection(getConf());
|
||||
Admin admin = conn.getAdmin()) {
|
||||
TableName tableName = TableName.valueOf(this.conf.get(OUTPUT_TABLE));
|
||||
if (!admin.tableExists(tableName)) {
|
||||
throw new TableNotFoundException("Can't write, table does not exist:" +
|
||||
|
|
|
@ -145,12 +145,10 @@ public class TestReplicationBase {
|
|||
table.addFamily(fam);
|
||||
fam = new HColumnDescriptor(noRepfamName);
|
||||
table.addFamily(fam);
|
||||
Connection connection1 = ConnectionFactory.createConnection(conf1);
|
||||
Connection connection2 = ConnectionFactory.createConnection(conf2);
|
||||
try (Admin admin1 = connection1.getAdmin()) {
|
||||
Connection connection1 = utility1.getConnection();
|
||||
Connection connection2 = utility2.getConnection();
|
||||
try (Admin admin1 = connection1.getAdmin(); Admin admin2 = connection2.getAdmin()) {
|
||||
admin1.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
|
||||
}
|
||||
try (Admin admin2 = connection2.getAdmin()) {
|
||||
admin2.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
|
||||
}
|
||||
utility1.waitUntilAllRegionsAssigned(tableName);
|
||||
|
|
|
@ -518,12 +518,10 @@ public class TestReplicationSmallTests extends TestReplicationBase {
|
|||
fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
|
||||
table.addFamily(fam);
|
||||
|
||||
Connection connection1 = ConnectionFactory.createConnection(conf1);
|
||||
Connection connection2 = ConnectionFactory.createConnection(conf2);
|
||||
try (Admin admin1 = connection1.getAdmin()) {
|
||||
try (Admin admin1 = utility1.getConnection().getAdmin()) {
|
||||
admin1.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
|
||||
}
|
||||
try (Admin admin2 = connection2.getAdmin()) {
|
||||
try (Admin admin2 = utility2.getConnection().getAdmin()) {
|
||||
admin2.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
|
||||
}
|
||||
utility1.waitUntilAllRegionsAssigned(tablename);
|
||||
|
|
|
@ -303,14 +303,9 @@ public class TestNamespaceCommands extends SecureTestUtil {
|
|||
AccessTestAction listAction = new AccessTestAction() {
|
||||
@Override
|
||||
public Object run() throws Exception {
|
||||
Connection unmanagedConnection =
|
||||
ConnectionFactory.createConnection(UTIL.getConfiguration());
|
||||
Admin admin = unmanagedConnection.getAdmin();
|
||||
try {
|
||||
try (Connection conn = ConnectionFactory.createConnection(UTIL.getConfiguration());
|
||||
Admin admin = conn.getAdmin()) {
|
||||
return Arrays.asList(admin.listNamespaceDescriptors());
|
||||
} finally {
|
||||
admin.close();
|
||||
unmanagedConnection.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue