Skip to content

feat: migrate last DDL operation ID to connection state - #948

Open
olavloite wants to merge 1 commit into
mainfrom
migrate-last-ddl-operation-id
Open

olavloite wants to merge 1 commit into
mainfrom
migrate-last-ddl-operation-id

Conversation

@olavloite

Copy link
Copy Markdown
Collaborator

Move the tracking of the last executed DDL operation ID from an internal connection field into the connection state as a read-only property.

Previously, the operation ID was stored in an unmanaged private field on the connection. As a result, the value was not cleared when a connection was returned to the connection pool and reset, which could leak stale operation IDs to subsequent queries reusing that pooled connection.

With this change:

  • The last DDL operation ID is stored in connection state as the read-only property last_ddl_operation_id.
  • Applications can inspect the value using SHOW VARIABLE last_ddl_operation_id or via the LastDDLOperationID() method on the Spanner connection interface.
  • Direct modifications via SET are rejected because the property is read-only.
  • The property is automatically cleared whenever the session is reset, preventing operation IDs from leaking across pooled connections.

Move the tracking of the last executed DDL operation ID from an internal
connection field into the connection state as a read-only property.

Previously, the operation ID was stored in an unmanaged private field on the
connection. As a result, the value was not cleared when a connection was
returned to the connection pool and reset, which could leak stale operation IDs
to subsequent queries reusing that pooled connection.

With this change:
- The last DDL operation ID is stored in connection state as the read-only
  property `last_ddl_operation_id`.
- Applications can inspect the value using `SHOW VARIABLE last_ddl_operation_id`
  or via the `LastDDLOperationID()` method on the Spanner connection interface.
- Direct modifications via `SET` are rejected because the property is read-only.
- The property is automatically cleared whenever the session is reset, preventing
  operation IDs from leaking across pooled connections.
@olavloite
olavloite requested a review from a team as a code owner November 6, 2026 14:06

@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 introduces the last_ddl_operation_id connection property as a read-only connection property bound to connectionstate.ConnectionState. It updates the SpannerConn interface to include LastDDLOperationID(), replaces the direct lastDDLOperationID field access on the private conn struct with state-backed getter and setter methods, and updates DDL execution paths to use these new methods. Additionally, it adds unit and integration tests to verify the behavior of the new property, including its reset behavior and visibility via SHOW VARIABLE. There are no review comments, and I have no feedback to provide.

@olavloite
olavloite requested a review from rahul2393 November 6, 2026 14:08

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