Skip to content

ADR 031: Homedb Cache (Bolt 5.8) #1115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jan 16, 2025
Merged

Conversation

robsdedude
Copy link
Member

@robsdedude robsdedude commented Nov 8, 2024

Introducing support for Bolt 5.8, which (among other things) makes the server echo back the resolved home/default db on starting a transaction as well as a connection hint whether server-side routing (SSR) is enabled. If so, the echoed db can be used together with an optimistic home db cache to guess a client-side route (optimistic routing - falling back to SSR on wrong guesses). This feature saves a round-trip under the following conditions (all must be fulfilled):

  • Server has SSR enabled
  • Sever supports Bolt 5.8
  • A fresh (yet unused) session without an explicitly configured target database starts its first transaction (auto-commit or explicit)
  • There is a cache entry for the current user.
    How exactly "current user" is defined is left as an implementation detail. Currently, this is in order of descending precedence:
    • the impersonated user if any
    • else the session auth token (for basic auth, only the principal is considered) if any
    • else some fallback key representing the driver-level user.

Depends on (re-run CI after merge):

@robsdedude robsdedude marked this pull request as ready for review December 16, 2024 14:26
Copy link
Contributor

@MaxAake MaxAake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Only checking the acquired connection for SSR support is sufficient for
correctness and saves checking the all connections in the pool (i.e., saves
taking the lock on the pool).
@robsdedude robsdedude enabled auto-merge (squash) January 16, 2025 14:31
@robsdedude robsdedude merged commit cb01e6e into neo4j:5.0 Jan 16, 2025
20 checks passed
@robsdedude robsdedude deleted the home-db-cache2 branch January 16, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants