Describe the bug
It is possible to induce RESTXQ to fail a dependency check and cause system instability.
Expected behavior
A failed dependency check by RESTXQ should be registered once, and not cause an infinite loop, log bloat, and system instability.
To Reproduce
Save the following query to /db/test.xqm:
xquery version "3.1";
module namespace test = "test";
Notice no problems in exist.log or restxq.log.
Now, add the following line to the query and save it a 2nd time:
import module namespace test = "test" at "test.xqm";
Again, notice no problems in exist.log or restxq.log.
Now, delete the added line, and save the query a 3rd time.
Now, notice the following two entries in restxq.log:
2020-06-16 17:14:38,175 [qtp554346832-55] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/test.xqm' has a missing dependency on '/db/test.xqm'. Will re-examine if the missing module is added.
2020-06-16 17:14:38,179 [qtp554346832-55] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/test.xqm' has been added to the database, re-examining '/db/test.xqm'...
In addition, the 2nd log line ("reexamineModules...") is repeated 1312 times in restxq.log.
In addition, the store fails, with the following error, reported in the Java admin client:
Failed to invoke method storeBinary in class org.exist.xmlrpc.RpcConnection: null
org.xmldb.api.base.XMLDBException: Failed to invoke method storeBinary in class org.exist.xmlrpc.RpcConnection: null
at org.exist.xmldb.RemoteCollection.execute(RemoteCollection.java:127)
at org.exist.xmldb.RemoteCollection.store(RemoteCollection.java:545)
at org.exist.xmldb.RemoteCollection.storeResource(RemoteCollection.java:508)
at org.exist.xmldb.RemoteCollection.storeResource(RemoteCollection.java:469)
at org.exist.client.QueryDialog.saveToDb(QueryDialog.java:148)
at org.exist.client.QueryDialog.lambda$1(QueryDialog.java:168)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.Component.processMouseEvent(Component.java:6539)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: org.apache.xmlrpc.XmlRpcException: Failed to invoke method storeBinary in class org.exist.xmlrpc.RpcConnection: null
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:197)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)
at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
at org.exist.xmldb.RemoteCollection.execute(RemoteCollection.java:125)
... 42 more
exist.log reports only:
2020-06-16 18:33:39,762 [qtp749002377-52] WARN (TransactionManager.java [close]:409) - Transaction was not committed or aborted, auto aborting!
A 4th save triggers the same error, failure, and flood of 1,100+ error messages in xmlrpc.log.
However, as soon as you disable RESTXQ (by commenting out the <triggers> element in /db/system/config/db/collection.xconf and running xmldb:reindex("/db")) and try to save the revised query, the XML-RPC errors, failures, and restxq.log warnings evaporate.
Context (please always complete the following information):
Additional context
conf.xml? None.I can confirm this behaviour. When trying to install hsg-shell XAR twice (https://github.com/HistoryAtState/hsg-shell/) on an eXist-db 5.1.1 or newer, the second istallation suddenly takes > 10 min while it would usually take below one minute. I obverseved the exact same behaviour @joewiz reports here. Disablinng the RESTXQ Trigger in /db/system/config/db/collection.xconf did fix the problem and 2nd and 3rd installaton round of hsg-shell took below a min again. Only disabling RESTXQ in the conf.xml did not help because the trigger is than active.
@joewiz So you have a module which tries to import itself?
@adamretter No, I don't. I arrived at this report quite mistakenly while developing https://github.com/eXist-db/exist/issues/3448.
The primary point of this issue is that it's possible for a user to introduce a typo like this in their code, and there appears to be no way to back out of the situation once you have introduced a self-referential import into a module. Imagine the user who has stored a module with a mistaken self-referential import, then realizes their error and deletes the import and stores the module again. In "fixing" a coding error, the user's eXist instance becomes unstable.
The secondary point is that people have reported similar phenomena affecting RESTXQ – e.g., @cwittern's Feb 26 2020 exist-open post – yet no one has been able to supply a reproducible test until now. This report clearly demonstrates how to induce this state in eXist.
Just because this state is typically introduced by a coding mistake, doesn't mean that there aren't other situations that can also induce it.
My hope is that by fixing this issue, it would also close the hole that others have stumbled into.
Here are some links to previous reports - likely long out of date, but just in case...
@joewiz Sorry I should have been more precise with my language. What I meant to say is - it looks like that that in this issue you have reported, there is a module which has a self import. I just wanted to confirm that was your test case!
I was not trying to infer a lack of expertise or skill on your XQuery coding skills ;-) Quite the opposite.
I do understand that this can easily happen by accident.
I wonder what happens if you try and use such a module in eXist-db outside RESTXQ. That probably needs to be looked at too ;-)
@adamretter Ah, I see. You're correct, in the issue I reported, the problem can be reproduced by saving a module with a self import, then removing the self import and storing the module. If my original description or the title could be improved, I'm definitely open to suggestions.
As to the question of if you use such a module in eXist-db outside RESTXQ, I tested this and didn't see any ill effects - no exceptions raised or errors logged when importing a module that imports itself.
I did see a separate but possibly related problem - an error raised when declaring global variables in two modules that import each other - which I reported in https://github.com/eXist-db/exist/issues/3449.
@adamretter BaseX raises an error when a library module tries to self import:
Duplicate declaration of prefix 'test'
Saxon raises no such error. (Nor does eXist.)
@adamretter Have you had the chance to think this one through, by chance? I just hit it again in a different scenario (installing hsg-shell over itself in 5.3.0-SNAPSHOT) and noticed @peterstadler reopened #1010 indicating he's also facing this. His workaround - disabling the restxq trigger - sounds feasible for me. But I thought I'd ask if there might be a more comprehensive solution.
I just hit this again in working on a branch of public-repo. In refactoring the app, I caused modules app.xqm and scan.xqm to import the other (app.xqm already imported scan.xqm, but then I had a need for scan.xqm to import app.xqm). When building and installing the resulting app the first time into a clean database, there's no problem. When installing the app a second time—over the first installation—the installation hangs. The restxq.log file balloons. eXist becomes unresponsive. eXist's CPU usage exceeds 100%. Monex shows that the package installation is stuck upon storing the scan.xqm binary:
Trying to shut down eXist just doesn't work at all - exist.log shows these every 2-3 seconds:
2021-03-07 00:07:16,709 [db.exist.scheduler.quartz-worker-2] WARN (BrokerPool.java [triggerSystemTask]:1526) - Unable to execute SystemTask: 'Sync' as database is shut down!
So I can only force-quit eXist and incur a recovery run.
Here's what restxq.log shows for the 2nd installation:
2021-03-07 00:14:34,569 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/scan.xqm' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,570 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/get-package.xq' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,570 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/list.xq' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,570 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/get-icon.xq' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,570 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/feed.xq' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,570 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/put-package.xq' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,570 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/view.xq' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,571 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/controller.xql' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,571 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/find.xq' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,571 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/post-install.xq' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,571 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/app.xqm' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,572 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/list.xq' has a missing dependency on '/db/apps/public-repo/modules/versions.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,572 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/find.xq' has a missing dependency on '/db/apps/public-repo/modules/versions.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,572 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/app.xqm' has a missing dependency on '/db/apps/public-repo/modules/versions.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,572 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/scan.xqm' has a missing dependency on '/db/apps/public-repo/modules/app.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,572 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/get-package.xq' has a missing dependency on '/db/apps/public-repo/modules/app.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,573 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/put-package.xq' has a missing dependency on '/db/apps/public-repo/modules/app.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,573 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/view.xq' has a missing dependency on '/db/apps/public-repo/modules/app.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,573 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/find.xq' has a missing dependency on '/db/apps/public-repo/modules/app.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,573 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/update.xq' has a missing dependency on '/db/apps/public-repo/modules/scan.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,574 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/list.xq' has a missing dependency on '/db/apps/public-repo/modules/scan.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,574 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/put-package.xq' has a missing dependency on '/db/apps/public-repo/modules/scan.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,574 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/app.xqm' has a missing dependency on '/db/apps/public-repo/modules/scan.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,638 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/controller.xql' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,641 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/post-install.xq' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,714 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/get-icon.xq' has a missing dependency on '/db/apps/public-repo/modules/config.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,723 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/config.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/scan.xqm was removed
2021-03-07 00:14:34,723 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/config.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/get-package.xq was removed
2021-03-07 00:14:34,723 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/config.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/list.xq was removed
2021-03-07 00:14:34,723 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/apps/public-repo/modules/config.xqm' has been added to the database, re-examining '/db/apps/public-repo/modules/get-icon.xq'...
2021-03-07 00:14:34,735 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:324) - Discovered 0 resource functions for /db/apps/public-repo/modules/get-icon.xq
2021-03-07 00:14:34,736 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/config.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/feed.xq was removed
2021-03-07 00:14:34,736 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/config.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/put-package.xq was removed
2021-03-07 00:14:34,736 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/config.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/view.xq was removed
2021-03-07 00:14:34,736 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/apps/public-repo/modules/config.xqm' has been added to the database, re-examining '/db/apps/public-repo/controller.xql'...
2021-03-07 00:14:34,766 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:324) - Discovered 0 resource functions for /db/apps/public-repo/controller.xql
2021-03-07 00:14:34,766 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/config.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/find.xq was removed
2021-03-07 00:14:34,766 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/apps/public-repo/modules/config.xqm' has been added to the database, re-examining '/db/apps/public-repo/post-install.xq'...
2021-03-07 00:14:34,777 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:324) - Discovered 0 resource functions for /db/apps/public-repo/post-install.xq
2021-03-07 00:14:34,777 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/config.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/app.xqm was removed
2021-03-07 00:14:34,783 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/find.xq' has a missing dependency on '/db/apps/public-repo/modules/app.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,789 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/get-package.xq' has a missing dependency on '/db/apps/public-repo/modules/app.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,843 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/versions.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/list.xq was removed
2021-03-07 00:14:34,843 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/apps/public-repo/modules/versions.xqm' has been added to the database, re-examining '/db/apps/public-repo/modules/find.xq'...
2021-03-07 00:14:34,848 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/find.xq' has a missing dependency on '/db/apps/public-repo/modules/app.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,848 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:324) - Discovered 0 resource functions for /db/apps/public-repo/modules/find.xq
2021-03-07 00:14:34,849 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/versions.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/app.xqm was removed
2021-03-07 00:14:34,851 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/view.xq' has a missing dependency on '/db/apps/public-repo/modules/app.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,900 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/app.xqm' has a missing dependency on '/db/apps/public-repo/modules/scan.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,967 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/put-package.xq' has a missing dependency on '/db/apps/public-repo/modules/app.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:34,967 [qtp1063583761-50] WARN (ExistXqueryRegistry.java [recordMissingDependency]:428) - Module '/db/apps/public-repo/modules/app.xqm' has a missing dependency on '/db/apps/public-repo/modules/scan.xqm'. Will re-examine if the missing module is added.
2021-03-07 00:14:35,199 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/scan.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/update.xq was removed
2021-03-07 00:14:35,199 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:327) - Dependant '/db/apps/public-repo/modules/scan.xqm' has been resolved. Dependency on: /db/apps/public-repo/modules/list.xq was removed
2021-03-07 00:14:35,199 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/apps/public-repo/modules/scan.xqm' has been added to the database, re-examining '/db/apps/public-repo/modules/put-package.xq'...
2021-03-07 00:14:35,445 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:324) - Discovered 0 resource functions for /db/apps/public-repo/modules/put-package.xq
2021-03-07 00:14:35,446 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/apps/public-repo/modules/scan.xqm' has been added to the database, re-examining '/db/apps/public-repo/modules/app.xqm'...
2021-03-07 00:14:35,680 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/apps/public-repo/modules/app.xqm' has been added to the database, re-examining '/db/apps/public-repo/modules/scan.xqm'...
2021-03-07 00:14:35,913 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/apps/public-repo/modules/scan.xqm' has been added to the database, re-examining '/db/apps/public-repo/modules/app.xqm'...
2021-03-07 00:14:36,155 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/apps/public-repo/modules/app.xqm' has been added to the database, re-examining '/db/apps/public-repo/modules/scan.xqm'...
2021-03-07 00:14:36,363 [qtp1063583761-50] INFO (ExistXqueryRegistry.java [reexamineModulesWithResolvedDependencies]:321) - Missing dependency '/db/apps/public-repo/modules/scan.xqm' has been added to the database, re-examining '/db/apps/public-repo/modules/app.xqm'...
... and so on ad infinitum, alternating between reports of scan.xqm and app.xqm having a "missing dependency".
Here's the snapshot build that triggers this situation - but beware, installing this twice will cause eXist to crash:
public-repo-2.0.0-SNAPSHOT.xar.zip
I guess this approach to refactoring my app won't work, so I'll rework the branch...
I've started getting the same issue after upgrade from eXist-db 2.2 to eXist-db 5.2.0. We have circular dependencies between modules, such as A -> B, B -> A. The surprising part is that we did not have this issue while testing but once we decided to release it to production, this issue appeared! I had to disable the RESTXQ trigger as a last resort. It would be really good it to be fixed properly.
We are having this issue but even without having any circular dependencies (AFAIK). Currently disabling the RESTXQ trigger and all things RESTXQ. Still, I'm wondering what we should do if we wanted to use RESTXQ.
Most helpful comment
@joewiz Sorry I should have been more precise with my language. What I meant to say is - it looks like that that in this issue you have reported, there is a module which has a self import. I just wanted to confirm that was your test case!
I was not trying to infer a lack of expertise or skill on your XQuery coding skills ;-) Quite the opposite.
I do understand that this can easily happen by accident.
I wonder what happens if you try and use such a module in eXist-db outside RESTXQ. That probably needs to be looked at too ;-)