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

Stefan Miklosovic edited comment on CASSANDRA-18264 at 2/15/23 11:25 PM:
-------------------------------------------------------------------------

[~brandon.williams] I see you are among watchers.

There is this (1) dir where triggers are loaded from by default. However,  
there is this as well (2) which says that it is by default "conf/triggers" and 
that is not true. If -Dcassandra.triggers_dir is not set, it will default to 
"triggers". So people reading the documentation will place it to 
"conf/triggers" and it will not work.

We have two options, we either change the documentation or we change the 
default in FBUtilities to "conf/triggers". I am on the edge what we should 
choose.

The example puts the jar to "conf/triggers" and in order to try it from IDEA, I 
had to add -Dcassandra.triggers_dir to run configuration (and tweak idea files) 
to point it to conf/triggers.

Documentation here (3) says it may be put to `lib/triggers`. In that case, 
`triggers` in FBUtilities probably makes sense but `conf/triggers` in 
jvm-server.options still does not.

(1) 
https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java#L112
(2) https://github.com/apache/cassandra/blob/trunk/conf/jvm-server.options#L65
(3) https://cassandra.apache.org/doc/latest/cassandra/cql/triggers.html


was (Author: smiklosovic):
[~brandon.williams] I see you are among watchers.

There is this (1) dir where triggers are loaded from by default. However,  
there is this as well (2) which says that it is by default "conf/triggers" and 
that is not true. If -Dcassandra.triggers_dir is not set, it will default to 
"triggers". So people reading the documentation will place it to 
"conf/triggers" and it will not work.

We have two options, we either change the documentation or we change the 
default in FBUtilities to "conf/triggers". I am on the edge what we should 
choose.

The example puts the jar to "conf/triggers".

Documentation here (3) says it may be put to `lib/triggers`. In that case, 
`triggers` in FBUtilities probably makes sense but `conf/triggers` in 
jvm-server.options still does not.

(1) 
https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java#L112
(2) https://github.com/apache/cassandra/blob/trunk/conf/jvm-server.options#L65
(3) https://cassandra.apache.org/doc/latest/cassandra/cql/triggers.html

> CustomClassLoader does not load jars rendering triggers from JARs broken
> ------------------------------------------------------------------------
>
>                 Key: CASSANDRA-18264
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18264
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Legacy/Core
>            Reporter: Stefan Miklosovic
>            Assignee: Stefan Miklosovic
>            Priority: Normal
>             Fix For: 4.1.x, 4.x
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> A user had to downgrade to 4.0.7 from 4.1.0 because they hit a problem with 
> CustomClassLoader for triggers. 
> User says that in Apache Cassandra 4.1.0 the trigger mechanism does not work, 
> not their trigger, but the possibility of loading any trigger in Cassandra.
> In the Cassandra 4.1.0 version of CustomClassLoader 
> (https://github.com/apache/cassandra/blob/cassandra-4.1/src/java/org/apache/cassandra/triggers/CustomClassLoader.java)
>  the code is changed in such a way that when copying the JAR Cassandra uses 
> java.nio.file.Files, while earlier versions (cassandra 4.0.X or 3.X) used 
> Guava com.google.common.io.Files to copy the JAR file.
> The difference between one and the other is that Guava by default overwrites 
> the file if it already exists and user has permissions to do so, and in Java 
> by default it does not overwrite.
> Copying is done here (1) from inputJar to out. However, the problem is that 
> we are getting temporary file from here (2) and the implementation loops 
> unless it succeeds to create an empty file. (3) - But that fails to copy the 
> file to out because copying does not work when the target file already exists.
> (1) 
> https://github.com/apache/cassandra/blob/cassandra-4.1/src/java/org/apache/cassandra/triggers/CustomClassLoader.java#L86
> (2) 
> https://github.com/apache/cassandra/blob/cassandra-4.1/src/java/org/apache/cassandra/triggers/CustomClassLoader.java#L81
> (3) 
> https://github.com/apache/cassandra/blob/cassandra-4.1/src/java/org/apache/cassandra/io/util/FileUtils.java#L152



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

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

Reply via email to