zhilinli123 commented on code in PR #7921:
URL: https://github.com/apache/seatunnel/pull/7921#discussion_r1820016570


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseSourceReader.java:
##########
@@ -75,28 +79,35 @@ public void close() throws IOException {
 
     @Override
     public void pollNext(Collector<SeaTunnelRow> output) throws Exception {
-        if (!splits.isEmpty()) {
-            try (ClickHouseResponse response = 
this.request.query(sql).executeAndWait()) {
-                response.stream()
-                        .forEach(
-                                record -> {
-                                    Object[] values =
-                                            new 
Object[this.rowTypeInfo.getFieldNames().length];
-                                    for (int i = 0; i < record.size(); i++) {
-                                        if 
(record.getValue(i).isNullOrEmpty()) {
-                                            values[i] = null;
-                                        } else {
-                                            values[i] =
-                                                    
TypeConvertUtil.valueUnwrap(
-                                                            
this.rowTypeInfo.getFieldType(i),
-                                                            
record.getValue(i));
+        synchronized (output.getCheckpointLock()) {
+            if (!splits.isEmpty()) {
+                try (ClickHouseResponse response = 
this.request.query(sql).executeAndWait()) {
+                    response.stream()
+                            .forEach(
+                                    record -> {
+                                        Object[] values =
+                                                new 
Object[this.rowTypeInfo.getFieldNames().length];
+                                        for (int i = 0; i < record.size(); 
i++) {
+                                            if 
(record.getValue(i).isNullOrEmpty()) {
+                                                values[i] = null;
+                                            } else {
+                                                values[i] =
+                                                        
TypeConvertUtil.valueUnwrap(
+                                                                
this.rowTypeInfo.getFieldType(i),
+                                                                
record.getValue(i));
+                                            }
                                         }
-                                    }
-                                    output.collect(new SeaTunnelRow(values));
-                                });
+                                        output.collect(new 
SeaTunnelRow(values));
+                                    });
+                }
+                this.readerContext.signalNoMoreElement();
+                this.splits.clear();
+            }

Review Comment:
   Extract clickhouse Close the task method
   ```
                   this.readerContext.signalNoMoreElement();
                   this.splits.clear();
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to