Exception on reasoned query on model with user defined rules

Hi all.
When trying to execute a query with reasoning in a model, I get this error : 000012: com.complexible.stardog.plan.eval.operator.OperatorException: Uncaught error during query evaluation: ConcurrentModificationException:

Ontology model has 2 SWRL rules and should be consistent, as it runs fine in Protege (with built-in pellet reasoner). Model has been imported into a stardog rdf model and the query

SELECT ?tse
FROM <urn:test_graph>
{
    ?tse a :TaperedShaftEnd
}

fails with the above error message.

By deleting the SWRL rules the query runs fine, but of course the model does no longer represent the desired domain. By translating the SWRL rules into stardog native rules, the error appears again.

Reasoning level is set to DL, as SL would imply too high processing times for the target application.
Changing the sameAs flag in the reasoner options does not change the behavior. Setting to SL would solve the problem on this simplified model, but as said would result impractical for the use on the final target application.

May you help me in identifying the root cause and the possible solution?

Attached the .ttl file of the model.
swrl_test_for_stardog_with_native_rules.ttl (2.1 KB)
Here below an excerpt of the log file.

Heartful thanks to anyone who may help me with this.
With kind regards,
Lorenzo.

ERROR 2022-02-21 12:18:11,280 [stardog-user-10] com.complexible.stardog.QueryManager:exceptionTriggered(519): Error during execution of the query
SELECT ?tse
FROM <urn:test_graph>
{
    ?tse a :TaperedShaftEnd
}
# Overrides by the API: 
# LIMIT 1000
with query plan
prefix : <http://api.stardog.com/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix stardog: <tag:stardog:api:>

From <urn:test_graph>
Slice(offset=0, limit=1000) [#1]
`─ Projection(?tse) [#1]
   `─ DL()
   `─ SELECT *
   `─ WHERE {
   `─    ?tse <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://api.stardog.com/TaperedShaftEnd> .
   `─ }
against database test_db with reasoning schema default
java.util.ConcurrentModificationException: null
	at java.util.HashMap$HashIterator.nextNode(HashMap.java:1469) ~[?:1.8.0_312]
	at java.util.HashMap$KeyIterator.next(HashMap.java:1493) ~[?:1.8.0_312]
	at com.clarkparsia.pellet.rules.RulesStrategy.applyRuleBindings(RulesStrategy.java:139) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.clarkparsia.pellet.rules.RulesStrategy.doComplete(RulesStrategy.java:230) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.clarkparsia.pellet.tableau.completion.AbstractCompletionStrategy.complete(AbstractCompletionStrategy.java:387) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.clarkparsia.pellet.tableau.abox.DefaultABox.checkInconsistent(DefaultABox.java:1083) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.clarkparsia.pellet.tableau.abox.DefaultABox.isConsistent(DefaultABox.java:1014) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.clarkparsia.pellet.tableau.abox.DefaultABox.consistency(DefaultABox.java:1006) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.clarkparsia.pellet.tableau.DefaultTableauKB.consistency(DefaultTableauKB.java:690) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.clarkparsia.pellet.tableau.DefaultTableauKB.isConsistent(DefaultTableauKB.java:702) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.clarkparsia.pellet.api.query.impl.DefaultQueryEngine.execute(DefaultQueryEngine.java:88) ~[stardog-reasoning-shared-7.8.0.jar:?]
	at com.clarkparsia.pellet.api.query.impl.AbstractQueryEngine.visit(AbstractQueryEngine.java:104) ~[stardog-reasoning-shared-7.8.0.jar:?]
	at com.clarkparsia.pellet.api.query.impl.AbstractQueryEngine.visit(AbstractQueryEngine.java:33) ~[stardog-reasoning-shared-7.8.0.jar:?]
	at com.clarkparsia.pellet.api.query.impl.SelectQueryImpl.accept(SelectQueryImpl.java:43) ~[stardog-reasoning-shared-7.8.0.jar:?]
	at com.clarkparsia.pellet.api.query.impl.AbstractQueryEngine.execute(AbstractQueryEngine.java:42) ~[stardog-reasoning-shared-7.8.0.jar:?]
	at com.complexible.stardog.reasoning.pellet.PelletUtils.executeQuery(PelletUtils.java:90) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.complexible.stardog.reasoning.pellet.PelletOp.computeNext(PelletOp.java:89) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.complexible.stardog.reasoning.pellet.PelletOp.computeNext(PelletOp.java:35) ~[stardog-reasoning-core-7.8.0.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:147) ~[stardog-utils-common-7.8.0.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:134) ~[stardog-utils-common-7.8.0.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:95) ~[stardog-7.8.0.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:32) ~[stardog-7.8.0.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:147) ~[stardog-utils-common-7.8.0.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:134) ~[stardog-utils-common-7.8.0.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.SliceOp._hasNext(SliceOp.java:92) ~[stardog-7.8.0.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.SliceOp.computeNext(SliceOp.java:100) ~[stardog-7.8.0.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.SliceOp.computeNext(SliceOp.java:26) ~[stardog-7.8.0.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:147) ~[stardog-utils-common-7.8.0.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:134) ~[stardog-utils-common-7.8.0.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:139) ~[stardog-7.8.0.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:27) ~[stardog-7.8.0.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:147) ~[stardog-utils-common-7.8.0.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:134) ~[stardog-utils-common-7.8.0.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:117) ~[stardog-7.8.0.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:38) ~[stardog-7.8.0.jar:?]
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) ~[guava-30.1.1-jre.jar:?]
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) ~[guava-30.1.1-jre.jar:?]
	at com.complexible.common.base.CloseableIterator$2.computeNext(CloseableIterator.java:84) ~[stardog-utils-common-7.8.0.jar:?]
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) ~[guava-30.1.1-jre.jar:?]
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) ~[guava-30.1.1-jre.jar:?]
	at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.computeNext(IteratorAsTupleQueryResult.java:98) ~[stardog-utils-rdf-7.8.0.jar:?]
	at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.computeNext(IteratorAsTupleQueryResult.java:24) ~[stardog-utils-rdf-7.8.0.jar:?]
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) ~[guava-30.1.1-jre.jar:?]
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) ~[guava-30.1.1-jre.jar:?]
	at com.stardog.stark.query.ClosingSpliterator.forEachRemaining(ClosingSpliterator.java:37) ~[stardog-stark-query-api-7.8.0.jar:?]
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:647) ~[?:1.8.0_312]
	at com.stardog.stark.query.io.QueryResultWriters.write(QueryResultWriters.java:140) ~[stardog-stark-query-io-7.8.0.jar:?]
	at com.stardog.stark.query.io.QueryResultWriters.write(QueryResultWriters.java:126) ~[stardog-stark-query-io-7.8.0.jar:?]
	at com.complexible.stardog.protocols.http.server.ProtocolUtils.writeTupleResponse(ProtocolUtils.java:728) ~[stardog-protocols-http-server-7.8.0.jar:?]
	at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:620) ~[stardog-protocols-http-server-7.8.0.jar:?]
	at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:589) ~[stardog-protocols-http-server-7.8.0.jar:?]
	at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:547) ~[stardog-protocols-http-server-7.8.0.jar:?]
	at com.complexible.stardog.protocols.http.server.SPARQLProtocol.executeQuery(SPARQLProtocol.java:239) ~[stardog-protocols-http-server-7.8.0.jar:?]
	at com.complexible.stardog.protocols.http.server.SPARQLProtocol.post(SPARQLProtocol.java:163) ~[stardog-protocols-http-server-7.8.0.jar:?]
	at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:192) ~[stardog-protocols-http-server-7.8.0.jar:?]
	at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) [shiro-core-1.7.1.jar:1.7.1]
	at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) [shiro-core-1.7.1.jar:1.7.1]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_312]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_312]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312]

