azexcy commented on code in PR #25787:
URL: https://github.com/apache/shardingsphere/pull/25787#discussion_r1198716040


##########
kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLBinlogEventPacketDecoder.java:
##########
@@ -69,11 +78,44 @@ protected void decode(final ChannelHandlerContext ctx, 
final ByteBuf in, final L
                 in.resetReaderIndex();
                 break;
             }
-            Optional.ofNullable(decodeEvent(payload, 
binlogEventHeader)).ifPresent(out::add);
+            AbstractBinlogEvent binlogEvent = decodeEvent(payload, 
binlogEventHeader);
+            if (null == binlogEvent) {
+                skipChecksum(binlogEventHeader.getEventType(), in);
+                return;
+            }
+            if (decodeWithTX) {
+                processEventWithTX(binlogEvent, out);
+            } else {
+                processEventIgnoreTX(binlogEvent, out);
+            }
             skipChecksum(binlogEventHeader.getEventType(), in);
         }
     }
     
+    private void processEventWithTX(final AbstractBinlogEvent binlogEvent, 
final List<Object> out) {
+        if (binlogEvent instanceof QueryEvent) {
+            QueryEvent queryEvent = (QueryEvent) binlogEvent;
+            if (TX_BEGIN_SQL.equals(queryEvent.getSql())) {
+                records.clear();
+            }

Review Comment:
   yes, because begin SQL reach, means a new transaction's arrives, but i will 
improve it, use `records = new LinkedList()` instead `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