You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/10/29 06:00:18 UTC

[GitHub] [inlong] yunqingmoswu opened a new pull request, #6323: [INLONG-6322][Sort] Fix write data incorrect for doris connector with sink multiple scenario

yunqingmoswu opened a new pull request, #6323:
URL: https://github.com/apache/inlong/pull/6323

   ### Prepare a Pull Request
   *(Change the title refer to the following example)*
   
   Title: [INLONG-6322][Sort] Fix write data incorrect for doris connector with sink multiple scenario
   
   *(The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)*
   
   Fixes #6322 
   
   ### Motivation
   
   Fix write data incorrect for doris connector with sink multiple scenario
   
   ### Modifications
   
   Update DorisDynamicSchemaOutputFormat to fix it.
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [x] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   
     *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a follow-up issue for adding the documentation
   


-- 
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@inlong.apache.org

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


[GitHub] [inlong] yunqingmoswu commented on a diff in pull request #6323: [INLONG-6322][Sort] Fix write data incorrect for doris connector with sink multiple scenario

Posted by GitBox <gi...@apache.org>.
yunqingmoswu commented on code in PR #6323:
URL: https://github.com/apache/inlong/pull/6323#discussion_r1008985506


##########
inlong-sort/sort-connectors/doris/src/main/java/org/apache/inlong/sort/doris/table/DorisDynamicSchemaOutputFormat.java:
##########
@@ -258,35 +265,52 @@ public synchronized void close() throws IOException {
 
     @SuppressWarnings({"rawtypes"})
     public synchronized void flush() {
+        flushing = true;

Review Comment:
   The entire flush needs to ensure atomicity here.



##########
inlong-sort/sort-connectors/doris/src/main/java/org/apache/inlong/sort/doris/table/DorisDynamicSchemaOutputFormat.java:
##########
@@ -258,35 +265,52 @@ public synchronized void close() throws IOException {
 
     @SuppressWarnings({"rawtypes"})
     public synchronized void flush() {
+        flushing = true;
         if (batchMap.isEmpty()) {

Review Comment:
   done



-- 
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@inlong.apache.org

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


[GitHub] [inlong] kuansix commented on a diff in pull request #6323: [INLONG-6322][Sort] Fix write data incorrect for doris connector with sink multiple scenario

Posted by GitBox <gi...@apache.org>.
kuansix commented on code in PR #6323:
URL: https://github.com/apache/inlong/pull/6323#discussion_r1008873461


##########
inlong-sort/sort-connectors/doris/src/main/java/org/apache/inlong/sort/doris/table/DorisDynamicSchemaOutputFormat.java:
##########
@@ -258,35 +265,52 @@ public synchronized void close() throws IOException {
 
     @SuppressWarnings({"rawtypes"})
     public synchronized void flush() {
+        flushing = true;

Review Comment:
   volatile can't ensure CAS atomic operation?



-- 
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@inlong.apache.org

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


[GitHub] [inlong] EMsnap commented on a diff in pull request #6323: [INLONG-6322][Sort] Fix write data incorrect for doris connector with sink multiple scenario

Posted by GitBox <gi...@apache.org>.
EMsnap commented on code in PR #6323:
URL: https://github.com/apache/inlong/pull/6323#discussion_r1009121570


##########
inlong-sort/sort-connectors/doris/src/main/java/org/apache/inlong/sort/doris/table/DorisDynamicSchemaOutputFormat.java:
##########
@@ -258,35 +263,68 @@ public synchronized void close() throws IOException {
 
     @SuppressWarnings({"rawtypes"})
     public synchronized void flush() {
-        if (batchMap.isEmpty()) {
+        flushing = true;
+        if (!hasRecords()) {
+            flushing = false;
             return;
         }
+        List<String> errorTables = new ArrayList<>();
         for (Entry<String, List> kvs : batchMap.entrySet()) {
-            if (checkFlushException(kvs.getKey())) {
+            if (checkFlushException(kvs.getKey()) || kvs.getValue().isEmpty()) {
                 continue;
             }
+            String loadValue = null;
             try {
-                load(kvs.getKey(), OBJECT_MAPPER.writeValueAsString(kvs.getValue()));
+                loadValue = OBJECT_MAPPER.writeValueAsString(kvs.getValue());
+                load(kvs.getKey(), loadValue);
+                LOG.info("load {} records to tableIdentifier: {}", kvs.getValue().size(), kvs.getKey());
+                writeOutNum.addAndGet(kvs.getValue().size());
+                // Clean the data that has been loaded.
+                kvs.getValue().clear();
             } catch (Exception e) {
                 flushExceptionMap.put(kvs.getKey(), e);
+                errorNum.getAndAdd(kvs.getValue().size());
                 if (!ignoreSingleTableErrors) {
                     throw new RuntimeException(
-                            String.format("Writing records to streamload of tableIdentifier:%s failed.", kvs.getKey()),
-                            e);
+                            String.format("Writing records to streamload of tableIdentifier:%s failed, the value: %s.",
+                                    kvs.getKey(), loadValue), e);
                 }
-                batchMap.remove(kvs.getKey());
+                errorTables.add(kvs.getKey());
+                LOG.warn("The tableIdentifier: {} load failed and the data will be throw away in the future"
+                        + " because the option 'sink.multiple.ignore-single-table-errors' is 'true'", kvs.getKey());
             }
         }
+        if (!errorTables.isEmpty()) {
+            // Clean the key that has erros

Review Comment:
   errors



-- 
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@inlong.apache.org

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


[GitHub] [inlong] kuansix commented on a diff in pull request #6323: [INLONG-6322][Sort] Fix write data incorrect for doris connector with sink multiple scenario

Posted by GitBox <gi...@apache.org>.
kuansix commented on code in PR #6323:
URL: https://github.com/apache/inlong/pull/6323#discussion_r1008844665


##########
inlong-sort/sort-connectors/doris/src/main/java/org/apache/inlong/sort/doris/table/DorisDynamicSchemaOutputFormat.java:
##########
@@ -258,35 +265,52 @@ public synchronized void close() throws IOException {
 
     @SuppressWarnings({"rawtypes"})
     public synchronized void flush() {
+        flushing = true;
         if (batchMap.isEmpty()) {

Review Comment:
   need flushing = true; before return



-- 
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@inlong.apache.org

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


[GitHub] [inlong] yunqingmoswu merged pull request #6323: [INLONG-6322][Sort] Fix write data incorrect for doris connector with sink multiple scenario

Posted by GitBox <gi...@apache.org>.
yunqingmoswu merged PR #6323:
URL: https://github.com/apache/inlong/pull/6323


-- 
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@inlong.apache.org

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


[GitHub] [inlong] kuansix commented on a diff in pull request #6323: [INLONG-6322][Sort] Fix write data incorrect for doris connector with sink multiple scenario

Posted by GitBox <gi...@apache.org>.
kuansix commented on code in PR #6323:
URL: https://github.com/apache/inlong/pull/6323#discussion_r1008844665


##########
inlong-sort/sort-connectors/doris/src/main/java/org/apache/inlong/sort/doris/table/DorisDynamicSchemaOutputFormat.java:
##########
@@ -258,35 +265,52 @@ public synchronized void close() throws IOException {
 
     @SuppressWarnings({"rawtypes"})
     public synchronized void flush() {
+        flushing = true;
         if (batchMap.isEmpty()) {

Review Comment:
   need flushing = false; before return



-- 
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@inlong.apache.org

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