dlg99 opened a new issue #2898:
URL: https://github.com/apache/bookkeeper/issues/2898


   **BUG REPORT**
   
   ***Describe the bug***
   
   DistributedLog can lose a correctly closed segment.
   Found while looking at flaky tests at `TestBKDistributedLogManager`.
   The scenario looks like:
   Open DLM
   write a few segments
   close DLM
   Open another DLM
   read the segments back
   ->  sometimes
   
   ***To Reproduce***
   
   Steps to reproduce the behavior:
   
   Add the following code to `TestBKDistributedLogManager`:
   ```
       @Test//(timeout = 90000)
       public void testNumberOfTransactionsWithInprogressAtEndLooped() throws 
Exception {
           for (int runId = 0; runId < 100; runId++) {
               String name = "distrlog-inprogressAtEndLooped" + runId;
               BKDistributedLogManager dlm = createNewDLM(conf, name);
               long txid = 1;
               for (long i = 0; i < 3; i++) {
                   BKSyncLogWriter out = dlm.startLogSegmentNonPartitioned();
                   for (long j = 1; j <= DEFAULT_SEGMENT_SIZE; j++) {
                       LogRecord op = DLMTestUtil.getLogRecordInstance(txid++);
                       out.write(op);
                   }
                   out.closeAndComplete();
               }
   
               assertEquals(txid - 1, dlm.getLastTxId());
               dlm.close();
   
               dlm = createNewDLM(conf, name);
   
               long numLogRecs = 0;
               LogReader reader = dlm.getInputStream(1);
               LogRecord record = reader.readNext(false);
               while (null != record) {
                   numLogRecs++;
                   verifyLogRecord(record);
                   assertEquals("(skipped txId) Failed at iteration " + runId, 
numLogRecs, record.getTransactionId());
                   record = reader.readNext(false);
               }
               reader.close();
               assertEquals("(missed txs) Failed at iteration " + runId, (txid 
- 1), numLogRecs);
               dlm.close();
           }
       }
   ```
   
   Execute this test like
   ```
   mvn test -f stream/distributedlog/core/pom.xml 
-Dtest=org.apache.distributedlog.TestBKDistributedLogManager#testNumberOfTransactionsWithInprogressAtEndLooped
 -DtestRetryCount=0
   ```
   or use gradle equivalent or IDE.
   
   get errors like
   ```
   [ERROR] Failures:
   [ERROR]   
TestBKDistributedLogManager.testNumberOfTransactionsWithInprogressAtEndLooped:371
 (skipped txId) Failed at iteration 0 expected:<1001> but was:<2001>
   ```
   (second segment is lost)
   
   or
   ```
   [ERROR] 
org.apache.distributedlog.TestBKDistributedLogManager.testNumberOfTransactionsWithInprogressAtEndLooped
  Time elapsed: 61.94 s  <<< FAILURE!
   java.lang.AssertionError: (missed txs) Failed at iteration 15 
expected:<3000> but was:<2000>
   ```
   (last/third segment is lost)
   
   
   ***Expected behavior***
   
   all transactions read back during all iterations
   


-- 
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]


Reply via email to