LiebingYu commented on code in PR #1749:
URL: https://github.com/apache/fluss/pull/1749#discussion_r2492663808
##########
fluss-server/src/main/java/org/apache/fluss/server/log/LogLoader.java:
##########
@@ -117,6 +122,37 @@ public LoadedLogOffsets load() throws IOException {
nextOffset, activeSegment.getBaseOffset(),
activeSegment.getSizeInBytes()));
}
+ /**
+ * Just recovers the given segment, without adding it to the provided
segments.
+ *
+ * @param segment Segment to recover
+ * @return The number of bytes truncated from the segment
+ * @throws LogSegmentOffsetOverflowException if the segment contains
messages that cause index
+ * offset overflow
+ */
+ private int recoverSegment(LogSegment segment) throws Exception {
+ WriterStateManager writerStateManager =
+ new WriterStateManager(
+ logSegments.getTableBucket(),
+ logTabletDir,
+ this.writerStateManager.writerExpirationMs());
+ // TODO, Here, we use 0 as the logStartOffset passed into
rebuildWriterState. The reason is
+ // that the current implementation of logStartOffset in Fluss is not
yet fully refined, and
+ // there may be cases where logStartOffset is not updated. As a
result, logStartOffset is
+ // not yet reliable. Once the issue with correctly updating
logStartOffset is resolved in
+ // issue https://github.com/apache/fluss/issues/744, we can use
logStartOffset here.
+ // Additionally, using 0 versus using logStartOffset does not affect
correctness—they both
+ // can restore the complete WriterState. The only difference is that
using logStartOffset
+ // can potentially skip over more segments.
+ LogTablet.rebuildWriterState(
+ writerStateManager, logSegments, 0, segment.getBaseOffset(),
false);
+ int bytesTruncated = segment.recover();
Review Comment:
Kafka use `writerStateManager` in `segment.recover()` mainly for txn
operations. I think Fluss doen't need here. What's your opinion @swuferhong?
--
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]