Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about CommitLog::recoverAbnormally #1434

Closed
BeiKeJieDeLiuLangMao opened this issue Aug 31, 2019 · 3 comments
Closed

Question about CommitLog::recoverAbnormally #1434

BeiKeJieDeLiuLangMao opened this issue Aug 31, 2019 · 3 comments

Comments

@BeiKeJieDeLiuLangMao
Copy link

As i know, logic of recoverAbnormally is as follow:

  1. Find first valid CommitLog file from last one
  2. Check all message in last valid CommitLog file
  3. For these valid messages in last valid CommitLog file, rebuild ConsumeQueue and IndexFile
  4. Fix all kinds of pointers, and clear ConsumeQueue redundant data

Now consider follow situation:

  1. A few messages been written to CommitLog file L2(last 2), and these message are last messages of this CommitLog file
  2. Create a new CommitLog file L1(last 1),then write a message to L1
  3. At this time, L2's last few messages and L1's first message are not been written to ConsumeQueue and IndexFile yet, then RocketMQ crash
  4. When RocketMQ restart, it will invoke recoverAbnormally, and only rebuild L1's message, L2's last few messages are lost.

If my analysis is right, i think follow solution could resolve it:

  1. Find first valid CommitLog file from last one
  2. Check all message in last valid CommitLog file
  3. Fix all kinds of pointers, and clear ConsumeQueue redundant data
  4. In step3, we could get valid ConsumeQueue max physics offset, besides we could also get IndexFile's max physics offset from file header
  5. In the light of ConsumeQueue max physics offset and IndexFile max physics offset, we could rebuild lost content respectively

This solution not only could resolve data lost issue what i described before, but also could reduce duplicate data of ConsumeQueue and IndexFile :).

@Gump518
Copy link

Gump518 commented Dec 24, 2020

Theoretically, I agree that this is the case.Doesn't everybody have that question?Strangely enough, 19 years of asking questions and nobody paid attention

@github-actions
Copy link

github-actions bot commented Oct 3, 2022

This issue is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs.

@github-actions github-actions bot added the stale label Oct 3, 2022
@github-actions
Copy link

github-actions bot commented Oct 7, 2022

This issue was closed because it has been inactive for 3 days since being marked as stale.

@github-actions github-actions bot closed this as completed Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants