Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9608 trunk #236

Closed
wants to merge 13 commits into from
Closed

9608 trunk #236

wants to merge 13 commits into from

Conversation

jasobrown
Copy link
Contributor

No description provided.

build.xml Outdated
<property name="ecj.version" value="4.6.1"/>
<property name="ohc.version" value="0.5.1"/>

<!--
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's move this java version section above the dependencies section

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

build.xml Outdated
@@ -462,7 +501,9 @@
<dependency groupId="com.googlecode.concurrent-trees" artifactId="concurrent-trees" version="2.4.0" />
<dependency groupId="com.github.ben-manes.caffeine" artifactId="caffeine" version="2.3.5" />
<dependency groupId="org.jctools" artifactId="jctools-core" version="1.2.1"/>
<dependency groupId="org.ow2.asm" artifactId="asm" version="5.0.4" />
<dependency groupId="org.ow2.asm" artifactId="asm" version="6.2" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe introduce a property with the version for org.ow2.asm, like what you've done for ecj.version and others?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

build.xml Outdated
@@ -703,6 +744,13 @@
</patternset>
<mapper type="flatten"/>
</unzip>

<delete>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to delete the netty and asm jars here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise an older asm (and previously an older netty version as well) landed in build/lib/jars via a transitive dependency.

# Java 11 (and newer) GC logging options:
# See description of https://bugs.openjdk.java.net/browse/JDK-8046148 for details about the syntax
# The following is the equivalent to -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10M
#-Xlog:gc=info,heap*=trace,age*=debug,safepoint=info,promotion*=trace:file=/var/log/cassandra/gc.log:time,uptime,pid,tid,level:filecount=10,filesize=10240
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: filesize=10240 is the file size in bytes. change to 10485760 if you actually want 10MB files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

if ! grep -q "^-[X]log:gc" $CASSANDRA_CONF/jvm.options ; then # [X] to prevent ccm from replacing this line
# only add -Xlog:gc if it's not mentioned in jvm.options file
mkdir -p ${CASSANDRA_HOME}/logs
JVM_OPTS="$JVM_OPTS -Xlog:gc=info,heap*=trace,age*=debug,safepoint=info,promotion*=trace:file=${CASSANDRA_HOME}/logs/gc.log:time,uptime,pid,tid,level:filecount=10,filesize=10240"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: filesize=10240 is the file size in bytes. change to 10485760 if you actually want 10MB files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

}
isCleanerAvailable = canClean;
}

public static boolean isDirectBuffer(ByteBuffer buf)
{
return clsDirectBuffer.isInstance(buf);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just call ByteBuffer.isDirect() instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@@ -208,7 +225,5 @@ public void checkPackageAccess(String pkg)
RuntimePermission perm = new RuntimePermission("accessClassInPackage." + pkg);
throw new AccessControlException("access denied: " + perm, perm);
}

super.checkPackageAccess(pkg);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we need to call super.checkPackageAccess() anymore?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise JavaScript based UDFs stop working due to JPMS, that would raise errors like
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.jdk.internal.org.objectweb.asm")

