Skip to content

fix: prevent duty loss and fix misleading comment in deadliner#4498

Open
enlightened88 wants to merge 3 commits intoObolNetwork:mainfrom
enlightened88:patch-2
Open

fix: prevent duty loss and fix misleading comment in deadliner#4498
enlightened88 wants to merge 3 commits intoObolNetwork:mainfrom
enlightened88:patch-2

Conversation

@enlightened88
Copy link
Copy Markdown

Remove the default branch from the timer case in deadliner.run to ensure deadlined duties are never silently dropped when the output channel is full. Also fix an incorrect comment in getCurrDuty that said latest instead of earliest

Signed-off-by: Андрій Шовкошитний <198119344+enlightened88@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the core deadliner to avoid silently dropping expired duties when the output channel is full, and corrects a misleading comment about duty selection order.

Changes:

  • Make deadliner.run always block (or exit on context cancel) until a deadlined duty is delivered to deadlineChan, instead of dropping it on a full channel.
  • Fix getCurrDuty’s comment to say it selects the earliest deadline (matching the implementation).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/deadline.go Outdated
Comment thread core/deadline.go Outdated
Comment on lines +178 to +186
case <-currTimer.Chan():
// Send deadlined duty to receiver.
select {
case <-ctx.Done():
return
case d.deadlineChan <- currDuty:
default:
log.Warn(ctx, "Deadliner output channel full", nil,
z.Str("label", d.label),
z.Any("duty", currDuty),
)
}

delete(duties, currDuty)
setCurrState()
select {
case <-ctx.Done():
return
case d.deadlineChan <- currDuty:
}

delete(duties, currDuty)
setCurrState()
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

This change removes the non-blocking send that previously dropped duties when deadlineChan was full. Please add/extend a unit test that fills the deadlineChan buffer (e.g., 11+ duties with the same deadline) and asserts that all duties are eventually delivered (none dropped) once the consumer starts reading, to prevent regressions.

Copilot uses AI. Check for mistakes.
Comment thread core/deadline.go Outdated
@KaloyanTanev
Copy link
Copy Markdown
Collaborator

@enlightened88 did you experience any bug or degraded performance because of the current logic? Currently the buffer is 10, which is more than enough to support all duties before they time out. For gloas we will likely increase it slightly though, because of PTC.

enlightened88 and others added 2 commits April 28, 2026 12:11
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Андрій Шовкошитний <198119344+enlightened88@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Андрій Шовкошитний <198119344+enlightened88@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

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.

3 participants