Export Current Solution - Graph folder is empty

Problem

Export current solution failed.

Error message

This case is that they tried exporting graph schema through graphstudio but failed, and exported directly from gsql also failed and got the below error:

GSQL > EXPORT GRAPH ALL -T TO "/home/tigergraph/export"
Exporting global graph
Exporting graph GRAPH_NAME
Internal Error, please contact support@tigergraph.com

And the GSQL export error logs with NullPointerException:

E@20220517 14:43:21.916 tigergraph|127.0.0.1:40480|00000000113 (QueryBlockHandler.java:202) java.lang.NullPointerException
java.lang.NullPointerException
at com.tigergraph.schema.g.k(DatabaseImportExport.java:344)
at com.tigergraph.schema.g.a(DatabaseImportExport.java:695)

Pulled the catalog from prod env and pushed it into test env, enable GSQL debug logs, reran the export command in GSQL, found out the stuck query,and dropped the query one by one, but at last, there was one query can’t be dropped with below error:

(Util.java:1688) Failed to drop queries on the graph 'GRAPH_NAME': [foo_test_subquery3].

Diagnosis

According to the last error logs, there may be some issue with the query foo_test_subquery3. Got the catalog of the query in “catalog/graph_name/QueryListCatalog.yaml”, and found it was called by two queries: "foo_" and "foo_test_call_subquery" in CallerQueries list:

      "CallerQueries": [
        "foo_",
        "foo_test_call_subquery"
      ],
      "subQueries": {},

And the query “foo_” can’t be found in the prod env, it was a ghost query that call the query “foo_test_subqeury3”

Workaround

A simple way to delete the ghost query which has called the exiting query:

1) login gsql and switch to the graph which the query foo_test_subquery3 was in,  and create a query named "foo_" which call the query "foo_test_subquery3"
2) drop query "foo_"
3) redo the export operation:
GSQL > EXPORT GRAPH ALL -T TO "/home/tigergraph/export"

It was reproduced in-house and solved the issue after running the above steps.