Issue #16236 has been reported by cosmo0920 (Hiroshi Hatake).

----------------------------------------
Bug #16236: Cannot handle logrotate on Windows when one file is written from multi process/thread
https://bugs.ruby-lang.org/issues/16236

* Author: cosmo0920 (Hiroshi Hatake)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.6p354 (2019-04-01 revision 67394) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
### TL;DR

This issue occurred in Windows version of Fluentd.
It uses ServerEngine and its logger functionality delegates into Ruby logger library.
Fluentd's logrotate functionality is originated from Ruby logger library,
Then, I found that this library does not seems to support logrotate under multi process/thread condition on Windows.

### Issue Detail

When a log file which is written from the one process or thread, it works correctly:

```
require "logger"

logger = Logger.new('test.log', 5, 30*1024)

loop do
  logger.error "lost connection"
  logger.debug "got new connection"
end
```

But logger writing file collision circumstances, it cannot handle logrotate correctly:

```
require "logger"

logger = Logger.new('test.log', 5, 30*1024)
myOtherLogger = Logger.new('test.log', 5, 30*1024)

loop do
  logger.error "lost connection"
  logger.debug "got new connection"
end
```

```
...
log shifting failed. closed stream
log writing failed. closed stream
log shifting failed. closed stream
log writing failed. closed stream
log shifting failed. closed stream
log writing failed. closed stream
log shifting failed. closed stream
log writing failed. closed stream
log shifting failed. closed stream
log writing failed. closed stream
.... (after that many of these lines)
```

Fluentd launches spawn model (which has supervisor and several workers) on Windows.
Currently, Fluentd implementation uses one logfile from supervisor and worker(s).
So, it causes log shifting operation collision.

### Expected behavior

Logrorating operation works correctly under multi process/threading circumstances on Windows like as Linux environment.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>