Skip to content

Conversation

@yihuang
Copy link

@yihuang yihuang commented Jun 20, 2023

Solution:

  • auto-recover the corrupted tail

Closes: #21

Solution:
- auto-recover the corrupted tail
@yihuang yihuang changed the title fix: wal tail could be corrupted feat: recover corrupted tail automatically Jun 20, 2023
DirPerms os.FileMode
FilePerms os.FileMode
// RecoverCorruptedTail will attempt to recover a corrupted tail in the last segment automatically.
RecoverCorruptedTail bool
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iiuc, the following scenarios would also need to be handled for completeness:

  • partial writes of payload, following the offset (i.e. when s.ebuf = ebuf[:pos] assignment below panics)
  • finding the last segment with non-corrupted data (the existing last segment file may only have corrupted data if e.g. it's 0 byte or the first entry is corrupted). We should delete that file and attempt reading second-to-last one (preferably with recoverCorruptedTail=false)
  • the last segment post-recovery must have non-zero entries or whatever is appropriate considering feat: TruncateFront & TruncateBack support truncating all entries #31

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the feedback, will think it through tmr, it's late here ;D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Needs to recover from corrupted tail

2 participants