Issue 1:
Running the following query on an empty database

MATCH (n:L) WHERE n.p XOR (false XOR n.p OR null) RETURN n

throws

Caused by: org.neo4j.graphdb.QueryExecutionException: Expected
RegularSinglePlannerQuery(QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']},InterestingOrder(RequiredOrderCandidate(List()),List()),RegularQueryProjection(Map(n -> Variable(n)),QueryPagination(None,None),Selections(Set())),None,None)

Instead, got:
RegularSinglePlannerQuery(QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'not n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']},InterestingOrder(RequiredOrderCandidate(List()),List()),RegularQueryProjection(Map(n -> Variable(n)),QueryPagination(None,None),Selections(Set())),None,None)
Plan: ProduceResult(List(n)) {
LHS -> Selection(Ands(Vector(Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(Null()))), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(Property(Variable(n),PropertyKeyName(p))))), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(Property(Variable(n),PropertyKeyName(p))), Property(Variable(n),PropertyKeyName(p)))), Ors(List(Property(Variable(n),PropertyKeyName(p)), Property(Variable(n),PropertyKeyName(p)), Null())), Ors(List(Property(Variable(n),PropertyKeyName(p)), Not(False()), Not(Property(Variable(n),PropertyKeyName(p))), Null())), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(False()), Property(Variable(n),PropertyKeyName(p)))), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(False())))))) {
LHS -> Distinct(Map(n -> Variable(n))) {
LHS -> Union() {
LHS -> Selection(Ands(Vector(Not(Property(Variable(n),PropertyKeyName(p)))))) {
LHS -> NodeByLabelScan(n, LabelName(L), Set(), IndexOrderNone) {}
}
RHS -> Selection(Ands(Vector(Not(Property(Variable(n),PropertyKeyName(p)))))) {
LHS -> NodeByLabelScan(n, LabelName(L), Set(), IndexOrderNone) {}
}
}
}
}
}

Differences:
- QueryGraph
A: QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']}
B: QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'not n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']}

at org.neo4j.kernel.impl.query.QueryExecutionKernelException.asUserException(QueryExecutionKernelException.java:35)
at org.neo4j.kernel.impl.coreapi.TransactionImpl.execute(TransactionImpl.java:293)
at org.neo4j.kernel.impl.coreapi.TransactionImpl.execute(TransactionImpl.java:274)
at org.neo4j.kernel.impl.coreapi.TransactionImpl.execute(TransactionImpl.java:268)
... 4 more
Caused by: org.neo4j.kernel.impl.query.QueryExecutionKernelException: Expected
RegularSinglePlannerQuery(QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']},InterestingOrder(RequiredOrderCandidate(List()),List()),RegularQueryProjection(Map(n -> Variable(n)),QueryPagination(None,None),Selections(Set())),None,None)

Instead, got:
RegularSinglePlannerQuery(QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'not n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']},InterestingOrder(RequiredOrderCandidate(List()),List()),RegularQueryProjection(Map(n -> Variable(n)),QueryPagination(None,None),Selections(Set())),None,None)
Plan: ProduceResult(List(n)) {
LHS -> Selection(Ands(Vector(Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(Null()))), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(Property(Variable(n),PropertyKeyName(p))))), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(Property(Variable(n),PropertyKeyName(p))), Property(Variable(n),PropertyKeyName(p)))), Ors(List(Property(Variable(n),PropertyKeyName(p)), Property(Variable(n),PropertyKeyName(p)), Null())), Ors(List(Property(Variable(n),PropertyKeyName(p)), Not(False()), Not(Property(Variable(n),PropertyKeyName(p))), Null())), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(False()), Property(Variable(n),PropertyKeyName(p)))), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(False())))))) {
LHS -> Distinct(Map(n -> Variable(n))) {
LHS -> Union() {
LHS -> Selection(Ands(Vector(Not(Property(Variable(n),PropertyKeyName(p)))))) {
LHS -> NodeByLabelScan(n, LabelName(L), Set(), IndexOrderNone) {}
}
RHS -> Selection(Ands(Vector(Not(Property(Variable(n),PropertyKeyName(p)))))) {
LHS -> NodeByLabelScan(n, LabelName(L), Set(), IndexOrderNone) {}
}
}
}
}
}

Differences:
- QueryGraph
A: QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']}
B: QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'not n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']}

