You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Sascha Vogt (Jira)" <ji...@apache.org> on 2022/04/08 08:18:00 UTC

[jira] [Commented] (FELIX-6515) File install race condition leads to empty config files

    [ https://issues.apache.org/jira/browse/FELIX-6515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17519401#comment-17519401 ] 

Sascha Vogt commented on FELIX-6515:
------------------------------------

attached our hacky solution which uses a temp file and remove including retries in case the file (on Windows) is locked... 

> File install race condition leads to empty config files
> -------------------------------------------------------
>
>                 Key: FELIX-6515
>                 URL: https://issues.apache.org/jira/browse/FELIX-6515
>             Project: Felix
>          Issue Type: Bug
>          Components: File Install
>    Affects Versions: fileinstall-3.7.4
>            Reporter: Sascha Vogt
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>             Fix For: fileinstall-3.7.5
>
>         Attachments: felix-fileinstall-empty-config.patch
>
>
> We discovered an ugly race condition within Felix Fileinstall together with the Config Admin. 
> ConfigInstaller opens the existing config file in a new writer, basically emptying out the file on disk (https://github.com/apache/felix-dev/blob/master/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java#L285) - If at the same time file install reads the file during it's regular poll interval, it will read an empty file. That leads to a new config admin "update" event where the config is empty. Now the first update finishes writing the config to disk and then the second event gets processed in the ConfigInstaller, which then detects all keys need to be removed.
> This then leads to configs which are empty besides the first comment header in the existing file (because only keys afterwards are emptied). 
> We have a patch ready which we are currently testing internally which writes to a temp file and do a rename afterwards + skipping to write fully empty configs (that part might not make sense in the official version, but for us, we're never going to "empty" out config files through code, instead we would delete the whole file...). That seems to solve the issue for us, yet still a bit hacky.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)