You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ju...@apache.org on 2026/06/11 09:42:45 UTC
(iotdb) 32/48: [TIMECHODB]fix: reduce lock granularity in ScpRemoteFileTransfer to avoid deadlock-like blocking
This is an automated email from the ASF dual-hosted git repository.
Caideyipi pushed a commit to branch hotfix/2.0.9.4-sjzt
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit e1cb738f22ade95051ac041dd061d53be1a2054b
Author: 罗振羽 <zh...@timecho.com>
AuthorDate: Tue May 12 03:12:41 2026 +0000
[TIMECHODB]fix: reduce lock granularity in ScpRemoteFileTransfer to avoid deadlock-like blocking
(cherry picked from commit d5c4fdfb976493c60a63cc9d4bb725619c01ea5a)
---
.../plugin/sink/tsfile/ScpRemoteFileTransfer.java | 24 ++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/library-pipe/tsfile-remote-sink/src/main/java/org/apache/iotdb/pipe/plugin/sink/tsfile/ScpRemoteFileTransfer.java b/library-pipe/tsfile-remote-sink/src/main/java/org/apache/iotdb/pipe/plugin/sink/tsfile/ScpRemoteFileTransfer.java
index 1a27f026c87..87556ded0cd 100644
--- a/library-pipe/tsfile-remote-sink/src/main/java/org/apache/iotdb/pipe/plugin/sink/tsfile/ScpRemoteFileTransfer.java
+++ b/library-pipe/tsfile-remote-sink/src/main/java/org/apache/iotdb/pipe/plugin/sink/tsfile/ScpRemoteFileTransfer.java
@@ -213,8 +213,8 @@ class ScpRemoteFileTransfer implements RemoteFileTransfer {
}
@Override
- public synchronized void transferFile(
- File tsFile, File modFile, File objectSourceDir, String targetName) throws IOException {
+ public void transferFile(File tsFile, File modFile, File objectSourceDir, String targetName)
+ throws IOException {
try {
syncObjectDirectory(objectSourceDir, targetName);
final String finalTsName = computeFinalTsName(targetName);
@@ -516,11 +516,15 @@ class ScpRemoteFileTransfer implements RemoteFileTransfer {
}
}
- private synchronized SshClient getOrCreateClient() {
+ private SshClient getOrCreateClient() {
if (client == null || !client.isStarted()) {
- System.setProperty("org.apache.sshd.security.provider.BC.enabled", "false");
- client = SshClient.setUpDefaultClient();
- client.start();
+ synchronized (this) {
+ if (client == null || !client.isStarted()) {
+ System.setProperty("org.apache.sshd.security.provider.BC.enabled", "false");
+ client = SshClient.setUpDefaultClient();
+ client.start();
+ }
+ }
}
return client;
}
@@ -535,7 +539,11 @@ class ScpRemoteFileTransfer implements RemoteFileTransfer {
private synchronized ClientSession getSession() throws IOException {
if (session == null || !session.isOpen()) {
- session = createAuthenticatedSession();
+ synchronized (this) {
+ if (session == null || !session.isOpen()) {
+ session = createAuthenticatedSession();
+ }
+ }
}
return session;
}
@@ -618,7 +626,7 @@ class ScpRemoteFileTransfer implements RemoteFileTransfer {
}
@Override
- public synchronized void handshake() throws IOException {
+ public void handshake() throws IOException {
try {
ensureRemoteDirExists(getSession(), remoteBaseDir);
LOGGER.info("SCP handshake OK, remote base: {}", remoteBaseDir);