Skip to content

CASSANDRA-14380 Tolerate unsupported fsync only for kernel-verified directory descriptors - #5148

Open
cheeeee wants to merge 1 commit into
apache:trunkfrom
cheeeee:CASSANDRA-14380-trunk
Open

CASSANDRA-14380 Tolerate unsupported fsync only for kernel-verified directory descriptors#5148
cheeeee wants to merge 1 commit into
apache:trunkfrom
cheeeee:CASSANDRA-14380-trunk

Conversation

@cheeeee

@cheeeee cheeeee commented Sep 10, 2026

Copy link
Copy Markdown

CASSANDRA-14380: on a filesystem whose directories do not support fsync (the report is a Rook/Ceph
volume) directory fsync fails with EINVAL, NativeLibrary.trySync raises FSWriteError, and the disk
failure policy stops the node. On Linux, fsync returns EINVAL when the file's operations have no
fsync at all; writeback errors are reported as EIO/ENOSPC/EDQUOT, never as EINVAL or ENOTSUP.

Changes:

  • NativeLibrary.trySyncDirectory(fd, path) / trySyncDirectory(path): fsync of a directory descriptor
    that fails with EINVAL, ENOTSUP or EOPNOTSUPP is logged once per directory per 10 minutes and
    otherwise ignored. Every other errno, and every error on a non-directory descriptor (trySync(fd) is
    unchanged), still raises FSWriteError.
  • The errno constants are resolved through jnr-constants for the running platform; a constant the
    platform table does not define is never matched, so no value from another platform is used. On AIX
    the jnr table has no ENOTSUP, so only EINVAL and EOPNOTSUPP are tolerated there.
  • tryOpenDirectory opens with O_RDONLY | O_DIRECTORY so the kernel itself guarantees the descriptor is
    a directory (ENOTDIR otherwise). O_DIRECTORY is resolved through jnr and then verified once at class
    initialization: opening java.io.tmpdir with it must succeed and opening a regular file with it must
    fail with ENOTDIR. If the verification fails or the constant is unavailable (Windows), O_DIRECTORY is
    treated as 0 and the tolerance is disabled entirely, i.e. the behaviour stays strict.
  • Callers pass the directory path: LogReplica, HintsCatalog (which also now closes the descriptor
    even when the sync throws, via Throwables.maybeFail) and Accord ReplayMarkers. SyncUtil.trySyncDir
    forwards to the new method.

Testing:

  • NativeLibraryTest (9): EINVAL/ENOTSUP/EOPNOTSUPP are tolerated for a directory descriptor and not
    for a plain descriptor; EIO/EBADF still fail for both; the warning names the directory and two
    directories are both reported within one window; tryOpenDirectory on a regular file returns -1; the
    descriptor is closed when fsync fails and the fsync failure is kept as the primary exception when
    close also fails; plus the existing skip-cache and pid tests.
  • HintsCatalogTest (4).
  • Kernel-level check, Linux 6.19: fsync on a directory descriptor returns 0 on ext4, tmpfs and hostfs
    and EINVAL on /proc (a directory whose operations have no fsync); open(O_RDONLY | O_DIRECTORY) on a
    regular file returns ENOTDIR on all four.
  • Not verified on other architectures or operating systems: the O_DIRECTORY verification exists
    precisely because jnr's per-architecture flag tables do not cover every platform, and it was only
    exercised on x86_64 Linux.

CASSANDRA-14380

@cheeeee
cheeeee force-pushed the CASSANDRA-14380-trunk branch from 2c79ceb to 89d1dcb Compare September 11, 2026 01:06
Resolve supported capability errno values for the host platform and keep
unknown values and ordinary descriptor failures strict. Route directory
sync callers explicitly and preserve primary sync failures when descriptor
cleanup also fails.

CASSANDRA-14380

Generated-by: Claude (Anthropic)
@cheeeee
cheeeee force-pushed the CASSANDRA-14380-trunk branch from 89d1dcb to 2973a43 Compare September 11, 2026 22:51
@cheeeee cheeeee changed the title CASSANDRA-14380: Tolerate EINVAL and ENOTSUP on directory fsync CASSANDRA-14380 Tolerate unsupported fsync only for kernel-verified directory descriptors Sep 11, 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.

1 participant