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 and Erigon: don't open files at startup if download is not finished (StageSnapshots == 0) #12332

Merged
merged 33 commits into from
Oct 18, 2024

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
@AskAlexSharov AskAlexSharov merged commit 200c85b into main Oct 18, 2024
11 checks passed
@AskAlexSharov AskAlexSharov deleted the rpcdaemon_dont_open_uncomplete branch October 18, 2024 07:33
@AskAlexSharov
Copy link
Collaborator Author

step2: #12362

AskAlexSharov added a commit that referenced this pull request Oct 19, 2024
only reason why we did it - is because we opened them first time when
downloading is not done yet. but after
#12332 - it can't happen
anymore
@AskAlexSharov AskAlexSharov changed the title RPCDaemon: don't open uncomplete files at startup RPCDaemon and Erigon: don't open files at startup if download is not finished (StageSnapshots == 0) Oct 22, 2024
@yperbasis yperbasis modified the milestones: 3.0.0-alpha6, 3.0.0-alpha5 Oct 23, 2024
AskAlexSharov pushed a commit that referenced this pull request Oct 24, 2024
1. accelerate scanning files by avoiding doubly nested loop
2. ~~do not reopen~~ (achieved by #12332 and #12362, so remove relevant
code here)
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.

4 participants