You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2023/01/03 02:32:47 UTC

[GitHub] [incubator-seatunnel] 531651225 opened a new pull request, #3850: [Improve][Connector][Doris] Support for at-most-once via doris lable and checkpoint

531651225 opened a new pull request, #3850:
URL: https://github.com/apache/incubator-seatunnel/pull/3850

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
   
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
   
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   
   -->
   refer to https://github.com/apache/incubator-seatunnel/issues/3752
   
   [Improve][Connector][Doris] Support for at-most-once via doris lable and checkpoint
   ## Purpose of this pull request
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   
   ## Check list
   
   * [x] Code changed are covered with tests, or it does not need tests for reason:
   * [x] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [x] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
   * [x] If you are contributing the connector code, please check that the following files are updated:
     1. Update change log that in connector document. For more details you can refer to [connector-v2](https://github.com/apache/incubator-seatunnel/tree/dev/docs/en/connector-v2)
     2. Update [plugin-mapping.properties](https://github.com/apache/incubator-seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     3. Update the pom file of [seatunnel-dist](https://github.com/apache/incubator-seatunnel/blob/dev/seatunnel-dist/pom.xml)


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #3850: [Improve][Connector][Doris] Support for at-most-once via doris lable and checkpoint

Posted by "EricJoy2048 (via GitHub)" <gi...@apache.org>.
EricJoy2048 commented on code in PR #3850:
URL: https://github.com/apache/incubator-seatunnel/pull/3850#discussion_r1104088450


##########
seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/client/DorisSinkManager.java:
##########
@@ -76,10 +90,64 @@ private void tryInit() throws IOException {
         }, batchIntervalMs, batchIntervalMs, TimeUnit.MILLISECONDS);
     }
 
+    public void startAsyncFlushing() {
+        // start flush thread
+        Thread flushThread = new Thread(() -> {
+            while (true) {
+                try {
+                    if (!asyncFlush()) {
+                        log.info("doris flush thread is about to exit.");
+                        asyncFlushThreadAlive = false;
+                        break;
+                    }
+                } catch (Exception e) {
+                    flushException = e;
+                }
+            }
+        });
+
+        flushThread.setUncaughtExceptionHandler((t, e) -> {
+            log.error("doris flush thread uncaught exception occurred: " + e.getMessage(), e);
+            flushException = (Exception) e;
+            asyncFlushThreadAlive = false;
+        });
+        flushThread.setName("doris-flush");
+        flushThread.setDaemon(true);
+        flushThread.start();
+        asyncFlushThreadAlive = true;
+    }
+
+    private boolean asyncFlush() throws Exception {
+        DorisFlushTuple flushData = flushQueue.poll(FLUSH_QUEUE_POLL_TIMEOUT, TimeUnit.MILLISECONDS);
+
+        if (flushData == null || (0 == flushData.getBytes() && !flushData.isEof())) {
+            return true;
+        }
+        if (flushData.isEof()) {
+            return false;
+        }
+        flush(flushData);
+        log.info(String.format("Async stream load finished: label[%s].", flushData.getLabel()));
+        //remove finished flushData from previousBufferMap
+        previousBufferMap.remove(flushData.getLabel());
+
+        return true;
+    }
+
     public synchronized void write(String record) throws IOException {
-        tryInit();
         checkFlushException();
         byte[] bts = record.getBytes(StandardCharsets.UTF_8);
+
+        if (sinkSemantics.equals(DorisSinkSemantics.AT_LEAST_ONCE)) {
+            if (currentSinkBuffer == null) {
+                String newLabel = createBatchLabel();
+                currentSinkBuffer = new DorisFlushTuple(newLabel);
+            }
+            currentSinkBuffer.addToBuffer(bts);

Review Comment:
   If we use `JDBC Source`, It may oom here. I don't think saving data in memory is a good way, I think we should discuss whether to add state saving like rocksdb to save state information.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] TyrantLucifer closed pull request #3850: [Improve][Connector][Doris] Support for at-most-once via doris lable and checkpoint

Posted by "TyrantLucifer (via GitHub)" <gi...@apache.org>.
TyrantLucifer closed pull request #3850: [Improve][Connector][Doris] Support for at-most-once via doris lable and checkpoint
URL: https://github.com/apache/incubator-seatunnel/pull/3850


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] TyrantLucifer commented on pull request #3850: [Improve][Connector][Doris] Support for at-most-once via doris lable and checkpoint

Posted by "TyrantLucifer (via GitHub)" <gi...@apache.org>.
TyrantLucifer commented on PR #3850:
URL: https://github.com/apache/incubator-seatunnel/pull/3850#issuecomment-1535965871

   Because of #4235 , I will close it.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org