w41ter commented on code in PR #46769:
URL: https://github.com/apache/doris/pull/46769#discussion_r1915866638


##########
fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogUtils.java:
##########
@@ -50,25 +50,39 @@ public static Pair<TStatus, TBinlog> 
getBinlog(TreeSet<TBinlog> binlogs, long pr
         }
     }
 
-    public static Pair<TStatus, Long> getBinlogLag(TreeSet<TBinlog> binlogs, 
long prevCommitSeq) {
+    public static Pair<TStatus, BinlogLagInfo> getBinlogLag(TreeSet<TBinlog> 
binlogs, long prevCommitSeq) {
         TStatus status = new TStatus(TStatusCode.OK);
         TBinlog firstBinlog = binlogs.first();
 
         if (firstBinlog.getCommitSeq() > prevCommitSeq) {
-            return Pair.of(status, Long.valueOf(binlogs.size()));
+            BinlogLagInfo lagInfo = new BinlogLagInfo(binlogs.size(), 
firstBinlog.getCommitSeq(),
+                    firstBinlog.getTimestamp());
+            return Pair.of(status, lagInfo);

Review Comment:
   In this case, there is still a range of binlogs. So, take the first and the 
last binlog instead of only taking the first binlog as the last one.



##########
fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogUtils.java:
##########
@@ -50,25 +50,39 @@ public static Pair<TStatus, TBinlog> 
getBinlog(TreeSet<TBinlog> binlogs, long pr
         }
     }
 
-    public static Pair<TStatus, Long> getBinlogLag(TreeSet<TBinlog> binlogs, 
long prevCommitSeq) {
+    public static Pair<TStatus, BinlogLagInfo> getBinlogLag(TreeSet<TBinlog> 
binlogs, long prevCommitSeq) {
         TStatus status = new TStatus(TStatusCode.OK);
         TBinlog firstBinlog = binlogs.first();
 
         if (firstBinlog.getCommitSeq() > prevCommitSeq) {
-            return Pair.of(status, Long.valueOf(binlogs.size()));
+            BinlogLagInfo lagInfo = new BinlogLagInfo(binlogs.size(), 
firstBinlog.getCommitSeq(),
+                    firstBinlog.getTimestamp());
+            return Pair.of(status, lagInfo);
         }
 
         // find first binlog whose commitSeq > commitSeq
         TBinlog guard = new TBinlog();
         guard.setCommitSeq(prevCommitSeq);
-        TBinlog binlog = binlogs.higher(guard);
+        TBinlog firstTBinlog = binlogs.higher(guard);
+        TBinlog lastBinlog = binlogs.last();
 
         // all prevCommitSeq <= commitSeq
-        if (binlog == null) {
-            return Pair.of(status, 0L);
-        } else {
-            return Pair.of(status, 
Long.valueOf(binlogs.tailSet(binlog).size()));
+        long lag = 0;
+        long lastCommitSeq = 0;
+        long lastCommitTs = 0;
+        long firstCommitSeq = 0;
+        long firstCommitTs = 0;
+        if (firstTBinlog != null) {
+            lag = binlogs.tailSet(firstTBinlog).size();
+            firstCommitSeq = firstTBinlog.getCommitSeq();
+            firstCommitTs = firstTBinlog.getTimestamp();
+        }
+        if (lastBinlog != null) {
+            lastCommitSeq = lastBinlog.getCommitSeq();
+            lastCommitTs = lastBinlog.getTimestamp();
         }

Review Comment:
   ```suggestion
           if (firstTBinlog != null) {
               lag = binlogs.tailSet(firstTBinlog).size();
               firstCommitSeq = firstTBinlog.getCommitSeq();
               firstCommitTs = firstTBinlog.getTimestamp();
               lastCommitSeq = lastBinlog.getCommitSeq();
               lastCommitTs = lastBinlog.getTimestamp();
           }
   ```



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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to