Maxwell-Guo commented on code in PR #2983:
URL: https://github.com/apache/cassandra/pull/2983#discussion_r1426625685
##########
src/java/org/apache/cassandra/service/StartupChecks.java:
##########
@@ -187,6 +191,70 @@ public void verify(StartupChecksOptions options) throws
StartupException
}
}
+ // https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1057843
+ public static final StartupCheck checkKernelBug1057843 = new StartupCheck()
+ {
+ private final Range<Semver> affectedKernels = Range.closedOpen(
+ new Semver("6.1.64", Semver.SemverType.LOOSE), new Semver("6.1.66",
Semver.SemverType.LOOSE));
+
+ private final Set<String> affectedFileSystemTypes = Set.of("ext4");
+
+ @Override
+ public void execute(StartupChecksOptions startupChecksOptions) throws
StartupException
+ {
+ try
+ {
+ if (startupChecksOptions.isDisabled(getStartupCheckType()))
+ return;
+
+ if (!FBUtilities.isLinux)
+ return;
+
+ Set<Path> directIOWritePaths = new HashSet<>();
+ if (DatabaseDescriptor.getCommitLogWriteDiskAccessMode() ==
Config.DiskAccessMode.direct)
+ directIOWritePaths.add(new
File(DatabaseDescriptor.getCommitLogLocation()).toPath());
+ // TODO: add data directories when direct IO is supported for
flushing and compaction
+
+ Set<Path> affectedPaths = new HashSet<>();
+ for (Path path : directIOWritePaths)
+ {
+ try
+ {
+ if
(affectedFileSystemTypes.contains(Files.getFileStore(path).type().toLowerCase()))
+ affectedPaths.add(path);
+ }
+ catch (IOException e)
+ {
+ throw new
StartupException(StartupException.ERR_WRONG_MACHINE_STATE, "Failed to determine
file system type for path " + path, e);
+ }
+ }
+
+ if (affectedPaths.isEmpty())
+ return;
+
+ Semver kernelVersion = FBUtilities.getKernelVersion();
+ if
(!affectedKernels.contains(kernelVersion.withClearedSuffixAndBuild()))
+ return;
+
+
+ throw new
StartupException(StartupException.ERR_WRONG_MACHINE_STATE,
+ String.format("Detected kernel
version %s with affected file system types %s and direct IO enabled for paths
%s. " +
+ "This combination is
known to cause data corruption. To start Cassandra in this environment, " +
+ "you have to disable
direct IO for the affected paths. If you are sure the verification provided " +
+ "a false positive
result, you can suppress it by setting '" +
IGNORE_KERNEL_BUG_1057843_CHECK.getKey() + "' system property to 'true'. " +
+ "Please see
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1057843 for more
information.",
+ kernelVersion,
affectedFileSystemTypes, affectedPaths));
+ }
+ catch (StartupException | RuntimeException ex)
+ {
+ if (IGNORE_KERNEL_BUG_1057843_CHECK.getBoolean())
Review Comment:
what about set this part of code before line 213 ?
That to say ,first time the user found the linux file system may cause risks
,and I think there is no need for the code to go here ,may just return at line
213.
`
if (startupChecksOptions.isDisabled(getStartupCheckType()))
return;
if (!FBUtilities.isLinux)
return;
boolean useDirectIo =
DatabaseDescriptor.getCommitLogWriteDiskAccessMode() ==
Config.DiskAccessMode.direct;
if (useDirectIo && IGNORE_KERNEL_BUG_1057843_CHECK.getBoolean())
{
logger.warn("Kernel bug 1057843 check failed with direct
IO enabled for commitlog - ignoring as '{}' system property is set: {}",
IGNORE_KERNEL_BUG_1057843_CHECK.getKey())
return;
}
`
?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]