Skip to content

Switch default value of Neo4j open session in view #20012

Closed
@michael-simons

Description

@michael-simons

The current default of "open session in view" for Spring Data Neo4j hurts performance in cluster scenarios.

By opening the session on the request, the session will be a general purpose session ("read write") and always go to the leader of a cluster, leaving all followers and read replicas unused. I have written down an analysis of the problem here Spring Data Neo4j, Neo4j-OGM and OSIV.

Neo4j-OGM doesn't have the issue of lazy loading and keeping the session up and running through the request only helps caching inside OGM.

If such a change is unappropriated for 2.3, I would like to see a better warning, for example

logger.warn("spring.data.neo4j.open-in-view is enabled by default."
    + "Therefore, database queries may be performed during view "
    + "rendering. It also prevent's chosing anything else than the leader in a cluster scenario. Explicitly configure "
   + "spring.data.neo4j.open-in-view to disable this warning");

Or, the best might even check if one or more bolt+routing respectively neo4j:// Uris have been configured and than according to that, choose a sane default.

So, I basically see three options:

  • Change the warning to be more drastic or
  • Change the default or
  • Change the default conditionally when there's one or more bolt+routing:// or neo4j:// uris or more than one bolt:// URI.

I could implement each one of them, but wanted to hear your opinion on that.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions