infodog commented on issue #1509: solve  #1476 issue.
URL: https://github.com/apache/bookkeeper/pull/1509#issuecomment-396167544
 
 
   I setup a bookkeeper cluster with 3 bookie server, and then setup a client 
read the logs , the client code is as following:
   ```
   void downloadLog() throws IOException {
           long nextTxId = getLocalLastTxId();
           long lastShardTxId = 0;
           try {
               lastShardTxId = dlm.getLastTxId();
   
           } catch (Throwable t) {
               //当日志为空的时候,dlm.getLastTxId会出异常,所以需要try住
               //do nothing
           }
           LogReader reader = dlm.getInputStream(nextTxId);
   
           while (true) {
               try {
   
                   while (true) {
                       try {
                           LogRecord record = reader.readNext(false);
                           if (record == null) {
                               break;
                           }
                           System.out.println("read record, txid=" + 
record.getTransactionId() + ", lastShardId=" + lastShardTxId);
                           if (record.getTransactionId() > getLocalLastTxId()) {
                               updateLocalLog(record);
                           }
                           // read next record
                       } catch (LogEmptyException t) {
                           //没事
                           System.out.println("no record in log.");
                       } catch (Throwable ioe) {
                           // handle the exception
                           nextTxId = getLocalLastTxId();
                           reader = dlm.getInputStream(nextTxId);
                       }
   
                   }
   
   
                   if (isSwitchingToMaster) {
                       return;
                   }
                   synchronized (downloadThreadMonitor) {
                       downloadThreadMonitor.wait(100);
                   }
                   if (isSwitchingToMaster) {
                       return;
                   }
               } catch (Throwable e) {
                   e.printStackTrace();
               }
           }
       }
   ```
   
   when I start a writer write to the bookkeeper server, with serveral 
thoundsand writes, the client will throw the exception, saying that the object 
recycled problem, then the client will not receive any new data. In fact I 
start 2 clients in the same time to read from the server. And always one client 
fails, randomly. 
   
   After apply the fix, my client will run and always get the updated data. So 
I think the fix addressed the data.
   
   Maybe we can create a test case like this? But I dont know how to do that. 
   
   By the way, When I debug the problem, I add some log statements to the code, 
and the logs shows there is still some problem hiding. Still shows something I 
can't understand.  Maybe I am not look carefully enough. 
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to