Skip to content

Commit

Permalink
[fix](connection)Add more log for Reach limit of connections (#45939)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jibing-Li authored Dec 25, 2024
1 parent 8e57386 commit 345e9ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1345,4 +1345,9 @@ public void setMysqlHandshakePacket(MysqlHandshakePacket mysqlHandshakePacket) {
public byte[] getAuthPluginData() {
return mysqlHandshakePacket == null ? null : mysqlHandshakePacket.getAuthPluginData();
}

@Override
public String toString() {
return getClass().getName() + "@" + Integer.toHexString(hashCode()) + ":" + qualifiedUser;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,20 @@ public boolean submit(ConnectContext context) {
// Register one connection with its connection id.
public boolean registerConnection(ConnectContext ctx) {
if (numberConnection.incrementAndGet() > maxConnections) {
LOG.info("Number connection {} has reach upper limit {}. Connection map : [{}]",
numberConnection.get(), maxConnections, connectionMap);
LOG.info("Number connection {} has reach upper limit {}. Connection map : [{}], "
+ "connByUser: [{}], flightToken2ConnectionId: [{}]",
numberConnection.get(), maxConnections, connectionMap, connByUser, flightToken2ConnectionId);
numberConnection.decrementAndGet();
return false;
}
// Check user
connByUser.putIfAbsent(ctx.getQualifiedUser(), new AtomicInteger(0));
AtomicInteger conns = connByUser.get(ctx.getQualifiedUser());
if (conns.incrementAndGet() > ctx.getEnv().getAuth().getMaxConn(ctx.getQualifiedUser())) {
LOG.info("User {}'s connection {} has reached upper limit {}. connByUser: [{}]", ctx.getQualifiedUser(),
conns.get(), ctx.getEnv().getAuth().getMaxConn(ctx.getQualifiedUser()), connByUser);
LOG.info("User {}'s connection {} has reached upper limit {}. numberConnection {}, "
+ "Connection map : [{}], connByUser: [{}], flightToken2ConnectionId: [{}]",
ctx.getQualifiedUser(), conns.get(), ctx.getEnv().getAuth().getMaxConn(ctx.getQualifiedUser()),
numberConnection.get(), connectionMap, connByUser, flightToken2ConnectionId);
conns.decrementAndGet();
numberConnection.decrementAndGet();
return false;
Expand Down Expand Up @@ -187,6 +190,7 @@ public List<List<String>> listConnectionForRpc(UserIdentity userIdentity, boolea
if (!ctx.getCurrentUserIdentity().equals(userIdentity) && !Env.getCurrentEnv()
.getAccessManager()
.checkGlobalPriv(userIdentity, PrivPredicate.GRANT)) {
LOG.info("connection filtered by auth, {}", ctx);
continue;
}
list.add(ctx.toThreadInfo(isShowFullSql).toRow(-1, nowMs));
Expand Down

0 comments on commit 345e9ab

Please sign in to comment.