pisceslj opened a new issue, #2943: URL: https://github.com/apache/fluss/issues/2943
### Search before asking - [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar. ### Fluss version 0.9.0 (latest release) ### Please describe the bug 🐞 When recovering log segments, invoke the readNextOffset function to calculate the offset that would be used for the next message to be appended to this segment. However, this function doesn‘t check for the scenario where batches is empty. Once batches is empty, invoking Iterables.getLast function will throw an exception. > 2026-03-27 11:37:12,446 ERROR org.apache.fluss.server.ServerBase [] - Could not start TabletServer. org.apache.fluss.exception.FlussException: Failed to start the TabletServer. at org.apache.fluss.server.ServerBase.start(ServerBase.java:144) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.ServerBase.startServer(ServerBase.java:99) [fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.tablet.TabletServer.main(TabletServer.java:191) [fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] Caused by: org.apache.fluss.exception.FlussRuntimeException: Failed to recovery log at org.apache.fluss.server.log.LogManager.loadLogs(LogManager.java:207) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.log.LogManager.startup(LogManager.java:139) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.tablet.TabletServer.startServices(TabletServer.java:228) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.ServerBase.start(ServerBase.java:131) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] ... 2 more Caused by: org.apache.fluss.exception.FlussRuntimeException: java.util.NoSuchElementException at org.apache.fluss.server.log.LogManager$1.run(LogManager.java:518) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] at java.lang.Thread.run(Thread.java:842) ~[?:?] Caused by: java.util.NoSuchElementException at org.apache.fluss.utils.AbstractIterator.next(AbstractIterator.java:57) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.shaded.guava32.com.google.common.collect.Iterators.getLast(Iterators.java:907) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.shaded.guava32.com.google.common.collect.Iterables.getLast(Iterables.java:850) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.log.LogSegment.readNextOffset(LogSegment.java:414) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.log.LogLoader.recoverLog(LogLoader.java:198) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.log.LogLoader.load(LogLoader.java:93) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.log.LogTablet.create(LogTablet.java:324) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.log.LogManager.loadLog(LogManager.java:342) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.fluss.server.log.LogManager$1.run(LogManager.java:487) ~[fluss-server-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] ### Solution Use Iterables.isEmpty to check if batches is empty in the readNextOffset function. If batches is empty, directly return the baseOffset. ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- 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]
