Skip to content

[Robustness] Service.cs — CheckHealth holds _healthCheckSemaphore during disk I/O #528

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Warning

File: src/Servy.Service/Service.cs, line 1946

Description:
In the healthy-process path of CheckHealth, ConditionalResetRestartAttemptsAsync is called at line 1946 while _healthCheckSemaphore is still held. This method performs File.ReadAllTextAsync and potentially File.WriteAllTextAsync (disk I/O).

Every heartbeat tick where the process is healthy and the restart counter is non-zero blocks the semaphore for the duration of a disk read/write. Any concurrent OnProcessExited call stalls on _healthCheckSemaphore.Wait() at line 1618, delaying exit-event processing.

Design decision needed:
The restart counter file access does not modify shared in-memory state, so it could be moved outside the semaphore. However, this changes the ordering guarantees between health checks and exit events. What level of consistency is needed between _failedChecks and the restart counter file?

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