Skip to content

[Robustness] Manager ServiceCommands.cs — _serviceLocks ConcurrentDictionary grows without bound #647

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Warning

File: src/Servy.Manager/Services/ServiceCommands.cs
Lines: 710–714

Description:
_serviceLocks is a ConcurrentDictionary<string, SemaphoreSlim> that grows by one SemaphoreSlim per unique service name via GetOrAdd. Entries are never evicted after a service is removed — only at Dispose(). If services are repeatedly added and removed (e.g., automated deployments), the dictionary accumulates stale SemaphoreSlim objects indefinitely.

Suggested fix:
Remove entries from _serviceLocks after the last operation completes (e.g., TryRemove after Release if the semaphore count returns to 1), or prune periodically.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions