storage: Fix 32-bit checksums (test) and update backup dir

Also added changelog entry
next
Sayan Nandan 6 months ago
parent 13361fe535
commit aa7051b6e1
No known key found for this signature in database
GPG Key ID: 0EBD769024B24F0A

@ -4,6 +4,10 @@ All changes in this project will be noted in this file.
## Version 0.8.1 ## Version 0.8.1
### Additions
- Added support for manual repair with the `skyd repair` command
### Fixes ### Fixes
- Fixed migration from v1 SE (released with v0.8.0-beta) to v2 SE (released in v0.8.0) - Fixed migration from v1 SE (released with v0.8.0-beta) to v2 SE (released in v0.8.0)

@ -13,6 +13,9 @@ Usage: skyd [OPTION]...
skyd is the Skytable database server daemon and can be used to serve database requests. skyd is the Skytable database server daemon and can be used to serve database requests.
Commands:
repair Check and repair any detected database storage errors
Flags: Flags:
-h, --help Display this help menu and exit. -h, --help Display this help menu and exit.
-v, --version Display the version number and exit. -v, --version Display the version number and exit.
@ -36,5 +39,7 @@ Notes:
- If no `--mode` is provided, we default to `dev` - If no `--mode` is provided, we default to `dev`
- You must provide `--auth-root-password` to set the default root password - You must provide `--auth-root-password` to set the default root password
- To use TLS, you must provide both `--tlscert` and `--tlskey` - To use TLS, you must provide both `--tlscert` and `--tlskey`
- When you run `repair`, your previous data is backed up in the `backups/` folder.
Restore if needed.
For further assistance, refer to the official documentation here: https://docs.skytable.org For further assistance, refer to the official documentation here: https://docs.skytable.org

@ -168,7 +168,10 @@ pub fn restore(cfg: &Configuration) -> RuntimeResult<SELoaded> {
pub fn repair() -> RuntimeResult<()> { pub fn repair() -> RuntimeResult<()> {
// back up all files // back up all files
let backup_dir = format!("backups/{}-before-repair-backup", util::time_now_string()); let backup_dir = format!(
"backups/{}-before-recovery-process",
util::time_now_string()
);
context::set_dmsg("creating backup directory"); context::set_dmsg("creating backup directory");
FileSystem::create_dir_all(&backup_dir)?; FileSystem::create_dir_all(&backup_dir)?;
context::set_dmsg("backing up GNS"); context::set_dmsg("backing up GNS");

@ -114,7 +114,7 @@ impl_db_event!(
checksum.update(&length_bytes); checksum.update(&length_bytes);
checksum.update(&me_bytes); checksum.update(&me_bytes);
buf.extend(&(checksum.finish().to_le_bytes())); // checksum buf.extend(&(checksum.finish().to_le_bytes())); // checksum
buf.extend(&(me.0.len() as u64).to_le_bytes()); // length buf.extend(&length_bytes); // length
buf.extend(me.0.as_bytes()); // payload buf.extend(me.0.as_bytes()); // payload
}, },
DbEventPop as 1, DbEventPop as 1,
@ -173,7 +173,8 @@ impl RawJournalAdapter for SimpleDBJournal {
match meta { match meta {
EventMeta::NewKey => { EventMeta::NewKey => {
let checksum = u64::from_le_bytes(file.read_block()?); let checksum = u64::from_le_bytes(file.read_block()?);
let length = u64::from_le_bytes(file.read_block()?) as usize; let length_u64 = u64::from_le_bytes(file.read_block()?);
let length = length_u64 as usize;
let mut payload = Vec::<u8>::new(); let mut payload = Vec::<u8>::new();
if length > SANE_MEM_LIMIT_BYTES if length > SANE_MEM_LIMIT_BYTES
|| payload.try_reserve_exact(length as usize).is_err() || payload.try_reserve_exact(length as usize).is_err()
@ -186,7 +187,7 @@ impl RawJournalAdapter for SimpleDBJournal {
} }
file.tracked_read(&mut payload)?; file.tracked_read(&mut payload)?;
let mut this_checksum = SCrc64::new(); let mut this_checksum = SCrc64::new();
this_checksum.update(&length.to_le_bytes()); this_checksum.update(&length_u64.to_le_bytes());
this_checksum.update(&payload); this_checksum.update(&payload);
match String::from_utf8(payload) { match String::from_utf8(payload) {
Ok(k) if this_checksum.finish() == checksum => gs.data.borrow_mut().push(k), Ok(k) if this_checksum.finish() == checksum => gs.data.borrow_mut().push(k),

Loading…
Cancel
Save