Query creation fails in a graph

I’m trying to run CREATE QUERY on a graph.
However, this causes the node running the graph to reach massive CPU usage for a very long time, and then the creation fails.

However, on a new cluster with an almost empty schema, creation and installation did succeed, though after considerable time. (So it’s not a syntax error)

There is no error message but “Internal Error”.
This is the basic outline of the query:

CREATE QUERY myquery(/* some params here */) FOR GRAPH mygraph {
    /* accumualtors and variable declerations*/
    Start = {sourcesEntities};

    WHILE Start.size() > 0 LIMIT max_hops DO
        @@currentHop += 1;

        startSingleHop = SELECT t FROM Start:s -(:e)- :t
            WHERE (/* conditions */)
                /* ACCUM block logic here */
        ; #end of select

        startTwoHops = Start MINUS startSingleHop;
        IF (some_condition) THEN
            startTwoHops = SELECT t FROM startTwoHops:s -(:e)- :t -(:enext)- :n
                WHERE (/* conditions */)
                  /* ACCUM block logic here */

                HAVING /* some condition */
            ; # end of select
        Start = startSingleHop UNION startTwoHops;


    PRINT results;


Note that the query is using V2 Syntax and Pattern Matching.

How can I know why creation fails?

Using TigerGraph 3.5.x