Skip to content

controller: lock before reading finalizer state in handleDeletion#79

Open
tamalsaha wants to merge 1 commit into
masterfrom
refactor/handleDeletion-ordering
Open

controller: lock before reading finalizer state in handleDeletion#79
tamalsaha wants to merge 1 commit into
masterfrom
refactor/handleDeletion-ordering

Conversation

@tamalsaha

Copy link
Copy Markdown
Contributor

Summary

`handleDeletion` used to check `ContainsFinalizer` first and only then acquire the serialization mutex. If `MaxConcurrentReconciles` is ever bumped above 1, two goroutines could both see "finalizer present" and race on the cleanup.

Acquire the lock up front so the finalizer check and the cleanup-then-remove sequence run as one critical section. Cheap correctness step that lets later PRs bump concurrency without revisiting this path.

Test plan

  • `go build ./...`
  • Delete an ExternalDNS and confirm cleanup still happens exactly once and the finalizer is removed

handleDeletion checked ContainsFinalizer first and only then acquired
the serialization mutex. If MaxConcurrentReconciles ever goes above 1,
two goroutines could both see "finalizer present", then race on the
cleanup (one runs while the other has already removed it). Acquire the
lock up front so the finalizer check and the cleanup-then-remove
sequence run as one critical section.

Cheap correctness step that lets later PRs bump concurrency without
revisiting this path.

Signed-off-by: Tamal Saha <tamal@appscode.com>
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.

1 participant