-
Notifications
You must be signed in to change notification settings - Fork 112
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
Database loading statuses #5405
Draft
jberci
wants to merge
2
commits into
master
Choose a base branch
from
jberci/feature/dbstatus
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package storage | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/oasisprotocol/oasis-core/go/common" | ||
|
@@ -9,6 +10,7 @@ import ( | |
"github.com/oasisprotocol/oasis-core/go/common/node" | ||
"github.com/oasisprotocol/oasis-core/go/common/workerpool" | ||
"github.com/oasisprotocol/oasis-core/go/config" | ||
storageApi "github.com/oasisprotocol/oasis-core/go/storage/api" | ||
"github.com/oasisprotocol/oasis-core/go/storage/mkvs/checkpoint" | ||
workerCommon "github.com/oasisprotocol/oasis-core/go/worker/common" | ||
committeeCommon "github.com/oasisprotocol/oasis-core/go/worker/common/committee" | ||
|
@@ -95,9 +97,8 @@ func (w *Worker) registerRuntime(commonNode *committeeCommon.Node, checkpointerC | |
} | ||
} | ||
|
||
localStorage, err := NewLocalBackend(commonNode.Runtime.DataDir(), id) | ||
if err != nil { | ||
return fmt.Errorf("can't create local storage backend: %w", err) | ||
storageCtor := func(ctx context.Context) (storageApi.LocalBackend, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why we don't create the local storage backend in |
||
return NewLocalBackend(commonNode.Runtime.DataDir(), id) | ||
} | ||
|
||
node, err := committee.NewNode( | ||
|
@@ -106,7 +107,7 @@ func (w *Worker) registerRuntime(commonNode *committeeCommon.Node, checkpointerC | |
rp, | ||
rpRPC, | ||
w.commonWorker.GetConfig(), | ||
localStorage, | ||
storageCtor, | ||
checkpointerCfg, | ||
&committee.CheckpointSyncConfig{ | ||
Disabled: config.GlobalConfig.Storage.CheckpointSyncDisabled, | ||
|
@@ -116,7 +117,6 @@ func (w *Worker) registerRuntime(commonNode *committeeCommon.Node, checkpointerC | |
if err != nil { | ||
return err | ||
} | ||
commonNode.Runtime.RegisterStorage(localStorage) | ||
commonNode.AddHooks(node) | ||
w.runtimes[id] = node | ||
|
||
|
@@ -167,13 +167,21 @@ func (w *Worker) Start() error { | |
}() | ||
|
||
// Start all runtimes and wait for initialization. | ||
go func() { | ||
w.logger.Info("starting storage sync services", "num_runtimes", len(w.runtimes)) | ||
var err error | ||
|
||
for _, r := range w.runtimes { | ||
_ = r.Start() | ||
w.logger.Info("starting storage sync services", "num_runtimes", len(w.runtimes)) | ||
for id, r := range w.runtimes { | ||
if err = r.Start(); err != nil { | ||
w.logger.Error("committee node did not start successfully", "err", err, "runtime", id) | ||
} | ||
defer func(r *committee.Node) { | ||
if err != nil { | ||
r.Stop() | ||
} | ||
}(r) | ||
} | ||
|
||
go func() { | ||
// Wait for runtimes to be initialized and the node to be registered. | ||
for _, r := range w.runtimes { | ||
<-r.Initialized() | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Isn't doing this async dangerous? Where do we ensure that start is not called before this completes? Related goroutines should probably block on a channel that gets closed once this deferred init completes?