caiconghui commented on a change in pull request #7936: URL: https://github.com/apache/incubator-doris/pull/7936#discussion_r800158119
########## File path: fe/fe-core/src/main/java/org/apache/doris/qe/ConnectScheduler.java ########## @@ -96,50 +94,50 @@ public boolean submit(ConnectContext context) { } // Register one connection with its connection id. - public synchronized boolean registerConnection(ConnectContext ctx) { - if (numberConnection >= maxConnections) { + public boolean registerConnection(ConnectContext ctx) { + if (numberConnection.incrementAndGet() > maxConnections) { + numberConnection.decrementAndGet(); return false; } // Check user - if (connByUser.get(ctx.getQualifiedUser()) == null) { - connByUser.put(ctx.getQualifiedUser(), new AtomicInteger(0)); - } - int conns = connByUser.get(ctx.getQualifiedUser()).get(); + connByUser.putIfAbsent(ctx.getQualifiedUser(), new AtomicInteger(0)); + AtomicInteger conns = connByUser.get(ctx.getQualifiedUser()); if (ctx.getIsTempUser()) { - if (conns >= LdapAuthenticate.getMaxConn()) { + if (conns.incrementAndGet() > LdapAuthenticate.getMaxConn()) { + conns.decrementAndGet(); + numberConnection.decrementAndGet(); return false; } - } else if (conns >= ctx.getCatalog().getAuth().getMaxConn(ctx.getQualifiedUser())) { + } else if (conns.incrementAndGet() > ctx.getCatalog().getAuth().getMaxConn(ctx.getQualifiedUser())) { + conns.decrementAndGet(); + numberConnection.decrementAndGet(); Review comment: > why call `numberConnection.decrementAndGet();` here? we should reduce the connection number when connect failed -- 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. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org