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

fix: use context deadlines only if task has been assigned work #70

Merged
merged 1 commit into from
Oct 7, 2020
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
4 changes: 2 additions & 2 deletions tasks/actorstate/actorstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ func (p *ActorStateProcessor) processBatch(ctx context.Context) (bool, error) {

// Lease some blocks to work on
claimUntil := p.clock.Now().Add(p.leaseLength)
ctx, cancel := context.WithDeadline(ctx, claimUntil)
defer cancel()

batch, err := p.storage.LeaseActors(ctx, claimUntil, p.batchSize, p.minHeight, p.maxHeight, p.actorCodes)
if err != nil {
Expand All @@ -138,6 +136,8 @@ func (p *ActorStateProcessor) processBatch(ctx context.Context) (bool, error) {
}

log.Debugw("leased batch of actors", "count", len(batch))
ctx, cancel := context.WithDeadline(ctx, claimUntil)
defer cancel()

for _, actor := range batch {
// Stop processing if we have somehow passed our own lease time
Expand Down
4 changes: 2 additions & 2 deletions tasks/actorstate/actorstatechange.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ func (p *ActorStateChangeProcessor) processBatch(ctx context.Context) (bool, err
defer span.End()

claimUntil := p.clock.Now().Add(p.leaseLength)
ctx, cancel := context.WithDeadline(ctx, claimUntil)
defer cancel()

// Lease some tipsets to work on
batch, err := p.storage.LeaseStateChanges(ctx, claimUntil, p.batchSize, p.minHeight, p.maxHeight)
Expand All @@ -75,6 +73,8 @@ func (p *ActorStateChangeProcessor) processBatch(ctx context.Context) (bool, err
}

log.Debugw("leased batch of tipsets", "count", len(batch))
ctx, cancel := context.WithDeadline(ctx, claimUntil)
defer cancel()

for _, item := range batch {
// Stop processing if we have somehow passed our own lease time
Expand Down
4 changes: 2 additions & 2 deletions tasks/message/gasoutputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ func (p *GasOutputsProcessor) processBatch(ctx context.Context) (bool, error) {
defer span.End()

claimUntil := p.clock.Now().Add(p.leaseLength)
ctx, cancel := context.WithDeadline(ctx, claimUntil)
defer cancel()

// Lease some messages with receipts to work on
batch, err := p.storage.LeaseGasOutputsMessages(ctx, claimUntil, p.batchSize, p.minHeight, p.maxHeight)
Expand All @@ -69,6 +67,8 @@ func (p *GasOutputsProcessor) processBatch(ctx context.Context) (bool, error) {
}

log.Debugw("leased batch of messages", "count", len(batch))
ctx, cancel := context.WithDeadline(ctx, claimUntil)
defer cancel()

for _, item := range batch {
// Stop processing if we have somehow passed our own lease time
Expand Down
4 changes: 2 additions & 2 deletions tasks/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func (p *MessageProcessor) processBatch(ctx context.Context) (bool, error) {
defer span.End()

claimUntil := p.clock.Now().Add(p.leaseLength)
ctx, cancel := context.WithDeadline(ctx, claimUntil)
defer cancel()

// Lease some blocks to work on
batch, err := p.storage.LeaseTipSetMessages(ctx, claimUntil, p.batchSize, p.minHeight, p.maxHeight)
Expand All @@ -78,6 +76,8 @@ func (p *MessageProcessor) processBatch(ctx context.Context) (bool, error) {
}

log.Debugw("leased batch of tipsets", "count", len(batch))
ctx, cancel := context.WithDeadline(ctx, claimUntil)
defer cancel()

for _, item := range batch {
// Stop processing if we have somehow passed our own lease time
Expand Down