-
Notifications
You must be signed in to change notification settings - Fork 838
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
Snapsync persist state #4381
Snapsync persist state #4381
Conversation
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
services/tasks/src/main/java/org/hyperledger/besu/services/tasks/FlatFileTaskCollection.java
Fixed
Show fixed
Hide fixed
3985ca0
to
fd8e70c
Compare
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
fd8e70c
to
16e1833
Compare
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
c6fdb82
to
26f0a74
Compare
…re/snapsync-persist Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
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.
intuitively I think that keeping the pending and inconsistent ranges in files in the filesystem rather than in rocksdb would be more flexible than adding column families. It is clearly a lot more data, but it would be consistent with how we treat pivot block.
Are we expecting that the number of files would be just too unwieldy?
@@ -33,7 +33,9 @@ public enum KeyValueSegmentIdentifier implements SegmentIdentifier { | |||
GOQUORUM_PRIVATE_STORAGE(new byte[] {12}), | |||
BACKWARD_SYNC_HEADERS(new byte[] {13}), | |||
BACKWARD_SYNC_BLOCKS(new byte[] {14}), | |||
BACKWARD_SYNC_CHAIN(new byte[] {15}); | |||
BACKWARD_SYNC_CHAIN(new byte[] {15}), | |||
SNAPSYNC_MISSING_ACCOUNT_RANGE(new byte[] {16}), |
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.
we should mark this PR as breaking backward compatibility if we add these column families
@@ -30,6 +30,7 @@ | |||
import java.util.function.Predicate; | |||
import java.util.stream.Stream; | |||
|
|||
import kotlin.Pair; |
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 we use java 17 record types yet?
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.
I propose to use org.apache.commons.lang3.tuple.Pair; is it fine for you ?
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.
because we are using java 11
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.
apache commons is good by me. We are so close to being able to use record types though... 🤤
try (final Stream<Pair<byte[], byte[]>> entry = keyValueStorage.stream()) { | ||
entry.forEach( | ||
key -> { | ||
lock.lock(); | ||
try { | ||
if (!inUseCheck.test(key) && keyValueStorage.tryDelete(key)) { | ||
if (!inUseCheck.test(key.getFirst()) && keyValueStorage.tryDelete(key.getFirst())) { |
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.
could we not use streamKeys() ? It looks like we are only using Pair.getFirst() here and in other places. I suspect the iterator for just keys would be more performant in cases where we only want keys 🤔
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.
Yes
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.
done
public Stream<Pair<byte[], byte[]>> stream() { | ||
final RocksIterator rocksIterator = db.newIterator(); | ||
rocksIterator.seekToFirst(); | ||
return RocksDbKeyIterator.create(rocksIterator).toStream(); | ||
return RocksDbIterator.create(rocksIterator).toStream(); | ||
} |
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.
seems like we could offer both stream() and streamKeys()
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.
Good catch
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.
done
Maybe rocksdb transactions are just cleaner to deal with than files ? 🤔 |
I tried a lot at the beginning to go through a file and I never managed to get a something clean. So I decided to switch to rocksdb .
Yes, the number of accounts to fix is something that cannot really be known over time. The bigger the chain, the bigger this list will be. And so you need a mechanism to manage this increase. I tried a lot to go through a file that splits when the size reaches a limit but after I said that I try to redo what rocksdb does better. So I decided to use rocksdb. But if you have a better idea to go through a file that could be split via a library why not |
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
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. The only open question is whether or not the new column families break backward compatibility. @gezero did you make besu handle extra column families or just bela?
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
This PR avoids restarting the download of the world state from scratch when restarting Besu Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
This PR avoids restarting the download of the world state from scratch when restarting Besu Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
PR description
This PR avoids starting the download of the world state from scratch when restarting Besu
Fixed Issue(s)
Documentation
doc-change-required
label to this PR ifupdates are required.
Changelog