Lazy inject database into session manager

Created on 17 August 2025, about 2 months ago

Problem/Motivation

Child of 📌 Explore using more service closures to break deep dependency chains and load fewer services Active

I confirmed this from @catch in the meta issue:

session -> session_manager -> database -> session_manager.metadata_bag

We should be able to avoid creating a database connection until we know we have a session cookie to check against. Dynamic page cache hits for anonymous users can theoretically be served without touching the database at all. Auth can if the an alternative session storage is used.

Using redis and a dynamic page cache hit as an anonymous user has no actual queries but still starts up the database connection.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component

base system

Created by

🇨🇭Switzerland berdir Switzerland

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @berdir
  • Merge request !13014Experimenting with database service closure → (Open) created by berdir
  • 🇨🇭Switzerland berdir Switzerland

    This turned out to be a major rabbit hole. I wanted to see where it goes, but it won't be possible to get this done like this, not in one issue.

    Sure, it started with SessionManager, and then two related services, session storage and cookie authentication provider.

    But then it escalated into config storage, state, various routing things, node grants, menu storage and path alias stuff.

    I almost made it through, but wasn't quite sure how to deal with the path alias outbound through the url generator, so stopped there.

    Also, it gets more complicated on pages not being the frontpage and pages having aliases/entities, then entity storage also gets involved and so on.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 312s
    #574783
Production build 0.71.5 2024