-
Notifications
You must be signed in to change notification settings - Fork 384
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
Add MigratableKVStore
trait
#3481
Add MigratableKVStore
trait
#3481
Conversation
.. which will be used for generic `KVStore`-to-`KVStore` migration logic.
98239df
to
b75d953
Compare
Added a migration util method and a test for |
877a636
to
bbcd31c
Compare
Addressed pending comments, let me know if I can squash fixups. |
bbcd31c
to
adcbd91
Compare
adcbd91
to
f391296
Compare
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.
Lgtm, mod nits.
f391296
to
ecdacd3
Compare
Addressed pending feedback. |
Feel free to squash, IMO. |
ecdacd3
to
3804d4c
Compare
Squashed fixups without further changes. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3481 +/- ##
==========================================
+ Coverage 89.70% 91.28% +1.58%
==========================================
Files 130 130
Lines 107422 118991 +11569
Branches 107422 118991 +11569
==========================================
+ Hits 96362 108622 +12260
+ Misses 8669 8136 -533
+ Partials 2391 2233 -158 ☔ View full report in Codecov by Sentry. |
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.
Lgtm!
.. which we'll be reusing shortly.
We implement the new interface on `FilesystemStore`, in particular `list_all_keys`.
.. allowing to migrate data from one store to another.
3804d4c
to
b0af39f
Compare
Force-pushed with fixups: 2024-12-add-kvstore-migration-ext ~/workspace/rust-lightning> git diff-tree -U2 3804d4c3d b0af39faa
diff --git a/lightning-persister/src/fs_store.rs b/lightning-persister/src/fs_store.rs
index a1d13c06b..487e1a7ac 100644
--- a/lightning-persister/src/fs_store.rs
+++ b/lightning-persister/src/fs_store.rs
@@ -348,6 +348,9 @@ fn dir_entry_is_key(p: &Path) -> Result<bool, lightning::io::Error> {
let metadata = p.metadata().map_err(|e| {
- let msg =
- format!("Failed to list keys at path {:?}: {}", p.to_str().map(PrintableString), e);
+ let msg = format!(
+ "Failed to list keys at path {}: {}",
+ PrintableString(p.to_str().unwrap_or_default()),
+ e
+ );
lightning::io::Error::new(lightning::io::ErrorKind::Other, msg)
})?;
@@ -362,10 +365,10 @@ fn dir_entry_is_key(p: &Path) -> Result<bool, lightning::io::Error> {
debug_assert!(
false,
- "Failed to list keys at path {:?}: file couldn't be accessed.",
- p.to_str().map(PrintableString)
+ "Failed to list keys at path {}: file couldn't be accessed.",
+ PrintableString(p.to_str().unwrap_or_default())
);
let msg = format!(
- "Failed to list keys at path {:?}: file couldn't be accessed.",
- p.to_str().map(PrintableString)
+ "Failed to list keys at path {}: file couldn't be accessed.",
+ PrintableString(p.to_str().unwrap_or_default())
);
return Err(lightning::io::Error::new(lightning::io::ErrorKind::Other, msg));
@@ -384,10 +387,10 @@ fn get_key_from_dir_entry(p: &Path, base_path: &Path) -> Result<String, lightnin
debug_assert!(
false,
- "Failed to list keys of path {:?}: file path is not valid key",
- p.to_str().map(PrintableString)
+ "Failed to list keys of path {}: file path is not valid key",
+ PrintableString(p.to_str().unwrap_or_default())
);
let msg = format!(
- "Failed to list keys of path {:?}: file path is not valid key",
- p.to_str().map(PrintableString)
+ "Failed to list keys of path {}: file path is not valid key",
+ PrintableString(p.to_str().unwrap_or_default())
);
return Err(lightning::io::Error::new(lightning::io::ErrorKind::Other, msg));
@@ -396,10 +399,10 @@ fn get_key_from_dir_entry(p: &Path, base_path: &Path) -> Result<String, lightnin
debug_assert!(
false,
- "Failed to list keys of path {:?}: file path is not valid UTF-8",
- p
+ "Failed to list keys of path {}: file path is not valid UTF-8",
+ PrintableString(p.to_str().unwrap_or_default())
);
let msg = format!(
- "Failed to list keys of path {:?}: file path is not valid UTF-8",
- p.to_str().map(PrintableString)
+ "Failed to list keys of path {}: file path is not valid UTF-8",
+ PrintableString(p.to_str().unwrap_or_default())
);
return Err(lightning::io::Error::new(lightning::io::ErrorKind::Other, msg));
@@ -409,10 +412,13 @@ fn get_key_from_dir_entry(p: &Path, base_path: &Path) -> Result<String, lightnin
debug_assert!(
false,
- "Failed to list keys of path {:?}: {}",
- p.to_str().map(PrintableString),
+ "Failed to list keys of path {}: {}",
+ PrintableString(p.to_str().unwrap_or_default()),
+ e
+ );
+ let msg = format!(
+ "Failed to list keys of path {}: {}",
+ PrintableString(p.to_str().unwrap_or_default()),
e
);
- let msg =
- format!("Failed to list keys of path {:?}: {}", p.to_str().map(PrintableString), e);
return Err(lightning::io::Error::new(lightning::io::ErrorKind::Other, msg));
},
@@ -467,10 +473,10 @@ impl MigratableKVStore for FilesystemStore {
debug_assert!(
false,
- "Failed to list keys of path {:?}: only two levels of namespaces are supported",
- tertiary_path.to_str()
- );
+ "Failed to list keys of path {}: only two levels of namespaces are supported",
+ PrintableString(tertiary_path.to_str().unwrap_or_default())
+ );
let msg = format!(
- "Failed to list keys of path {:?}: only two levels of namespaces are supported",
- tertiary_path.to_str()
+ "Failed to list keys of path {}: only two levels of namespaces are supported",
+ PrintableString(tertiary_path.to_str().unwrap_or_default())
);
return Err(lightning::io::Error::new(
|
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.
Can land this and fix up the test later, or feel free to fix it now.
Closes #3387
We add a
MigratableKVStore
trait (suggestion for better naming are welcome) that describes methods required to write generalizedKVStore
-to-KVStore
migration logic. In particular, it adds afn list_all_keys
method that exhaustively lists all keys stored, which then can be used by a utility to transfer all of them to the new store before deleting the old state.We implement this new trait for
FilesystemStore
.TODOs (draft until then):FilesystemStore
toFilesystemStore
migration.Should be ready for review.