pheecian commented on a change in pull request #6717: fix filesystem offload 
oom based on https://github.com/apache/pulsar/…
URL: https://github.com/apache/pulsar/pull/6717#discussion_r407047633
 
 

 ##########
 File path: 
tiered-storage/file-system/src/main/java/org/apache/bookkeeper/mledger/offload/filesystem/impl/FileSystemManagedLedgerOffloader.java
 ##########
 @@ -188,12 +191,15 @@ public void run() {
                 AtomicLong haveOffloadEntryNumber = new AtomicLong(0);
                 long needToOffloadFirstEntryNumber = 0;
                 CountDownLatch countDownLatch;
+                //avoid prefetch too much data into memory
+                ArrayBlockingQueue<Boolean> tasks = new 
ArrayBlockingQueue<>(PREFETCH_ROUNDS);
                 do {
                     long end = Math.min(needToOffloadFirstEntryNumber + 
ENTRIES_PER_READ - 1, readHandle.getLastAddConfirmed());
                     log.debug("read ledger entries. start: {}, end: {}", 
needToOffloadFirstEntryNumber, end);
                     LedgerEntries ledgerEntriesOnce = 
readHandle.readAsync(needToOffloadFirstEntryNumber, end).get();
+                    tasks.put(true);
                     countDownLatch = new CountDownLatch(1);
-                    assignmentScheduler.chooseThread(ledgerId).submit(new 
FileSystemWriter(ledgerEntriesOnce, dataWriter,
+                    
assignmentScheduler.chooseThread(ledgerId).submit(FileSystemWriter.create(ledgerEntriesOnce,
 dataWriter, tasks,
 
 Review comment:
   I made a comment below @congbobo184 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to