You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Benedict Elliott Smith (Jira)" <ji...@apache.org> on 2022/10/13 07:35:00 UTC

[jira] [Comment Edited] (CASSANDRA-17850) Find a way to get FileDescriptor.fd and sun.nio.ch.FileChannelImpl.fd without opening internals

    [ https://issues.apache.org/jira/browse/CASSANDRA-17850?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17616836#comment-17616836 ] 

Benedict Elliott Smith edited comment on CASSANDRA-17850 at 10/13/22 7:34 AM:
------------------------------------------------------------------------------

You can get them directly from {{{}FileInputStream{}}}, {{FileOutputStream}} and {{{}RandomAccessFile{}}}. It is a shame there is no equivalent method for {{{}FileChannel{}}}. There is also the option of redefining {{FileChannelImpl}} on load to introduce a public method to retrieve the {{FileDescriptor}} and to simply define our static accessor method (also using ASM) to access this public method.

But, it might be that we don't really need the file descriptor and can simply use the {{force}} method on {{{}FileChannel{}}}. We can even do this for syncing directories, seemingly. Relevant JDK bug thread where this feature was temporarily broken, tracking a replacement mechanism (that does not yet exist): [https://bugs.openjdk.org/browse/JDK-8080235]

 


was (Author: benedict):
You can get them from FileInputStream, FileOutputStream and RandomAccessFile.

But, it might be that we don't really need the file descriptor and can simply use the {{force}} method on {{{}FileChannel{}}}. We can even do this for syncing directories, seemingly. Relevant JDK bug thread where this feature was temporarily broken, tracking a replacement mechanism (that does not yet exist): [https://bugs.openjdk.org/browse/JDK-8080235]

 

> Find a way to get FileDescriptor.fd and sun.nio.ch.FileChannelImpl.fd without opening internals
> -----------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-17850
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-17850
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Build
>            Reporter: Ekaterina Dimitrova
>            Priority: Normal
>             Fix For: 4.x
>
>
> With Java 17 if we do not add below to the jvm17 server options:
> {code:java}
> --add-opens java.base/sun.nio.ch=ALL-UNNAMED
> --add-opens java.base/java.io=ALL-UNNAMED{code}
> we get on startup (considering I comment out the scripted UDFs and apply a few changes to the startup scripts):
> {code:java}
> ERROR [ScheduledTasks:1] 2022-08-23 12:29:25,652 JVMStabilityInspector.java:68 - Exception in thread Thread[ScheduledTasks:1,5,ScheduledTasks]
> java.lang.AssertionError: java.lang.reflect.InaccessibleObjectException: Unable to make field private int java.io.FileDescriptor.fd accessible: module java.base does not "opens java.io" to unnamed module @11d8ae8b
> at org.apache.cassandra.utils.FBUtilities.getProtectedField(FBUtilities.java:801)
> at org.apache.cassandra.utils.NativeLibrary.<clinit>(NativeLibrary.java:84)
> at org.apache.cassandra.utils.TimeUUID$Generator.hash(TimeUUID.java:496)
> at org.apache.cassandra.utils.TimeUUID$Generator.makeNode(TimeUUID.java:474)
> at org.apache.cassandra.utils.TimeUUID$Generator.makeClockSeqAndNode(TimeUUID.java:452)
> at org.apache.cassandra.utils.TimeUUID$Generator.<clinit>(TimeUUID.java:368)
> at org.apache.cassandra.streaming.StreamingState.<clinit>(StreamingState.java:50)
> at org.apache.cassandra.streaming.StreamManager.<init>(StreamManager.java:257)
> at org.apache.cassandra.streaming.StreamManager.<clinit>(StreamManager.java:58)
> at org.apache.cassandra.service.StorageService.<init>(StorageService.java:376)
> at org.apache.cassandra.service.StorageService.<clinit>(StorageService.java:226)
> at org.apache.cassandra.locator.DynamicEndpointSnitch.updateScores(DynamicEndpointSnitch.java:274)
> at org.apache.cassandra.locator.DynamicEndpointSnitch$1.run(DynamicEndpointSnitch.java:91)
> at org.apache.cassandra.concurrent.ExecutionFailure$1.run(ExecutionFailure.java:133)
> at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
> at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
> at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
> at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> at java.base/java.lang.Thread.run(Thread.java:833)
> Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private int java.io.FileDescriptor.fd accessible: module java.base does not "opens java.io" to unnamed module @11d8ae8b
> at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
> at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
> at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
> at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
> at org.apache.cassandra.utils.FBUtilities.getProtectedField(FBUtilities.java:796)
> ... 20 common frames omitted
> {code}
> and 
> {code:java}
> ERROR [ScheduledTasks:1] 2022-08-23 12:31:18,443 JVMStabilityInspector.java:68 - Exception in thread Thread[ScheduledTasks:1,5,ScheduledTasks]
> java.lang.AssertionError: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.io.FileDescriptor sun.nio.ch.FileChannelImpl.fd accessible: module java.base does not "opens sun.nio.ch" to unnamed module @4c012563
> at org.apache.cassandra.utils.FBUtilities.getProtectedField(FBUtilities.java:801)
> at org.apache.cassandra.utils.NativeLibrary.<clinit>(NativeLibrary.java:87)
> at org.apache.cassandra.utils.TimeUUID$Generator.hash(TimeUUID.java:496)
> at org.apache.cassandra.utils.TimeUUID$Generator.makeNode(TimeUUID.java:474)
> at org.apache.cassandra.utils.TimeUUID$Generator.makeClockSeqAndNode(TimeUUID.java:452)
> at org.apache.cassandra.utils.TimeUUID$Generator.<clinit>(TimeUUID.java:368)
> at org.apache.cassandra.streaming.StreamingState.<clinit>(StreamingState.java:50)
> at org.apache.cassandra.streaming.StreamManager.<init>(StreamManager.java:257)
> at org.apache.cassandra.streaming.StreamManager.<clinit>(StreamManager.java:58)
> at org.apache.cassandra.service.StorageService.<init>(StorageService.java:376)
> at org.apache.cassandra.service.StorageService.<clinit>(StorageService.java:226)
> at org.apache.cassandra.locator.DynamicEndpointSnitch.updateScores(DynamicEndpointSnitch.java:274)
> at org.apache.cassandra.locator.DynamicEndpointSnitch$1.run(DynamicEndpointSnitch.java:91)
> at org.apache.cassandra.concurrent.ExecutionFailure$1.run(ExecutionFailure.java:133)
> at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
> at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
> at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
> at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> at java.base/java.lang.Thread.run(Thread.java:833)
> Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.io.FileDescriptor sun.nio.ch.FileChannelImpl.fd accessible: module java.base does not "opens sun.nio.ch" to unnamed module @4c012563
> at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
> at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
> at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
> at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
> at org.apache.cassandra.utils.FBUtilities.getProtectedField(FBUtilities.java:796)
> ... 20 common frames omitted
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org