[crac] RFR: Linux file system watcher support

joeylee duke at openjdk.org
Tue May 23 15:28:59 UTC 2023


On Tue, 16 May 2023 08:30:41 GMT, Radim Vansa <duke at openjdk.org> wrote:

>> inotify monitors changes on filesystem, this support automatic restore for LinuxFileWatcher.
>> 
>> FileWatcherAfterRestoreTest verifies watcher service works after restore.
>> FileWatcherTest verifies automatic closing inotiify fd
>> 
>> The watcher keys are still managed by user, so exception will be thrown if no watcher keys are leaked, as in FileWatcherWithOpenKeysTest
>
> I was hoping that a fastdebug build with assertions on would fail somewhere earlier but it is not the case. I would suspect that since this NULL dereference is happening when the thread already exits there's an earlier event that goes wrong.

Hi @rvansa , thanks for your review. I have updated FileWatcherAfterRestoreTest with a minimal case where the monitor key could be different after restore, and this test will manually  re-register alternative path.



When closing the notify service automatically simplifies the code, rather than just adding a close/reopen to the watch key management.

Where this patch could help simplifies code:
1. When users are manually managing all keys, this patch could only save them from  a `close()` and `open()` call before and  after checkpoint.
2. But some cases close and reopen a watch service could be very troublesome, like this case:
Notice the `watchservice` could be final for some 3rd party libraries, in that case we can not reopen and assign a new value for watch service. This patch allows user to focus only on keys, which might change after restore.


import jdk.crac.Core;

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.WatchService;

public class Case {
    private final WatchService watcher;

    Case() {
        watcher = createWatcher();
    }

    private static WatchService createWatcher() {
        try {
            return FileSystems.getDefault().newWatchService();
        } catch (IOException e) {
            return null;
        }
    }
}

-------------

PR Comment: https://git.openjdk.org/crac/pull/72#issuecomment-1559112302


More information about the crac-dev mailing list