I noticed the same error from a very simple query against my Cloud Essentials database

describe ?r { ?r a <http://www.w3.org/ns/hydra/core#Resource> } limit 1

On the other hand, with a different the RDF type it runs fine

describe ?r { ?r a <https://www.w3.org/ns/activitystreams#Activity> } limit 1

I don't have any custom rules. It happens when using various reasoning types. Here's the query plan when set to RDFS

# reused
From local
From named local named
Describe(default) [#1]
`─ Projection(?r) [#1]
   `─ Slice(offset=0, limit=1) [#1]
      `─ Union [#185K]
         +─ Union [#185K]
         │  +─ Union [#185K]
         │  │  +─ Union [#185K]
         │  │  │  +─ Scan[PS_NOC](?r, <http://www.w3.org/ns/hydra/core#apiDocumentation>, _) [#131K]
         │  │  │  `─ Scan[PO_NOC](_, <http://www.w3.org/ns/hydra/core#apiDocumentation>, ?r) [#54K]
         │  │  `─ Union [#6]
         │  │     +─ Scan[PO_NOC](_, <http://www.w3.org/ns/hydra/core#collection>, ?r) [#4]
         │  │     `─ Scan[PO_NOC](_, <http://www.w3.org/ns/hydra/core#entrypoint>, ?r) [#1]
         │  `─ Union [#60]
         │     +─ Union [#20]
         │     │  +─ Scan[PS_NOC](?r, <http://www.w3.org/ns/hydra/core#entrypoint>, _) [#3]
         │     │  `─ Scan[PS_NOC](?r, <http://www.w3.org/ns/hydra/core#manages>, _) [#16]
         │     `─ Union [#39]
         │        +─ Scan[PS_NOC](?r, <http://www.w3.org/ns/hydra/core#member>, _) [#14]
         │        `─ Union [#25]
         │           +─ Scan[PS_NOC](?r, <http://www.w3.org/ns/hydra/core#memberAssertion>, _) [#17]
         │           `─ Scan[PS_NOC](?r, <http://www.w3.org/ns/hydra/core#search>, _) [#7]
         `─ Union [#78]
            +─ Union [#67]
            │  +─ Union [#11]
            │  │  +─ Scan[POSC](?r, rdf:type, <http://www.w3.org/ns/hydra/core#ApiDocumentation>) [#8]
            │  │  `─ Scan[POSC](?r, rdf:type, <http://www.w3.org/ns/hydra/core#BaseUriSource>) [#3]
            │  `─ Union [#56]
            │     +─ Scan[POSC](?r, rdf:type, <http://www.w3.org/ns/hydra/core#Collection>) [#22]
            │     `─ Union [#34]
            │        +─ Scan[POSC](?r, rdf:type, <http://www.w3.org/ns/hydra/core#Link>) [#16]
            │        `─ Scan[POSC](?r, rdf:type, <http://www.w3.org/ns/hydra/core#Resource>) [#18]
            `─ Union [#11]
               +─ Union [#2]
               │  +─ Scan[POSC](?r, rdf:type, <http://www.w3.org/ns/hydra/core#TemplatedLink>) [#1]
               │  `─ Scan[POSC](?r, rdf:type, <https://jmk.maze.link/accounts/api/AccountsCollection>) [#1]
               `─ Union [#9]
                  +─ Scan[POSC](?r, rdf:type, <https://jmk.maze.link/registry/api/RegistrationDataCollection>) [#1]
                  `─ Union [#8]
                     +─ Scan[POSC](?r, rdf:type, <https://jmk.org.pl/vocab#Dictionary>) [#7]
                     `─ Scan[POSC](?r, rdf:type, <https://jmk.org.pl/vocab#RegistrationData>) [#1]