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

[fix] disable global restXQ trigger #4699

Closed
wants to merge 1 commit into from
Closed

Conversation

line-o
Copy link
Member

@line-o line-o commented Jan 24, 2023

Description:

This PR disables the restXQ trigger in collection.xconf.init. This is a breaking change as applications relying on this trigger to
be activated globally will have to add this trigger to their application's collection.xconf.

In my testing I was able to add two separate applications with both having the restXQ-trigger activated in their own
collection.xconf (both were based on https://gist.github.com/joewiz/28dd9b8454d14b4164a0). Modifying the code
showed up immediately when the exported routes were called with /exist/restxq/{route}.

Reference:

This trigger has led to several severe problems in the past with heap-memory exceptions when installing XAR-packages and
hanging databases. There is also an unsolved issue with modules with circular dependencies.

Type of tests:

In order to replicate my test you can check out this PR, build it and then create one or more test-applications using the template below.

xquery version "3.1";

module namespace my-app = "http://my/app";

(: 
    Save this file into eXist anywhere (e.g., /db/restxq-template.xqm or 
    /db/apps/my-app/modules/restxq-template.xqm).
    
    Note that the collection configuration file where you store the module must invoke
    the restXQ trigger.

    Add a collection.xconf next to your script (or in any parent collection).
    It has to have the following trigger configuration (along with any other configurations).

        <collection xmlns="http://exist-db.org/collection-config/1.0">
            <triggers>
                <trigger class="org.exist.extensions.exquery.restxq.impl.RestXqTrigger"/>
            </triggers>
        </collection>
    
    run the handler with GET http://localhost:8080/exist/restxq/test
:)

declare namespace rest = "http://exquery.org/ns/restxq";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare
    %rest:GET
    %rest:path("/test")
    %output:media-type("text/html")
    %output:method("html5")
function my-app:hello() {
    let $title := 'Hello world!'
    return
        <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
                <title>{$title}</title>
            </head>
            <body>
                <h1>{$title}</h1>
            </body>
        </html>
};

@line-o line-o added the needs documentation Signals issues or PRs that will require an update to the documentation repo label Jan 24, 2023
@line-o line-o added this to the eXist-7.0.0 milestone Jan 24, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jan 24, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@adamretter
Copy link
Member

As I previously stated to you @line-o in the public eXist-db Slack, I will not accept this change

@line-o
Copy link
Member Author

line-o commented Jan 24, 2023

I know you wrote you were against it. As I was able to confirm in my testing, restxq is still an option for application developers as long as they set the trigger for the collections that contain actual handlers. So, I hope that I can convince users to just add it to where they need it. With the positive side effect for everyone that all other collections are no longer affected by the problems it introduces by being active everywhere.

@line-o
Copy link
Member Author

line-o commented Jan 24, 2023

Here you have the chance to argue why this is still needed or what I have not thought about. Just not accepting it is a little shallow of an argument.

@adamretter
Copy link
Member

adamretter commented Jan 24, 2023

Would you like me to copy and paste my points from Slack?

@line-o
Copy link
Member Author

line-o commented Jan 24, 2023

Would you like me to copy and paste my points from Slack?

Yes, please do so.

@line-o line-o requested a review from a team January 24, 2023 11:32
@reinhapa
Copy link
Member

As I previously stated to you @line-o in the public eXist-db Slack, I will not accept this change

Hi @adamretter,
I tried to find the discussion about this but was not able to find it anymore. Could you explain what the problem is in your opinion as I do not really seem understand the actual problem with this change.

@dizzzz
Copy link
Member

dizzzz commented Feb 6, 2023

@adamretter in exist index configuration for a collection is taken from the collection.xconf for that collection, or when missing the one from the most close by parent collection.xconf .
How does that work for triggers?

@duncdrum
Copy link
Contributor

duncdrum commented Feb 9, 2023

@line-o there is a test for docker using restxq. This will need to modified to either activate it by using a custom conf.xml for that temporary container; or disabled.

@line-o
Copy link
Member Author

line-o commented Feb 9, 2023

@duncdrum Yes I saw that. Maybe it helps to put in the extra effort to show that everything is still running fine afterwards and what needs to be adapted.

@windauer
Copy link
Member

windauer commented Feb 9, 2023

@adamretter in Slack you wrote that the people who are not using restxq should simply disable it. Problem with this approach is imho that endusers will not know whats the cause of their issues and that they should search for "disabling restxq". They will notice heavy RAM usage only due to installing a XAR (and eXist-db not freeing the RAM afterwards, even when you trigger a GC via Monex). Or that the installation of frus takes 40min with a default eXist-db while it would take only 20min on the same machine with restxq disabled. In worst case they even step away from eXist-db without knowing that their issue could have simply been solved by disabling the restxq trigger.

I would be all in for adding a "enable restxq" trigger to the app generator @duncdrum is maintaining and to add the information how and where to enable restxq prominent in the documentation but to disable it by default.

@StephanMa
Copy link
Contributor

My two cents from an eXist user…
In almost every installation I am using restxq. Disable it from the beginning, is maybe no dealbreaker, but some extra step.

The argument of stepping away from exist… well I am using eXist for 8 years… Every time I have to work with it, I discover more and more bugs/mysterious problems/what so ever… we were used to problems…

@line-o
Copy link
Member Author

line-o commented Feb 27, 2023

@StephanMa are you using restxq - annotating functions to route http traffic - or the REST-like API of exist?
The easiest way to distinguish them is by the URLs you are calling

  • [/exist]/restxq/... -> restxq
  • [/exist]/rest/... -> REST-like API

This is about restxq and does not disable the REST-like API of exist.

@StephanMa
Copy link
Contributor

StephanMa commented Feb 27, 2023

-> [/exist]/restxq/... -> restxq!

@duncdrum
Copy link
Contributor

duncdrum commented Apr 7, 2023

See #4855 (comment)

@adamretter
Copy link
Member

#4855 is unrelated to this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs documentation Signals issues or PRs that will require an update to the documentation repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants