Graph db
Troubleshooting Guide: Neo4j Graph Database Query Failures in R2R
When working with R2R (RAG to Riches) and encountering Neo4j graph database query failures, it’s important to systematically identify and resolve the issues. This guide will help you troubleshoot common problems.
1. Verify Neo4j Connection
First, ensure that R2R can connect to Neo4j:
-
Check Neo4j connection settings in your R2R configuration:
cat /path/to/your/r2r_config.toml
Look for the
[graph_store]
section and verify the Neo4j URL, username, and password. -
Try connecting to Neo4j using the official Neo4j Browser or cypher-shell:
cypher-shell -a bolt://localhost:7687 -u neo4j -p your_password
If this fails, it’s likely a connection issue rather than a query problem.
2. Check Neo4j Logs
Neo4j logs can provide valuable information about query failures:
-
Locate Neo4j logs:
docker exec -it r2r-neo4j-1 bash cat /logs/neo4j.log | grep ERROR
-
Look for specific error messages related to your queries.
3. Validate Cypher Queries
Ensure your Cypher queries are correctly formatted:
-
Extract the failing query from R2R logs:
docker logs r2r-r2r-1 | grep "Cypher query"
-
Test the query directly in Neo4j Browser or cypher-shell.
-
Common Cypher syntax issues:
- Missing or mismatched parentheses
- Incorrect property names
- Case sensitivity (Neo4j is case-sensitive)
- Incorrect relationship types
4. Check for Data Integrity
Ensure the data in Neo4j matches what your queries expect:
-
Verify node labels:
MATCH (n) RETURN DISTINCT labels(n)
-
Check relationship types:
MATCH ()-[r]->() RETURN DISTINCT type(r)
-
Inspect property keys:
MATCH (n) UNWIND keys(n) AS key RETURN DISTINCT key
5. Performance Issues
If queries are failing due to timeouts:
-
Check Neo4j’s query timeout setting:
docker exec -it r2r-neo4j-1 bash cat /var/lib/neo4j/conf/neo4j.conf | grep dbms.transaction.timeout
-
Analyze query performance:
- Use
PROFILE
before your Cypher query in Neo4j Browser to see execution plans. - Look for full graph scans or high-cost operations.
- Use
-
Ensure proper indexes are in place:
SHOW INDEXES
6. Memory and Resource Constraints
Graph queries can be memory-intensive:
-
Check Neo4j’s memory settings:
docker exec -it r2r-neo4j-1 bash cat /var/lib/neo4j/conf/neo4j.conf | grep dbms.memory
-
Monitor Neo4j’s memory usage:
docker stats r2r-neo4j-1
-
Adjust memory settings if necessary in your Docker Compose file.
7. Version Compatibility
Ensure R2R is compatible with your Neo4j version:
-
Check Neo4j version:
docker exec -it r2r-neo4j-1 neo4j --version
-
Verify R2R’s supported Neo4j versions in the documentation.
8. Plugin Issues
If using Neo4j plugins like APOC or GDS:
-
Verify plugin installation:
CALL dbms.procedures() YIELD name WHERE name STARTS WITH "apoc" OR name STARTS WITH "gds" RETURN name
-
Check plugin compatibility with your Neo4j version.
9. Authentication and Authorization
Ensure the Neo4j user has proper permissions:
-
Check user roles:
SHOW USERS
-
Verify database access rights:
SHOW USER neo4j PRIVILEGES
10. Network Issues
For dockerized setups:
-
Ensure Neo4j is on the same Docker network as R2R:
docker network inspect r2r-network
-
Check if Neo4j is accessible from the R2R container:
docker exec -it r2r-r2r-1 ping neo4j
Debugging Steps
- Enable verbose logging in R2R for Neo4j operations.
- Use Neo4j’s query logging feature to capture all executed queries.
- Implement query parameter logging in R2R to ensure correct parameter passing.
Getting Help
If issues persist:
- Gather relevant logs (R2R, Neo4j, Docker).
- Document the exact steps to reproduce the issue.
- Check R2R and Neo4j documentation for known issues.
- Consult the R2R community on Discord or GitHub for support.
- For Neo4j-specific issues, consider posting on Neo4j’s community forums.
Remember to sanitize any sensitive information before sharing logs or queries publicly.
By following this guide, you should be able to identify and resolve most Neo4j query failures in your R2R setup. If problems persist, don’t hesitate to seek help from the R2R or Neo4j communities.
Was this page helpful?