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

storage: source storage timeout #276

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion analyzer/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (

const (
ConsensusDamaskAnalyzerName = "consensus_damask"

ProcessBlockTimeout = 61 * time.Second
)

type EventType = apiTypes.ConsensusEventType // alias for brevity
Expand Down Expand Up @@ -266,13 +268,16 @@ func (m *Main) processGenesis(ctx context.Context) error {
// from source storage and committing an atomically-executed batch of queries
// to target storage.
func (m *Main) processBlock(ctx context.Context, height int64) error {
ctxWithTimeout, cancel := context.WithTimeout(ctx, ProcessBlockTimeout)
defer cancel()

// Fetch all data.
source, err := m.source(height)
if err != nil {
return err
}

data, err := source.AllData(ctx, height)
data, err := source.AllData(ctxWithTimeout, height)
if err != nil {
return err
}
Expand Down
8 changes: 6 additions & 2 deletions analyzer/emerald/emerald.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const (
emerald = analyzer.RuntimeEmerald

EmeraldDamaskAnalyzerName = "emerald_damask"

ProcessRoundTimeout = 61 * time.Second
)

// Main is the main Analyzer for the Emerald Runtime.
Expand Down Expand Up @@ -218,13 +220,15 @@ func (m *Main) processRound(ctx context.Context, round uint64) error {
"round", round,
)

group, groupCtx := errgroup.WithContext(ctx)
ctxWithTimeout, cancel := context.WithTimeout(ctx, ProcessRoundTimeout)
defer cancel()
group, groupCtx := errgroup.WithContext(ctxWithTimeout)

// Prepare and perform updates.
batch := &storage.QueryBatch{}

group.Go(func() error {
return m.prepareBlockData(ctx, round, batch)
return m.prepareBlockData(groupCtx, round, batch)
})

type prepareFunc = func(context.Context, uint64, *storage.QueryBatch) error
Expand Down