[ 
https://issues.apache.org/jira/browse/ROCKETMQ-265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16174157#comment-16174157
 ] 

ASF GitHub Bot commented on ROCKETMQ-265:
-----------------------------------------

Github user dongeforever commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq/pull/146#discussion_r140138721
  
    --- Diff: 
store/src/test/java/org/apache/rocketmq/store/ConsumeQueueTest.java ---
    @@ -131,6 +130,65 @@ protected void putMsg(DefaultMessageStore master) 
throws Exception {
             }
         }
     
    +    protected void deleteDirectory(String rootPath) {
    +        File file = new File(rootPath);
    +        deleteFile(file);
    +    }
    +
    +    protected void deleteFile(File file) {
    +        File[] subFiles = file.listFiles();
    +        if (subFiles != null) {
    +            for (File sub : subFiles) {
    +                deleteFile(sub);
    +            }
    +        }
    +
    +        file.delete();
    +    }
    +
    +    @Test
    +    public void testPutMessagePositionInfo_buildCQRepeatedly() throws 
Exception {
    +        DefaultMessageStore messageStore = null;
    +        try {
    +
    +            messageStore = gen();
    +
    +            int totalMessages = 10;
    +
    +            for (int i = 0; i < totalMessages; i++) {
    +                putMsg(messageStore);
    +            }
    +            Thread.sleep(5);
    +
    +            ConsumeQueue cq = 
messageStore.getConsumeQueueTable().get(topic).get(queueId);
    +            Method method = 
cq.getClass().getDeclaredMethod("putMessagePositionInfo", long.class, 
int.class, long.class, long.class);
    +
    +            assertThat(method).isNotNull();
    +
    +            method.setAccessible(true);
    +
    +            SelectMappedBufferResult result = 
messageStore.getCommitLog().getData(0);
    +            assertThat(result != null).isTrue();
    +
    +            DispatchRequest dispatchRequest = 
messageStore.getCommitLog().checkMessageAndReturnSize(result.getByteBuffer(), 
false, false);
    +
    +            assertThat(cq).isNotNull();
    +
    +            Object dispatchResult = method.invoke(cq, 
dispatchRequest.getCommitLogOffset(),
    +                dispatchRequest.getMsgSize(), 
dispatchRequest.getTagsCode(), dispatchRequest.getConsumeQueueOffset());
    +
    +            
assertThat(Boolean.parseBoolean(dispatchResult.toString())).isTrue();
    +
    +        } finally {
    +            if (messageStore != null) {
    --- End diff --
    
    @fuyou001 It would look clear to remove try finally block from unit test. 
Better to do it in "@after".


> when os crash for some reasons, the broker consume queue’s data maybe repeat, 
> consumer can’t pull the latest message, cause message lag
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: ROCKETMQ-265
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-265
>             Project: Apache RocketMQ
>          Issue Type: Bug
>          Components: rocketmq-store
>    Affects Versions: 4.0.0-incubating, 4.1.0-incubating
>            Reporter: yubaofu
>            Assignee: yukon
>            Priority: Critical
>              Labels: bug
>             Fix For: 4.2.0-incubating
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> when os crash for some reasons, the broker consume queue’s data maybe repeat, 
> consumer can’t pull the latest message, cause message lag



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to