Skip to content
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

RPCDaemon: don't open uncomplete files at startup #12332

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

AskAlexSharov
Copy link
Collaborator

@AskAlexSharov AskAlexSharov commented Oct 16, 2024

Probably right way is: check StageSnapshots > 0 as "all downloads done". Because:

  • --prune.mode=minimal has not much files, but preverified.toml stays the same
  • downloader has logic to of prohibit_new_downloads.lock - downloading consider doen't even if preverified.toml has more files
  • small files may get merged - while preverified.toml stays the same
  • developer may generate new version of file (hash or len changed) - while preverified.toml stays the same
  • Downloader's Complete flag can't be used - because e3 does download headers and bodies first, then Complete=true happens, and then we download transactions (Complete=false happens).

@AskAlexSharov AskAlexSharov changed the title RPCDaemon: don't open uncoomplete files RPCDaemon: don't open uncoomplete files at startup Oct 16, 2024
@AskAlexSharov AskAlexSharov changed the title RPCDaemon: don't open uncoomplete files at startup [wip] RPCDaemon: don't open uncoomplete files at startup Oct 16, 2024
@AskAlexSharov AskAlexSharov added this to the 3.0.0-alpha6 milestone Oct 16, 2024
allBorSnapshots.OptimisticalyReopenFolder()
if doOptimisticOpen {
allSnapshots.OptimisticalyReopenFolder()
allBorSnapshots.OptimisticalyReopenFolder()
Copy link
Contributor

Choose a reason for hiding this comment

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

the naming is OptimisticallReopenFolder, but the ReopenFolder function it called doesn't open file in optimistic way.

@AskAlexSharov AskAlexSharov changed the title [wip] RPCDaemon: don't open uncoomplete files at startup [wip] RPCDaemon: don't open uncomplete files at startup Oct 17, 2024
@@ -2319,6 +2293,10 @@ func (d *Downloader) ReCalcStats(interval time.Duration) {

d.lock.Unlock()

if stats.Completed {
d.saveAllCompleteFlag()
Copy link
Contributor

Choose a reason for hiding this comment

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

There're two steps of downloading: 1. header chain segments(headers and bodies) 2. other segments(transactions...)
stats.Completed is true after the first step completed, but will be re-written to false once step2 starts.

should we wait all types of segments complete and then set the flag?

Copy link
Contributor

Choose a reason for hiding this comment

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

add some logs locally and here's logs test on sepolia:

Stats.Completed false
[INFO] [10-17|23:03:55.301] [1/6 OtterSync] Downloading              progress="(228/228 files) 99.71% - 2.7GB/2.7GB" rate=5.9MB/s time-left=0hrs:0m total-time=1m40s download-rate=5.9MB/s completion-rate=5.9MB/s alloc=552.7MB sys=653.8MB
Stats.Completed true
header and body snapshots downloaded completely
other snapshots downloading started
[INFO] [10-17|23:03:55.810] [snapshots] no metadata yet              files=90 list=domain/v1-accounts.0-128.bt,domain/v1-receipt.200-202.kv,v1-006710-006720-transactions.idx,v1-006730-006740-transactions.seg,domain/v1-accounts.192-200.bt,...
Stats.Completed false

Copy link
Contributor

Choose a reason for hiding this comment

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

And i'm a little confused that the flag seems to work the same way as prohibit_new_downloads.lock file, cause the file is written in right after specific types of segments complete downloading and stats.Completed turns true. However you said In the past i used prohibit_new_downloads.lock file for this - but now it created before download completion (and it’s fine).

If the prohibit_new_downloads file cannot mark the completion of download, then the flag cannot too.

If above is right, we can still use the way used by previous version of the PR , this function should work:
e729c1f#diff-f98a3c65d957c3d92bee0d12aeed5ec1ee902de014f1cda287f430808ea1aa2eR63

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You right. Maybe i must use “StageSnapshots progress > 0”

@AskAlexSharov AskAlexSharov changed the title [wip] RPCDaemon: don't open uncomplete files at startup RPCDaemon: don't open uncomplete files at startup Oct 18, 2024
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.

3 participants