Skip to content

Fix Direct IO and drop cache silent failures on Ubuntu Linux#145

Draft
Copilot wants to merge 2 commits intodevfrom
copilot/investigate-direct-io-issue
Draft

Fix Direct IO and drop cache silent failures on Ubuntu Linux#145
Copilot wants to merge 2 commits intodevfrom
copilot/investigate-direct-io-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

Direct IO with the modern engine silently failed in jpackage DEB/RPM builds, and the sync command could be abandoned prematurely before drop_caches ran — both producing no visible error output.

Root causes & fixes

  • jdk.unsupported missing from jpackage module list (build.xml)
    com.sun.nio.file.ExtendedOpenOption (used for O_DIRECT) is exported from jdk.unsupported, which was absent from --add-modules in both create-fat-deb and create-fat-rpm targets. The bundled JRE threw NoClassDefFoundError at runtime — silently, because BenchmarkWorker.done() never called get().

    <!-- before -->
    java.base,java.desktop,java.logging,...,java.naming
    <!-- after -->
    java.base,java.desktop,java.logging,...,java.naming,jdk.unsupported
  • InterruptedException swallowed in sync/drop_caches commands (UtilOs.java)
    A lingering interrupt on the SwingWorker thread (e.g. from a prior cancellation) caused process.waitFor() to throw immediately, abandoning sync before it completed. flushDataToDriveLinux() and dropWriteCacheLinux() now retry waitFor() in a loop on interruption and restore the interrupted status afterward.

  • Null FileChannel on Direct IO IOException fallback (Sample.java)
    If FileChannel.open() with ExtendedOpenOption.DIRECT threw IOException (e.g. filesystem doesn't support O_DIRECT), initialFc was left null and the subsequent fc.read()/fc.write() call threw NullPointerException — not caught by the IOException handler. Both measureWrite() and measureRead() now fall back to buffered IO with an explicit error message, matching the existing UnsupportedOperationException path.

  • Silent exception swallowing in BenchmarkWorker (BenchmarkWorker.java)
    done() never called get(), so any exception from doInBackground() was silently discarded. Now logs and surfaces the error message to the user.

Original prompt

This section details on the original issue you should resolve

<issue_title>ubuntu: direct io / drop cache sudo command does not work</issue_title>
<issue_description>testing with @mikewong79 discovered that

running as root should run drop cache and clear the disk cache but this did not work:

Image

it is suspected the drop cache also does not work

Image

</issue_description>

<agent_instructions>help investigate and resolve why direct io w modern engine does not work on ubuntu linux. there is no output when it fails.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@jamesmarkchan mike testing on a usb drive live image: Image Image

mikes usb hw:

https://www.amazon.com/dp/B01BGTG2A0?ref=ppx_pop_mob_ap_share</comment_new>
<comment_new>@jamesmarkchan
running directIO in NetBeans IDS appears to work in ubuntu... it's just the jpackage deb installer that does not work.

Image</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: jamesmarkchan <6020424+jamesmarkchan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix direct IO and drop cache command on Ubuntu Fix Direct IO and drop cache silent failures on Ubuntu Linux Mar 2, 2026
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.

ubuntu: direct io / drop cache sudo command does not work

2 participants