Skip to content

Conversation

@arturaslcast
Copy link
Contributor

actions might be executed at least twice as PollActions and AckAction are asynchronous operations and can sometimes race. Introduce a store for tracking recently completed actions to avoid that. The completed actions will be garbage collected after two polls when they are completed and successfully acked.

@arturaslcast arturaslcast requested a review from a team as a code owner January 8, 2026 10:28

startedActionsWg sync.WaitGroup
startedActions map[string]struct{}
completedActions map[string]time.Time
Copy link

Choose a reason for hiding this comment

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

guess it's time to create a map + RWMutex as a separate struct

now := time.Now()

s.startedActionsMu.Lock()
defer s.startedActionsMu.Unlock()
Copy link

Choose a reason for hiding this comment

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

why are u locking on startedActionsMu here? i think it's better to lock on separate mutex
once again, i think we need simple concurrent map as separate struct

observedMax := maxExecutingObserved
counts := make(map[string]int)
for k, v := range executionCounts {
counts[k] = v
Copy link

Choose a reason for hiding this comment

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

btw, this is frustrating
image
i don't think linter should be that strict

Copy link

@cirisked cirisked left a comment

Choose a reason for hiding this comment

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

all good, but i'd like to have separate struct to handle concurrent map read/write ops

healthCheck *health.HealthzProvider
actionsMu sync.Mutex
startedActions map[string]struct{} // protected by actionsMu
completedActions map[string]int8 // protected by actionsMu
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] I'd call it recentlyCompletedActions to be more accurrate

@arturaslcast arturaslcast merged commit 8e403ca into main Jan 9, 2026
4 of 5 checks passed
@arturaslcast arturaslcast deleted the arturasl/completed-actions branch January 9, 2026 13:02
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