-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-24788: Fix the connection leaks on getting hbase admin from unclosed connection #2162
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem to be a few more instances of this in the tests. Mind fixing them too?
git grep " ConnectionFactory.createConnection(" | grep getAdmin hbase-it/src/test/java/org/apache/hadoop/hbase/mapreduce/IntegrationTestBulkLoad.java: try (Connection conn = ConnectionFactory.createConnection(conf); Admin admin = conn.getAdmin(); hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableOutputFormat.java: try (Admin admin = ConnectionFactory.createConnection(hConf).getAdmin()) { hbase-server/src/main/java/org/apache/hadoop/hbase/util/ServerRegionReplicaUtil.java: Admin admin = ConnectionFactory.createConnection(conf).getAdmin(); hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicaWithCluster.java: Admin admin = ConnectionFactory.createConnection(HTU.getConfiguration()).getAdmin(); hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMasterReplication.java: ConnectionFactory.createConnection(configurations[masterClusterNumber]).getAdmin()) { hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java: Admin admin1 = ConnectionFactory.createConnection(conf1).getAdmin(); hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestPerTableCFReplication.java: Admin replicationAdmin = ConnectionFactory.createConnection(conf1).getAdmin(); hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java: hbaseAdmin = ConnectionFactory.createConnection(CONF1).getAdmin(); hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestGlobalReplicationThrottler.java: Admin admin1 = ConnectionFactory.createConnection(conf1).getAdmin(); hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java: Admin admin = ConnectionFactory.createConnection(HTU.getConfiguration()).getAdmin(); hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestRegionReplicaReplicationEndpoint.java: Admin admin = ConnectionFactory.createConnection(HTU.getConfiguration()).getAdmin(); hbase-shell/src/main/ruby/hbase/replication_admin.rb: @admin = ConnectionFactory.createConnection(configuration).getAdmin
*/ | ||
@Override | ||
public RecordWriter<KEY, Mutation> getRecordWriter(TaskAttemptContext context) | ||
throws IOException, InterruptedException { | ||
throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Check-style might flag this for bad indentation (needs nested indent)
|
||
try (Connection connection = ConnectionFactory.createConnection(conf); | ||
Admin admin = connection.getAdmin()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove extra newline
hbase-server/src/main/java/org/apache/hadoop/hbase/util/ServerRegionReplicaUtil.java
Show resolved
Hide resolved
🎊 +1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment, once addressed, can merge after a green build.
AsyncAdmin admin = | ||
ConnectionFactory.createAsyncConnection(HTU.getConfiguration()).get().getAdmin(); | ||
AsyncConnection conn = ConnectionFactory.createAsyncConnection(HTU.getConfiguration()).get(); | ||
AsyncAdmin admin = conn.getAdmin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a try-with-resources too?
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
c2b57d8
to
6b445ad
Compare
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
Changes look good, +1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed this in early scan. Seems like this is the issue with test failures.
} catch (ReplicationPeerNotFoundException e) { | ||
LOG.warn( | ||
"Region replica replication peer id=" + REGION_REPLICA_REPLICATION_PEER + " not exist", | ||
e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we catch this Exception, don't we want to create replication peer id?
We can model this with:
try(closeables){
try{
peerConfig = admin.getReplicationPeerConfig(REGION_REPLICA_REPLICATION_PEER);
} catch (ReplicationPeerNotFoundException e){
}
if (peerConfig == null) {
.....
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I was about to submit the change for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Fixing the connection leaks in hbase due to closing hbase admin without closing connection.