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
Raft: do not ever remove state, rename it and leave it around #233
Conversation
This commit changes the way that consensus.Clean() works. Before it deleted the whole data folder. Now it renames it as <name>.old.0 and leaves it. When Clean() is called again, it renames <name>.old.0 as <name>.old.1, and the actual data becomes <name>.old.0. Higher number means older. The number of backups is fixed to 5. When 5 backups exists and a new one comes up again, the last one is discarded. License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small thing about error messages
consensus/raft/data_helper_test.go
Outdated
} | ||
backups := helper.listBackups() | ||
if i < RaftDataBackupKeep && len(backups) != i+1 { | ||
t.Fatal("not saving enough backups") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If something really weird happened with the helper and too many backups were saved before iteration RaftDataBackupKeep
or alternatively too few backups were saved after iteration RaftDataBackupKeep
, then the error messages will be misleading. As the check stands, a better message would be "incorrect number of backups saved"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok fixed
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
LGTM |
Thanks! |
This commit changes the way that consensus.Clean() works. Before
it deleted the whole data folder. Now it renames it as .old.0
and leaves it. When Clean() is called again, it renames .old.0
as .old.1, and the actual data becomes .old.0. Higher number
means older. The number of backups is fixed to 5. When 5 backups exists
and a new one comes up again, the last one is discarded.
License: MIT
Signed-off-by: Hector Sanjuan hector@protocol.ai