at org.neo4j.cypher.internal.javacompat.ExecutionEngine.executeQuery(ExecutionEngine.java:131)
at org.neo4j.cypher.internal.javacompat.ExecutionEngine.executeQuery(ExecutionEngine.java:115)
at org.neo4j.kernel.impl.coreapi.TransactionImpl.execute(TransactionImpl.java:285)
... 8 more
Caused by: org.neo4j.exceptions.InternalException: Expected
RegularSinglePlannerQuery(QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']},InterestingOrder(RequiredOrderCandidate(List()),List()),RegularQueryProjection(Map(n -> Variable(n)),QueryPagination(None,None),Selections(Set())),None,None)

Instead, got:
RegularSinglePlannerQuery(QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'not n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']},InterestingOrder(RequiredOrderCandidate(List()),List()),RegularQueryProjection(Map(n -> Variable(n)),QueryPagination(None,None),Selections(Set())),None,None)
Plan: ProduceResult(List(n)) {
LHS -> Selection(Ands(Vector(Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(Null()))), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(Property(Variable(n),PropertyKeyName(p))))), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(Property(Variable(n),PropertyKeyName(p))), Property(Variable(n),PropertyKeyName(p)))), Ors(List(Property(Variable(n),PropertyKeyName(p)), Property(Variable(n),PropertyKeyName(p)), Null())), Ors(List(Property(Variable(n),PropertyKeyName(p)), Not(False()), Not(Property(Variable(n),PropertyKeyName(p))), Null())), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(False()), Property(Variable(n),PropertyKeyName(p)))), Ors(List(Not(Property(Variable(n),PropertyKeyName(p))), Not(False())))))) {
LHS -> Distinct(Map(n -> Variable(n))) {
LHS -> Union() {
LHS -> Selection(Ands(Vector(Not(Property(Variable(n),PropertyKeyName(p)))))) {
LHS -> NodeByLabelScan(n, LabelName(L), Set(), IndexOrderNone) {}
}
RHS -> Selection(Ands(Vector(Not(Property(Variable(n),PropertyKeyName(p)))))) {
LHS -> NodeByLabelScan(n, LabelName(L), Set(), IndexOrderNone) {}
}
}
}
}
}

Differences:
- QueryGraph
A: QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']}
B: QueryGraph {Nodes: ['n'], Predicates: ['not n.p OR not NULL', 'n.p OR not false OR not n.p OR NULL', 'not n.p OR not false OR n.p', 'not n.p', 'n:L', 'n.p OR n.p OR NULL', 'not n.p OR not n.p', 'not n.p OR not false', 'not n.p OR not n.p OR n.p']}

