Skip to content

Feat: add timeout to graph queries #157

@SHAcollision

Description

@SHAcollision

Description:

We have started to make queries to the get_from_graph function in the PostStream model. it fetches posts streams from Neo4J without a timeout. Right now it is super fast, but as the network grows some queries will take longer. We need to introduce timeout handling to ensure that long-running queries do not affect the performance and responsiveness of the system.

Why This Is Needed:

  • Prevent Long-Running Queries: Large or complex queries can hang, blocking resources.
  • Maintain Responsiveness: Timeout ensures the application remains responsive under high load.
  • Better Error Handling: Gracefully handle long-running queries by returning a timeout error.

Requirements:

  • Use tokio::time::timeout to limit query execution time.
  • Ensure the Neo4J query is canceled if the timeout is exceeded.
  • Investigate Neo4J’s support for canceling timed-out queries. Per query timeout might be possible with apoc? . We can only use a global setting for timeout. That would make bigger queries difficult as well (e.g. reindexing will take long but we do not care so much).
CALL apoc.cypher.runTimeboxed("MATCH (n:Person{name:'Keanu Reeves'})-[*]-(other)
 RETURN count(*) as allPathsCount",
 {}, 20000)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions