Skip to content

Commit 79e10af

Browse files
authored
Fixed the warn log of internal/MQTT session's close session method (#16909)
* remove-warn * must
1 parent 1bf79ca commit 79e10af

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/writeback/WriteBackSink.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ private void doTransfer(final PipeStatementInsertionEvent pipeStatementInsertion
369369
@Override
370370
public void close() throws Exception {
371371
if (session != null) {
372-
SESSION_MANAGER.closeSession(session, COORDINATOR::cleanupQueryExecution);
372+
SESSION_MANAGER.closeSession(session, COORDINATOR::cleanupQueryExecution, false);
373373
}
374374
if (treeSession != null) {
375-
SESSION_MANAGER.closeSession(treeSession, COORDINATOR::cleanupQueryExecution);
375+
SESSION_MANAGER.closeSession(treeSession, COORDINATOR::cleanupQueryExecution, false);
376376
}
377377
}
378378

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.iotdb.service.rpc.thrift.TSConnectionType;
2323

24+
import java.util.Collections;
2425
import java.util.Map;
2526
import java.util.Set;
2627
import java.util.concurrent.ConcurrentHashMap;
@@ -109,7 +110,6 @@ public PreparedStatementInfo getPreparedStatement(String statementName) {
109110

110111
@Override
111112
public Set<String> getPreparedStatementNames() {
112-
throw new UnsupportedOperationException(
113-
"InternalClientSession should never call PREPARE statement methods.");
113+
return Collections.emptySet();
114114
}
115115
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ public PreparedStatementInfo getPreparedStatement(String statementName) {
9797

9898
@Override
9999
public Set<String> getPreparedStatementNames() {
100-
throw new UnsupportedOperationException(
101-
"MQTT client session does not support PREPARE statement.");
100+
return Collections.emptySet();
102101
}
103102
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ public BasicOpenSessionResp login(
255255
}
256256

257257
public boolean closeSession(IClientSession session, LongConsumer releaseByQueryId) {
258+
return closeSession(session, releaseByQueryId, true);
259+
}
260+
261+
public boolean closeSession(
262+
IClientSession session, LongConsumer releaseByQueryId, boolean mustCurrent) {
258263
releaseSessionResource(session, releaseByQueryId);
259264
MetricService.getInstance()
260265
.remove(
@@ -264,11 +269,11 @@ public boolean closeSession(IClientSession session, LongConsumer releaseByQueryI
264269
String.valueOf(session.getId()));
265270
// TODO we only need to do so when query is killed by time out close the socket.
266271
IClientSession session1 = currSession.get();
267-
if (session1 != null && session != session1) {
272+
if (mustCurrent && session1 != null && session != session1) {
268273
LOGGER.info(
269274
String.format(
270275
"The client-%s is trying to close another session %s, pls check if it's a bug",
271-
session, session1));
276+
session1, session));
272277
return false;
273278
} else {
274279
LOGGER.info(String.format("Session-%s is closing", session));

0 commit comments

Comments
 (0)