at org.neo4j.cypher.internal.compiler.planner.logical.steps.VerifyBestPlan$.apply(VerifyBestPlan.scala:70)
at org.neo4j.cypher.internal.compiler.planner.logical.QueryPlanner$.plan(QueryPlanner.scala:121)
at org.neo4j.cypher.internal.compiler.planner.logical.QueryPlanner$.process(QueryPlanner.scala:63)
at org.neo4j.cypher.internal.compiler.planner.logical.QueryPlanner$.process(QueryPlanner.scala:51)
at org.neo4j.cypher.internal.frontend.phases.Phase.$anonfun$transform$1(Phase.scala:36)
at org.neo4j.cypher.internal.frontend.helpers.package$.$anonfun$closing$1(package.scala:24)
at org.neo4j.cypher.internal.frontend.helpers.package$.using(package.scala:32)
at org.neo4j.cypher.internal.frontend.helpers.package$.closing(package.scala:24)
at org.neo4j.cypher.internal.frontend.phases.Phase.transform(Phase.scala:35)
at org.neo4j.cypher.internal.frontend.phases.Phase.transform$(Phase.scala:33)
at org.neo4j.cypher.internal.compiler.planner.logical.QueryPlanner$.transform(QueryPlanner.scala:51)
at org.neo4j.cypher.internal.frontend.phases.PipeLine.transform(Transformer.scala:79)
at org.neo4j.cypher.internal.frontend.phases.PipeLine.transform(Transformer.scala:78)
at org.neo4j.cypher.internal.frontend.phases.PipeLine.transform(Transformer.scala:78)
at org.neo4j.cypher.internal.frontend.phases.PipeLine.transform(Transformer.scala:78)
at org.neo4j.cypher.internal.frontend.phases.PipeLine.transform(Transformer.scala:78)
at org.neo4j.cypher.internal.frontend.phases.If.transform(Transformer.scala:96)
at org.neo4j.cypher.internal.frontend.phases.PipeLine.transform(Transformer.scala:79)
at org.neo4j.cypher.internal.compiler.CypherPlanner.planPreparedQuery(CypherPlanner.scala:70)
at org.neo4j.cypher.internal.planning.CypherPlanner.doCreatePlan(CypherPlanner.scala:404)
at org.neo4j.cypher.internal.planning.CypherPlanner.org$neo4j$cypher$internal$planning$CypherPlanner$$createPlan$1(CypherPlanner.scala:352)
at org.neo4j.cypher.internal.planning.CypherPlanner$$anon$1.compile(CypherPlanner.scala:361)
at org.neo4j.cypher.internal.planning.CypherPlanner$$anon$1.compile(CypherPlanner.scala:360)
at org.neo4j.cypher.internal.QueryCache.$anonfun$compileAndCache$1(QueryCache.scala:276)
at org.neo4j.cypher.internal.QueryCache.compileOrCompileWithExpressionCodeGenAndCache(QueryCache.scala:304)
at org.neo4j.cypher.internal.QueryCache.compileAndCache(QueryCache.scala:276)
at org.neo4j.cypher.internal.QueryCache.computeIfAbsentOrStale(QueryCache.scala:193)
at org.neo4j.cypher.internal.planning.CypherPlanner.doPlan(CypherPlanner.scala:379)
at org.neo4j.cypher.internal.planning.CypherPlanner.parseAndPlan(CypherPlanner.scala:269)
at org.neo4j.cypher.internal.CypherCurrentCompiler.compile(CypherCurrentCompiler.scala:152)
at org.neo4j.cypher.internal.MasterCompiler.compile(MasterCompiler.scala:86)
at org.neo4j.cypher.internal.ExecutionEngine.$anonfun$compilerWithExpressionCodeGenOption$2(ExecutionEngine.scala:229)
at org.neo4j.cypher.internal.ExecutionEngine$$anon$2.compile(ExecutionEngine.scala:237)
at org.neo4j.cypher.internal.ExecutionEngine$$anon$2.compile(ExecutionEngine.scala:231)
at org.neo4j.cypher.internal.QueryCache.$anonfun$compileAndCache$1(QueryCache.scala:276)
at org.neo4j.cypher.internal.QueryCache.compileOrCompileWithExpressionCodeGenAndCache(QueryCache.scala:304)
at org.neo4j.cypher.internal.QueryCache.compileAndCache(QueryCache.scala:276)
at org.neo4j.cypher.internal.QueryCache.computeIfAbsentOrStale(QueryCache.scala:193)
at org.neo4j.cypher.internal.ExecutionEngine.getOrCompile(ExecutionEngine.scala:287)
at org.neo4j.cypher.internal.ExecutionEngine.doExecute(ExecutionEngine.scala:200)
at org.neo4j.cypher.internal.ExecutionEngine.$anonfun$executeSubquery$1(ExecutionEngine.scala:178)
at org.neo4j.cypher.internal.ExecutionEngine.closing(ExecutionEngine.scala:183)
at org.neo4j.cypher.internal.ExecutionEngine.executeSubquery(ExecutionEngine.scala:175)
at org.neo4j.cypher.internal.ExecutionEngine.execute(ExecutionEngine.scala:125)
at org.neo4j.cypher.internal.javacompat.ExecutionEngine.executeQuery(ExecutionEngine.java:127)
... 10 more

This might be a duplicate of #12877 but the query is slightly different so I reported it just in case.

Neo4j Version: 4.4.6

Operating System: 5.17.6 Arch Linux

API: Java

Expected behavior

I would expect the query not to throw any exception.

Actual behavior

An exception is thrown.

Issue 2:
Given an empty database, using asynchronous HTTP requests and the same exact MERGE command in rapid succession causes the neo4j server to create multiple instances of the same node. Tested on CentOS and Mac OS X using 2.1.5 release and local builds from master. Following is python code to trigger the issue:

import requests # using requests instead of future requests "alleviates" the issue

from requests_futures.sessions import FuturesSession

from bson.json_util import dumps, loads

def handleWedgeResponses(sess, r):

print r.text

session = FuturesSession()

for i in range(2):

statements = []

statements.append({"statement": "MERGE (a:Author {name: 'abc'})"})

r = session.post("http://localhost:7474/db/data/transaction/commit", data=dumps({"statements": statements}), headers={'content-type': 'application/json'}, background_callback=handleWedgeResponses)