Skip to content

Commit 341615f

Browse files
authored
[Fix][Connector-V2] Fix doris sink can not be closed when stream load not read any data (#6570)
1 parent 5fd98ea commit 341615f

File tree

1 file changed

+7
-7
lines changed
  • seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/sink/writer

1 file changed

+7
-7
lines changed

Diff for: seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/sink/writer/DorisSinkWriter.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ public class DorisSinkWriter
6565
private final int intervalTime;
6666
private final DorisSerializer serializer;
6767
private final CatalogTable catalogTable;
68-
private final transient ScheduledExecutorService scheduledExecutorService;
69-
private transient Thread executorThread;
70-
private transient volatile Exception loadException = null;
68+
private final ScheduledExecutorService scheduledExecutorService;
69+
private Thread executorThread;
70+
private volatile Exception loadException = null;
7171

7272
public DorisSinkWriter(
7373
SinkWriter.Context context,
@@ -114,8 +114,6 @@ private void initializeLoad() {
114114
} catch (Exception e) {
115115
throw new DorisConnectorException(DorisConnectorErrorCode.STREAM_LOAD_FAILED, e);
116116
}
117-
// get main work thread.
118-
executorThread = Thread.currentThread();
119117
startLoad(labelGenerator.generateLabel(lastCheckpointId + 1));
120118
// when uploading data in streaming mode, we need to regularly detect whether there are
121119
// exceptions.
@@ -125,7 +123,7 @@ private void initializeLoad() {
125123

126124
@Override
127125
public void write(SeaTunnelRow element) throws IOException {
128-
checkLoadException();
126+
checkLoadExceptionAndResetThread();
129127
byte[] serialize =
130128
serializer.serialize(
131129
dorisConfig.isNeedsUnsupportedTypeCasting()
@@ -222,9 +220,11 @@ private void checkDone() {
222220
}
223221
}
224222

225-
private void checkLoadException() {
223+
private void checkLoadExceptionAndResetThread() {
226224
if (loadException != null) {
227225
throw new RuntimeException("error while loading data.", loadException);
226+
} else {
227+
executorThread = Thread.currentThread();
228228
}
229229
}
230230

0 commit comments

Comments
 (0)