Skip to content

Release lock in AckEvent in base capability - #2358

Merged
DylanTinianov merged 1 commit into
mainfrom
ackEvent-release-lock-in-base
Sep 4, 2026
Merged

Release lock in AckEvent in base capability#2358
DylanTinianov merged 1 commit into
mainfrom
ackEvent-release-lock-in-base

Conversation

@yashnevatia

Copy link
Copy Markdown
Contributor

Requires

Supports

Copilot AI lite review requested due to automatic review settings September 4, 2026 13:03
@yashnevatia
yashnevatia requested a review from a team as a code owner September 4, 2026 13:03
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

👋 yashnevatia, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-common

View full report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The concurrency/deadlock fix should be accompanied by a targeted regression test to ensure AckEvent cannot reintroduce lock-holding behavior during capability updates/removal.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the base capabilities registry wrappers to avoid holding the wrapper mutex while forwarding AckEvent calls to the underlying capability, reducing the risk of lock contention/deadlocks during acknowledgements.

Changes:

  • Update atomicTriggerCapability.AckEvent to snapshot the underlying capability under RLock and call AckEvent without holding the mutex.
  • Update atomicExecuteAndTriggerCapability.AckEvent with the same lock-release/snapshot pattern.
File summaries
File Description
pkg/capabilities/registry/base.go Releases wrapper lock before calling underlying AckEvent by snapshotting cap under RLock
Review details

Suppressed comments (1)

pkg/capabilities/registry/base.go:571

  • Same as the trigger-only wrapper: this lock-release change in AckEvent should be covered by a regression test that simulates a blocked underlying AckEvent and verifies capability updates/removal don’t block (to prevent deadlocks from being reintroduced).
func (a *atomicExecuteAndTriggerCapability) AckEvent(ctx context.Context, triggerID string, eventID string, method string) error {
	a.mu.RLock()
	cap := a.cap
	a.mu.RUnlock()
	if cap == nil {
		return errors.New("capability unavailable")
	}
	return cap.AckEvent(ctx, triggerID, eventID, method)
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 387 to +394
func (a *atomicTriggerCapability) AckEvent(ctx context.Context, triggerID string, eventID string, method string) error {
a.mu.Lock()
defer a.mu.Unlock()
if a.cap == nil {
a.mu.RLock()
cap := a.cap
a.mu.RUnlock()
if cap == nil {
return errors.New("capability unavailable")
}
return a.cap.AckEvent(ctx, triggerID, eventID, method)
return cap.AckEvent(ctx, triggerID, eventID, method)
@DylanTinianov
DylanTinianov added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 0d1da9b Sep 4, 2026
33 of 34 checks passed
@DylanTinianov
DylanTinianov deleted the ackEvent-release-lock-in-base branch September 4, 2026 15:42
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.

4 participants