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

Ledger init status #1058

Merged
merged 8 commits into from Jun 28, 2022
Merged

Ledger init status #1058

merged 8 commits into from Jun 28, 2022

Conversation

shiqizng
Copy link
Contributor

Summary

This PR adds status logging for ledger init and stops node if it's running when indexer receives SIGTERM or SIGINT.

Test Plan

regression testing, run daemon.

@codecov
Copy link

codecov bot commented Jun 23, 2022

Codecov Report

❗ No coverage uploaded for pull request base (localledger/integration@5584c6d). Click here to learn what that means.
The diff coverage is n/a.

@@                    Coverage Diff                     @@
##             localledger/integration    #1058   +/-   ##
==========================================================
  Coverage                           ?   58.74%           
==========================================================
  Files                              ?       49           
  Lines                              ?     8780           
  Branches                           ?        0           
==========================================================
  Hits                               ?     5158           
  Misses                             ?     3139           
  Partials                           ?      483           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5584c6d...762a17e. Read the comment docs.

if err != nil {
return &blockProcessor{}, fmt.Errorf("MakeProcessorWithCatchup() slow catchup err: %w", err)
}
}
return MakeProcessor(logger, genesis, nextDBRound, opts.AlgodDataDir, handler)
return MakeProcessor(logger, genesis, nextDBRound, opts.IndexerDatadir, handler)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should be the indexer directory?

@shiqizng shiqizng requested a review from winder June 24, 2022 14:15
@shiqizng shiqizng requested a review from winder June 27, 2022 17:15
os.Exit(1)
}()
}
func InitializeLedgerSimple(ctx context.Context, cf context.CancelFunc, logger *log.Logger, round uint64, opts *idb.IndexerDbOptions) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is something missing here? How does this exit when it's all caught up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cancel() is called here

if uint64(block.Block.Round()) == dbRound {
// migration completes
cancel()
} else {

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I missed that.

I think this would cause problems because the context is going to be cancelled when we're finished initializing. You can wrap the context with another WithCancel. I had to try it, but this seems to work as expected: https://go.dev/play/p/l1S-LqG0MkR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix added.

@@ -26,21 +24,9 @@ import (
)

// InitializeLedgerSimple executes the migration core functionality.
func InitializeLedgerSimple(logger *log.Logger, round uint64, opts *idb.IndexerDbOptions) error {
ctx, cf := context.WithCancel(context.Background())
func InitializeLedgerSimple(ctx context.Context, logger *log.Logger, round uint64, opts *idb.IndexerDbOptions) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this function supposed to block until initialization is complete? It looks like it starts fetcher and then runs in the background.

Copy link
Contributor

Choose a reason for hiding this comment

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

bot.Run is blocking, nevermind!

@winder winder merged commit a1a08b2 into localledger/integration Jun 28, 2022
@winder winder deleted the shiqi/logging branch June 28, 2022 18:34
Eric-Warehime added a commit that referenced this pull request Jul 21, 2022
* Local Ledger (#1011)

* integrate block processor

* Local Ledger Deployment (#1013)

* add simple local ledger migration

* add deleted opts

* fast catchup (#1023)

* add fast catchup

* Localledger merge (#1036)

* return empty lists from fetchApplications and fetchAppLocalStates (#1010)

* Update model to converge with algod (#1005)

* New Feature: Adds Data Directory Support (#1012)

- Updates the go-algorand submodule hash to point to rel/beta
- Moves the cpu profiling file, pid file and indexer configuration file
  to be options of only the daemon sub-command
- Changes os.Exit() to be a panic with a special handler.  This is so
  that defer's are handled instead of being ignored.
- Detects auto-loading configuration files in the data directory and
  issues errors if equivalent command line arguments are supplied.
- Updates the README with instructions on how to use the auto-loading
  configuration files and the data directory.

* Update mockery version

Co-authored-by: erer1243 <1377477+erer1243@users.noreply.github.com>
Co-authored-by: AlgoStephenAkiki <85183435+AlgoStephenAkiki@users.noreply.github.com>

* recovery scenario (#1024)

* handle ledger recovery scenario

* refactor create genesis block (#1026)

* refactor create genesis block

* Adds Local Ledger Readme (#1035)

* Adds Local Ledger Readme

Resolves #4109

Starts Readme docs

* Update docs/LocalLedger.md

Co-authored-by: Will Winder <wwinder.unh@gmail.com>

* Update docs/LocalLedger.md

Co-authored-by: Will Winder <wwinder.unh@gmail.com>

* Update docs/LocalLedger.md

Co-authored-by: Will Winder <wwinder.unh@gmail.com>

* Removed troubleshooting section

Co-authored-by: Will Winder <wwinder.unh@gmail.com>

* update ledger file path and migration (#1042)

* LocalLedger Refactoring + Catchpoint Service (#1049)

Part 1

    cleanup genesis file access.
    put node catchup into a function that can be swapped out with the catchup service.
    pass the indexer logger into the block processor.
    move open ledger into a util function, and move the initial state util function into a new ledger util file.
    add initial catchupservice implementation.
    move ledger init from daemon.go to constructor.
    Merge multiple read genesis functions.

Part 2

    Merge local_ledger migration package into blockprocessor.
    Rename Migration to Initialize
    Use logger in catchup service catchup

Part 3

    Update submodule and use NewWrappedLogger.
    Make util.CreateInitState private

* build: merge develop into localledger/integration (#1062)

* Ledger init status (#1058)

* Generate an error if the catchpoint is not valid for initialization. (#1075)

* Use main logger in handler and fetcher. (#1077)

* Switch from fullNode catchup to catchpoint catchup service. (#1076)

* Refactor daemon, add more tests (#1039)

Refactors daemon cmd into separate, testable pieces.

* Merge develop into localledger/integration (#1083)

* Misc Local Ledger cleanup (#1086)

* Update processor/blockprocessor/initialize.go

Co-authored-by: Zeph Grunschlag <tzaffi@users.noreply.github.com>

* commit

* fix function call args

* RFC-0001: Rfc 0001 impl (#1069)

Adds an Exporter interface and a noop exporter implementation with factory methods for construction

* Fix test errors

* Add/fix tests

* Add postgresql_exporter tests

* Update config loading

* Change BlockExportData to pointers

* Move and rename ExportData

* Add Empty func to BlockData

* Add comment

Co-authored-by: shiqizng <80276844+shiqizng@users.noreply.github.com>
Co-authored-by: shiqi.zheng@algorand.com <shiqi.zheng@algorand.com>
Co-authored-by: erer1243 <1377477+erer1243@users.noreply.github.com>
Co-authored-by: AlgoStephenAkiki <85183435+AlgoStephenAkiki@users.noreply.github.com>
Co-authored-by: Will Winder <wwinder.unh@gmail.com>
Co-authored-by: Zeph Grunschlag <tzaffi@users.noreply.github.com>
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.

None yet

4 participants