jbonofre opened a new pull request, #3067:
URL: https://github.com/apache/karaf/pull/3067
## Problem
`LogTest` still fails now and then on the ubuntu CI job after #3006, always
with the same error on `log:set`:
```
java.lang.IllegalStateException: Unrecognized configuration
at
org.apache.karaf.log.core.internal.LogServiceImpl.getDelegate(LogServiceImpl.java:71)
at
org.apache.karaf.log.core.internal.LogServiceImpl.setLevel(LogServiceImpl.java:114)
```
Once it happens, every remaining test of the class fails the same way,
retries included. Recent occurrences: the `main` push of 00b4fd6444, #3060, and
the `pr-secmgr-removal` and Hibernate dependabot PRs.
## Root cause
This is a race in Felix fileinstall 3.7.4 (the latest release), not in the
log commands:
1. Every `log:set` updates the `org.ops4j.pax.logging` configuration.
fileinstall's `ConfigInstaller` writes it back to
`etc/org.ops4j.pax.logging.cfg` in place, with `new FileOutputStream(file)`:
the file is empty until the writer is closed.
2. The fileinstall scanner (polling `etc/` every second) is meant to load a
file only when its checksum is the same on two polls. But after checking the
files it got change events for, `scan()` checks all known files again in the
same scan (the "double check" for files on mounted file systems). That second
pass compares against the checksum stored a few microseconds earlier, so a
single poll is enough to report the file.
3. If that poll lands while the file is truncated,
`ConfigInstaller.setConfig()` reads an empty file and updates the configuration
with no properties, so `LogServiceImpl.getDelegate()` throws "Unrecognized
configuration".
4. The write-back of that empty configuration then removes every key it
doesn't contain from the file, so the configuration never recovers.
Step 2 was reproduced with the fileinstall 3.7.4 `Scanner`: one
`scan(false)` while the file is truncated (writer still open) reports it as
changed, with the file at 0 bytes.
This most likely only shows up on Linux because there the change events are
delivered immediately, so the file is always in the scanner's changed set right
after a write. On macOS, the JDK watch service only polls every few seconds.
## Fix
`LogTest` checks the log commands against ConfigAdmin, never against the
file, so this disables fileinstall's config write-back
(`felix.fileinstall.enableConfigSave=false`) in the `LogTest` container.
Without the write-back there is no truncated file for the scanner to pick up.
The retries added in #3006 are left in place. They're no longer needed, and
can be removed separately.
The underlying fileinstall race can affect any configuration changed through
ConfigAdmin (`config:edit`, `log:set`, the web console) and is to be fixed in
Felix fileinstall, by writing the file to a temporary file and moving it into
place.
## Testing
`mvn -pl itests/test test -Dtest=LogTest` passes locally (JDK 17, macOS). As
the race is rare and mostly hit on Linux, the actual confirmation is CI over
time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]