@@ -78,7 +77,14 @@
static
{
FILE_DESCRIPTOR_FD_FIELD = FBUtilities.getProtectedField(FileDescriptor.class, "fd");
FILE_CHANNEL_FD_FIELD = FBUtilities.getProtectedField(FileChannelImpl.class, "fd");
try
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this in a try/catch block now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the Class.forName declaring the checked exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, ok missed that one

{
// For Java 11 try to see whether the class actually exists and read the
// class file data via the class' module. (This is necessary at least
// for 9-ea build 123)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still true as of java11 (ea 19)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm - seems that was actually a bug in Java and it's been fixed.

private static Class clsDirectBuffer;
private static MethodHandle mhDirectBufferCleaner;
private static MethodHandle mhCleanerClean;
private static MethodHandle mhDirectBufferAddress;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhDirectBufferAddress isn't used anywhere. can we eliminate it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

canClean = true;
}
catch (Throwable t)
{
logger.info("Cannot initialize un-mmaper. Compacted data files will not be removed promptly.", t);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original log message here was rather awful. I'm not sure sure what actions an operator could take after seeing this, and Compacted data files will not be removed promptly is sufficiently vague.

Maybe we could say something like: `Cannot initialize optimized memory deallocator. Some data, both in-memory and on-disk, may live longer due to garbage collection."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

cleanerClean(buf, false);
}

public static void cleanerClean(ByteBuffer buf, boolean cleanAttachment)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any code path where cleanAttachment can be true. Am I missing something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yikes - that was wrong. good catch!

public static File createTempFile(String prefix, String suffix, File directory)
{
try
{
return File.createTempFile(prefix, suffix, directory);
// Do not use java.io.File.createTempFile(), because some tests rely on the
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the tests that require monotonicity in the file version numbers also require the versions to be related to wall-clock time? If not, and the monotonicity / uniqueness guarantees are sufficient, you can simplify the while loop below to get just the next value by tempFileNum.getAndIncrement()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I think that's reasonable.

patch by Robert Stupp; reviewed by Jason Brown and Eduard Tudenhöfner for CASSANDRA-9608
use chronicle-core snapshot build to run on Java 11
the snapshot-build of chronicle-core solves the "junit.framework.AssertionFailedError: java.lang.NoSuchFieldException: reservedMemory" issue at net.openhft.chronicle.core.Jvm.<clinit>(Jvm.java:87)
see OpenHFT/Chronicle-Core#68
###########################################################################
# jvm11-clients.options #
# #
# See jvm-clients.options. This file is specific for Java 8 and newer. #
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this should say for Java 11 and newer

build.xml Outdated
<property name="source.version" value="1.8"/>
<property name="target.version" value="1.8"/>
<!--
We specific '8' instead of '1.8' in source.version to indicate that that this build requires Java 11 _and_ Java 8.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

petty nit: We specify

build.xml Outdated
@@ -1665,7 +1763,7 @@
<echo message="Mem size : ${mem.size}"/>
</target>

<target name="test" depends="build-test,get-cores,get-mem,stress-build" description="Parallel Test Runner">
<target name="test" depends="build-test" description="Parallel Test Runner">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this not depend on get-cores,get-mem anymore? Otherwise, those targets are unused in the build.xml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, re-added

@@ -591,14 +592,17 @@ private NameEnvironmentAnswer findType(String className)

String resourceName = className.replace('.', '/') + ".class";

try (InputStream is = UDFunction.udfClassLoader.getResourceAsStream(resourceName))
try
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we need a nested try block here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah - I've changed that part twice. But yea, one try-catch is absolutely sufficient.

JVMStabilityInspector.inspectThrowable(t);
logger.info("Cannot initialize un-mmaper. (Are you using a non-Oracle JVM?) Compacted data files will not be removed promptly. Consider using an Oracle JVM or using standard disk access mode");
throw new RuntimeException(t);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this is a change in semantics (throwing a RuntimeException). Previously, we would just complain if we couldn't get to the buffer cleaner, now we're basically terminating the process. Is that intended? If it is, at minimum the log statement a few lines up should be FATAL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much every JVM should have a Cleaner nowadays. Not having would break a lot of assumṕtions IMO.
Changed the log message to ERROR.


// We have a positive long here, which is safe to use for example
// for CommitLogTest.
String timePart = Long.toString(num);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename this variable, or maybe just move Long.toString(num) into the next line.

DirectBuffer db = (DirectBuffer) buffer;
if (db.cleaner() != null)
db.cleaner().clean();
if (buffer.isDirect())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is redundant as you've already performed the !buffer.isDirect() earlier in this method (and bailed if it isn't)

db.cleaner().clean();
if (buffer.isDirect())
{
Object cleaner = mhDirectBufferCleaner.bindTo(buffer).invoke();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some comments here? It's not clear what's going on, but more importantly, why there's two code paths.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops. There shouldn't be any else.

@@ -78,7 +77,14 @@
static
{
FILE_DESCRIPTOR_FD_FIELD = FBUtilities.getProtectedField(FileDescriptor.class, "fd");
FILE_CHANNEL_FD_FIELD = FBUtilities.getProtectedField(FileChannelImpl.class, "fd");
try
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, ok missed that one

@jasobrown
Copy link
Contributor Author

Is javaexec.in.sh needed anymore? Looks like all the java checks are in cassandra.in.sh now. The file is not referenced by dtests or ccm, either.

@snazy
Copy link
Member

snazy commented Jul 26, 2018

No, it's no longer needed. I removed it.

@jasobrown jasobrown closed this Jul 26, 2018
@jasobrown
Copy link
Contributor Author

Committed as sha 6ba2fb9395226491872b41312d978a169f36fcdb

@snazy snazy deleted the 9608-trunk branch May 4, 2020 09:39
blambov pushed a commit to blambov/cassandra that referenced this pull request Oct 1, 2021
jacek-lewandowski added a commit to jacek-lewandowski/cassandra that referenced this pull request Mar 7, 2022
blambov pushed a commit to blambov/cassandra that referenced this pull request Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants