Skip to content

Implement Database-Backed Session Storage (DatabaseSessionService) for ADK Java #665

Description

@prasadskarmarkar

ADK Java currently provides only in-memory session storage, which is not suitable for production environments that require durable, consistent, and queryable session/state/event storage.

Projects building on ADK often need:

  • Persistent session storage across restarts
  • Reliable event logging and retrieval
  • Concurrency-safe updates
  • Support for standard relational databases
  • Schema versioning for continuous delivery

Describe the solution you'd like

Introduce a production-ready database-backed session service (DatabaseSessionService) that provides durable storage for sessions, events, and state.

Key characteristics:

  • Pure JDBC implementation with zero ORM dependencies
  • HikariCP connection pooling for high performance
  • Flyway migrations for schema versioning and zero-downtime deployments
  • Multi-database support: PostgreSQL, MySQL, H2, Cloud Spanner (SQLite not supported)
  • 3-tier state storage: Separate tables for app-level, user-level, and session-level state
  • Pessimistic locking for safe concurrent updates
  • Dialect-aware JSON handling (JSONB for PostgreSQL, JSON for MySQL, CLOB for others)
  • Reactive API with RxJava 3 (Single/Maybe/Completable)
  • Event filtering and pagination
  • Comprehensive test coverage using H2 and integration tests on actual databases (PostgreSQL, MySQL, Spanner) running in Docker

This service offers a robust, scalable alternative to the current in-memory session implementation without introducing heavy ORM dependencies.

Describe alternatives you've considered

Providing this as an external extension/library

  • Persistent sessions are commonly required; shipping this in-core provides a better out-of-the-box experience.

Continuing with in-memory storage only

  • Not viable for production deployments requiring durability or concurrency guarantees.

Using Hibernate/JPA

  • Adds significant dependency overhead and complexity; pure JDBC provides better control and performance.

Additional context

The Python ADK includes a production-grade DatabaseSessionService that is widely used in real-world workloads (including GKE deployments). Adding equivalent persistent session storage to ADK Java would
provide consistency across ADK environments and reduce the need for custom user-built solutions.

An implementation is available in PR: #700

Activity

  1. self-assigned this
    on Jan 14, 2026
  2. added 3 commits that reference this issue on Jan 16, 2026
    ee60ef8
    07e499e
    8bd47fd
  3. added a commit that references this issue on Feb 5, 2026
    9907827
  4. hemasekhar-p commented on May 29, 2026

    @hemasekhar-p
    Contributor

    Hi @prasadskarmarkar, Thank you for taking time and submitting this feature request and We appreciate you your contribution. It is currently under review by our team, and we will keep you posted if any additional information is required. thank you.

  5. hemasekhar-p commented on May 29, 2026

    @hemasekhar-p
    Contributor

    @krwc, Please have a look into it.

  6. added a commit that references this issue on Jul 30, 2026
    87e506f
  7. paulparkinson commented on Aug 24, 2026

    @paulparkinson

    Also interested in this feature, particularly Oracle Database support. I’ve added a note on #700 about possibly contributing Oracle support there or as a follow-up. Thanks!

  8. added a commit that references this issue on Aug 25, 2026
    19913c7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions