Skip to content
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

[fix](connection)Add more log for Reach limit of connections #45939

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading