Skip to content

Backport(v1.16) Windows: Fix an issue where stopping the service immediately after startup could leave the processes (#4782) #4802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

kenhys
Copy link
Contributor

@kenhys kenhys commented Jan 29, 2025

Which issue(s) this PR fixes:

Backport #4782

What this PR does / why we need it:

Add retry for stop event for Windows Service to fix #3937.

If Event.open()
(OpenEvent) is called before the Event.new()
(CreateEvent), Event.open() raises Errno::ENOENT.
This causes the service to be stopped while the supervisor and worker process remains.
It causes #3937.
This PR fixes it by adding retry.

ev = Win32::Event.open(event_name)

{win32_event: Win32::Event.new("#{@signame}"), action: :stop},

Docs Changes:
Not needed.

Release Note:
It would be good to have both of the following.

  • Windows: Fixed an issue where stopping the service immediately after startup could leave the processes.
  • Windows: Fixed an issue where stopping service sometimes can not be completed forever.

…artup could leave the processes (#4782)

**Which issue(s) this PR fixes**:
* Fixes #3937

**What this PR does / why we need it**:
Add retry for stop event for Windows Service to fix #3937.

If `Event.open()`
([OpenEvent](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-openeventw))
is called before the `Event.new()`
([CreateEvent](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createeventw)),
`Event.open()` raises `Errno::ENOENT`.
This causes the service to be stopped while the supervisor and worker
process remains.
It causes #3937.
This PR fixes it by adding retry.

https://github.com/fluent/fluentd/blob/30c3ce00ff165b1b5d9f53fc0a027074bbcab0da/lib/fluent/winsvc.rb#L90

https://github.com/fluent/fluentd/blob/30c3ce00ff165b1b5d9f53fc0a027074bbcab0da/lib/fluent/supervisor.rb#L299

**Docs Changes**:
Not needed.

**Release Note**:
It would be good to have both of the following.

* Windows: Fixed an issue where stopping the service immediately after
startup could leave the processes.
* Windows: Fixed an issue where stopping service sometimes can not be
completed forever.

---------

Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
Co-authored-by: Kentaro Hayashi <kenhys@gmail.com>
Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
@kenhys
Copy link
Contributor Author

kenhys commented Jan 29, 2025

git switch -c backport-pr4782 --track origin/v1.16
git cherry-pick 569c3588b8fdad28406371a3c012f0b5f4c57b28

@daipom daipom added this to the v1.16.7 milestone Jan 29, 2025
@daipom daipom merged commit b973802 into v1.16 Jan 29, 2025
11 of 16 checks passed
@daipom daipom deleted the backport-pr4782 branch January 29, 2025 03:04
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.

2 participants