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/07/22 03:53:01 UTC

[GitHub] [inlong] gong commented on a diff in pull request #5170: [INLONG-5169][Sort] Fix race condition issue of HBaseSinkFunction metric collection

gong commented on code in PR #5170:
URL: https://github.com/apache/inlong/pull/5170#discussion_r927265471


##########
inlong-sort/sort-connectors/hbase/src/main/java/org/apache/inlong/sort/hbase/sink/HBaseSinkFunction.java:
##########
@@ -233,39 +213,20 @@ public void invoke(T value, Context context) throws Exception {
         checkErrorAndRethrow();
 
         mutator.mutate(mutationConverter.convertToMutation(value));
-        rowSize++;
-        dataSize = dataSize + value.toString().getBytes(StandardCharsets.UTF_8).length;
+        if (metricData.getNumRecordsOut() != null) {
+            metricData.getNumRecordsOut().inc(1);
+        }
+        if (metricData.getNumRecordsOut() != null) {
+            metricData.getNumBytesOut()
+                .inc(value.toString().getBytes(StandardCharsets.UTF_8).length);
+        }
         // flush when the buffer number of mutations greater than the configured max size.
         if (bufferFlushMaxMutations > 0
                 && numPendingRequests.incrementAndGet() >= bufferFlushMaxMutations) {
-            try {
-                flush();
-                if (metricData.getNumRecordsOut() != null) {
-                    metricData.getNumRecordsOut().inc(rowSize);
-                }
-                if (metricData.getNumRecordsOut() != null) {
-                    metricData.getNumBytesOut()
-                            .inc(dataSize);
-                }
-                resetStateAfterFlush();
-            } catch (Exception e) {
-                if (metricData.getDirtyRecords() != null) {
-                    metricData.getDirtyRecords().inc(rowSize);
-                }
-                if (metricData.getDirtyBytes() != null) {
-                    metricData.getDirtyBytes().inc(dataSize);
-                }

Review Comment:
   lost write Fail records



-- 
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