Skip to content

Commit eed90ce

Browse files
authored
Pipe: Fixed the issue that frequent logins on the receiving end caused indicator leaks (apache#16076)
* Pipe: Fixed the issue that frequent logins on the receiving end caused indicator leaks * fix * fix * spotless
1 parent c50ae86 commit eed90ce

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -908,15 +908,28 @@ private TSStatus executeStatementWithPermissionCheckAndRetryOnDataTypeMismatch(
908908

909909
@Override
910910
protected TSStatus login() {
911-
final BasicOpenSessionResp openSessionResp =
912-
SESSION_MANAGER.login(
913-
SESSION_MANAGER.getCurrSession(),
914-
username,
915-
password,
916-
ZoneId.systemDefault().toString(),
917-
SessionManager.CURRENT_RPC_VERSION,
918-
IoTDBConstant.ClientVersion.V_1_0);
919-
return RpcUtils.getStatus(openSessionResp.getCode(), openSessionResp.getMessage());
911+
final IClientSession session = SESSION_MANAGER.getCurrSession();
912+
913+
if (session != null && !session.isLogin()) {
914+
final BasicOpenSessionResp openSessionResp =
915+
SESSION_MANAGER.login(
916+
session,
917+
username,
918+
password,
919+
ZoneId.systemDefault().toString(),
920+
SessionManager.CURRENT_RPC_VERSION,
921+
IoTDBConstant.ClientVersion.V_1_0);
922+
return RpcUtils.getStatus(openSessionResp.getCode(), openSessionResp.getMessage());
923+
}
924+
925+
Long timeToExpire = SESSION_MANAGER.checkPasswordExpiration(username, password);
926+
if (timeToExpire != null && timeToExpire <= System.currentTimeMillis()) {
927+
return RpcUtils.getStatus(
928+
TSStatusCode.ILLEGAL_PASSWORD.getStatusCode(),
929+
"Password has expired, please use \"ALTER USER\" to change to a new one");
930+
}
931+
932+
return AuthorityChecker.checkUser(username, password);
920933
}
921934

922935
private TSStatus executeStatementForTableModel(

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/session/SessionManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public BasicOpenSessionResp login(
139139
* @return the timestamp when the password will expire. Long.MAX if the password never expires.
140140
* Null if the password history cannot be found.
141141
*/
142-
private Long checkPasswordExpiration(String username, String password) {
142+
public Long checkPasswordExpiration(String username, String password) {
143143
// check password expiration
144144
long passwordExpirationDays =
145145
CommonDescriptor.getInstance().getConfig().getPasswordExpirationDays();

0 commit comments

Comments
 (0)