I’m encountering an issue with my Neo4j database deployed on an AWS EC2 r6i.2xlarge (8 vCPU, 64GB of RAM) instance. Whenever I execute a specific Cypher query through my Node.js server using the neo4j-driver library (version 4.4.5), I receive the following error:
Neo4jError: The allocation of an extra 2.0 MiB would use more than the limit 56.0 GiB. Currently using 56.0 GiB. db.memory.transaction.total.max threshold reached
Here are some details about my setup:
Neo4j: Community Edition (version: 5.19.0)
Deployment: https://aws.amazon.com/marketplace/pp/prodview-lxxbmpqvwo5eq?sr=0-2&ref_=beagle&applicationId=AWSMPContessa#pdp-pricing (used as a template)
Configurations in neo4j.conf:
server.memory.heap.initial_size=56g
server.memory.heap.max_size=57g
server.memory.pagecache.size=2g
db.memory.transaction.total.max=56g
db.memory.transaction.max=56g
dbms.memory.transaction.total.max=56g
server.jvm.additional=-XX:+ExitOnOutOfMemoryError
Database Schema
Dao {
organizationId: String!
daoId: String!
name: String!
}
Proposal {
proposalNativeId: String!
proposer: String!
(Proposal)-[:IN]->(Dao)
}
Vote {
voteNativeId: String!
voter: String!
choice: String!
(Vote)-[:BELONGS_TO]->(Proposal)
}
Indexes:
Dao - daoId column
Proposal - proposalNativeId column
Vote - voteNativeId column
Data Volume:
Dao - 1
Proposal - 62
Vote - 483
Problematic Query:
MATCH (d:Dao { daoId: '9ad9fb81-ad04-4830-85c2-212034072580' })<-[:IN]-(v1:Vote)-[:BELONGS_TO]->(p:Proposal)
MATCH (d)<-[:IN]-(v2:Vote WHERE v1.voter < v2.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v3:Vote WHERE v2.voter < v3.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v4:Vote WHERE v3.voter < v4.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v5:Vote WHERE v4.voter < v5.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v6:Vote WHERE v5.voter < v6.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v7:Vote WHERE v6.voter < v7.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v8:Vote WHERE v7.voter < v8.voter)-[:BELONGS_TO]->(p)
WITH v1.voter AS member1, v2.voter AS member2, v3.voter AS member3, v4.voter AS member4, v5.voter AS member5, v6.voter AS member6, v7.voter AS member7, v8.voter AS member8, COUNT(distinct p) as voted_on_same_proposal
MATCH (d:Dao { daoId: '9ad9fb81-ad04-4830-85c2-212034072580' })<-[:IN]-(v1:Vote)-[:BELONGS_TO]->(p:Proposal)
MATCH (d)<-[:IN]-(v2:Vote WHERE v1.voter < v2.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v3:Vote WHERE v2.voter < v3.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v4:Vote WHERE v3.voter < v4.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v5:Vote WHERE v4.voter < v5.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v6:Vote WHERE v5.voter < v6.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v7:Vote WHERE v6.voter < v7.voter)-[:BELONGS_TO]->(p)
MATCH (d)<-[:IN]-(v8:Vote WHERE v7.voter < v8.voter)-[:BELONGS_TO]->(p)
WHERE v1.voter = member1 AND v2.voter = member2 AND v3.voter = member3 AND v4.voter = member4 AND v5.voter = member5 AND v6.voter = member6 AND v7.voter = member7 AND v8.voter = member8
AND v1.choice = v2.choice AND v2.choice = v3.choice AND v3.choice = v4.choice AND v4.choice = v5.choice AND v5.choice = v6.choice AND v6.choice = v7.choice AND v7.choice = v8.choice
RETURN [v1.voter, v2.voter, v3.voter, v4.voter, v5.voter, v6.voter, v7.voter, v8.voter] AS members, COUNT(distinct p) AS voted_together, collect(distinct p.proposalNativeId) AS proposal_native_ids, voted_on_same_proposal
ORDER BY voted_together DESC, voted_on_same_proposal DESC
LIMIT 20
The query retrieves information about voters who voted together on the same proposals (with consideration of choice and without) within a DAO.
The goal: get ## number people coalitions for ## number of votes.
I’ve already increased memory configurations in neo4j.conf as mentioned above and increased the EC2 instance (from r6i.xlarge to r6i.2xlarge), but the issue persists.
Also, is it possible to get logs to understand the progress percentage of the query being performed?
Any insights into resolving this problem would be greatly appreciated. Thank you!
Yurii Pristay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.