Skip to content

fix(spanner): honor session and pool database_role when creating sessions - #19273

Draft
sinhasubham wants to merge 1 commit into
mainfrom
fix-spanner-session-database-role
Draft

sinhasubham wants to merge 1 commit into
mainfrom
fix-spanner-session-database-role

Conversation

@sinhasubham

Copy link
Copy Markdown
Contributor

Notes

Ensure fine-grained access control (FGAC) database_role precedence (session > pool > database) is consistently applied across all session creation paths in both sync and async clients.

Fixes https://b.corp.google.com/issues/588631669

Validation

Added tests to replicate and catch the issue

…ions

Ensure fine-grained access control (FGAC) database_role precedence
(session > pool > database) is consistently applied across all session
creation paths in both sync and async clients:

- Session.create(): resolve creator_role from self._database_role or
  database.database_role instead of ignoring self._database_role, omit
  the empty session submessage when unset/empty, and keep
  self._database_role in sync after successful creation when falling
  back to database.database_role.
- DatabaseSessionsManager._build_multiplexed_session(): resolve
  database_role from getattr(self._pool, 'database_role', None) or
  self._database.database_role so multiplexed sessions match
  non-multiplexed session pools.
- Database.session(): resolve database_role from the explicit argument,
  then pool.database_role, then self._database_role.
- Regenerate sync modules via CrossSync and add sync/async unit and
  mockserver regression tests.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the database_role resolution logic across sessions, databases, and session managers for both synchronous and asynchronous implementations. Specifically, it ensures that when creating a session, the database_role is resolved with the following precedence: explicitly provided session role, pool's database_role, and finally the database's database_role. It also updates multiplexed sessions to respect the pool's database_role and adds extensive unit and mock server tests to verify these precedence rules. There are no review comments, and I have no feedback to provide.

This branch has not been deployed

No deployments
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.

1 participant