-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fix: avoid data loss after truncate on init volume #5259
Conversation
Please add some comments here. I feel there should be a better way for this purpose. |
There can be two directions for improvement
|
Let's remove the truncation from the |
I have seen cases where trunking is necessary, but I suggest limiting it to one or two last files from the index. |
I looked everywhere where truncation was used to revert to a previous state before writing or before appending data on errors. So, in case of panic at the time of recording, the data that was not completely recorded can be saved, so when connecting the volume, a check is made to ensure that the last few files were recorded in their entirety. But this check does not cover extreme cases where the .dat or .idx file itself is significantly truncated. |
Isn't it better to get maximum offset of last 10 indexes (or maybe last 1% of indexes) and only truncate with that offset? |
Yes. good thought. |
fixed in 7c45992 |
What problem are we solving?
#4991
This is not exactly a solution to the problem, about the restriction on deleting data from dat files due to a broken idx
I want to avoid:
If you don’t do Truncate, the volume will go into read-only mode and you can rebuild the index manually using a
weed fix
It's not the best solution, but it's better than nothing.
The correct thing to do would be to rebuild the index. But this is an expensive operation.
How are we solving the problem?
avoid truncate dat file on init volume
How is the PR tested?
localy after fix
before fix:
Checks