Skip to content

feat(alloydb): add native read-only session locking - #3617

Merged
anubhav756 merged 1 commit into
feat/read-onlyfrom
anubhav-readonly-alloydb
Aug 27, 2026
Merged

anubhav756 merged 1 commit into
feat/read-onlyfrom
anubhav-readonly-alloydb

Conversation

@anubhav756

@anubhav756 anubhav756 commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR implements native, protocol-level Read-Only session enforcement for AlloyDB for PostgreSQL.

Changes

  • Appends options='-c alloydb_session_read_only=locked' to the connection DSN when readOnly: true is configured on the source.
  • Added ReadOnly bool to alloydbpg.Config and implemented IsReadOnly() bool on alloydbpg.Source.
  • Updated prebuilt configuration templates (alloydb-postgres.yaml and alloydb-postgres-admin.yaml) to dynamically resolve read-only mode via the ALLOYDB_READONLY environment variable (readonly: ${ALLOYDB_READONLY:false}).
  • Leverages AlloyDB's native session-lockout flag to block physical Transaction ID (XID) allocation, guaranteeing that all DML/DDL write operations, transaction breakout attempts (COMMIT; START TRANSACTION READ WRITE;), and mutating stored procedures fail-closed at the engine layer.
  • Added unit tests, integration vulnerability tests, and updated integration documentation.

@anubhav756 anubhav756 self-assigned this Jul 14, 2026

@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 a read-only mode for the AlloyDB PostgreSQL source by setting the alloydb_session_read_only=locked session parameter, and adds a corresponding read-only SQL execution tool. It also includes an integration test to verify that write operations are blocked in this mode. The review feedback suggests clarifying the documentation to explain that read-only mode is enforced via session state rather than physical endpoint routing, and improving the integration test's robustness by checking for alternative spelling formats of the read-only error message.

Comment thread docs/ALLOYDBPG_README.md Resolved
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch 2 times, most recently from a975dc7 to efeaaa2 Compare July 14, 2026 07:31
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from 410930e to 071a167 Compare July 14, 2026 07:32
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch from efeaaa2 to c638838 Compare July 14, 2026 07:36
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from 071a167 to 345cb7f Compare July 14, 2026 08:14
@anubhav756

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 a read-only mode for the AlloyDB PostgreSQL source, allowing users to enforce read-only session states on database connections to prevent write operations. It adds a new execute_sql_readonly prebuilt tool, updates the connection configuration to append the appropriate read-only session options, and includes an integration test to verify the write-blocking behavior. The feedback suggests documenting the new prebuilt tool in the README, centralizing the read-only option string into a constant, and refactoring the integration test to construct the configuration map directly in Go rather than unmarshaling a raw YAML string.

@anubhav756
anubhav756 marked this pull request as ready for review July 14, 2026 13:30
@anubhav756
anubhav756 requested review from a team as code owners July 14, 2026 13:30
@anubhav756 anubhav756 assigned Yuan325 and unassigned anubhav756 Jul 14, 2026
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch 2 times, most recently from bc19b9b to 21954fb Compare July 15, 2026 08:09
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch 6 times, most recently from c35957e to a6f8ff1 Compare July 20, 2026 14:36
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from 21954fb to be7f372 Compare July 20, 2026 15:07
@anubhav756
anubhav756 marked this pull request as draft July 20, 2026 15:50
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch 2 times, most recently from 4091cdd to 8011f00 Compare July 20, 2026 16:08
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from 302e833 to c51553a Compare August 10, 2026 19:31
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch from 6242771 to cc44835 Compare August 10, 2026 20:19
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from c51553a to 6dbd955 Compare August 10, 2026 20:19
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch from cc44835 to bf538b0 Compare August 10, 2026 20:29
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from 6dbd955 to 9ddedc4 Compare August 10, 2026 20:29
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch from bf538b0 to b058146 Compare August 10, 2026 20:35
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from 9ddedc4 to 05b7eff Compare August 10, 2026 20:35
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch 2 times, most recently from 3bcf247 to f9cc575 Compare August 10, 2026 21:19
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from 05b7eff to d6a5d68 Compare August 10, 2026 21:19
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch from f9cc575 to 50037a4 Compare August 10, 2026 21:52
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from d6a5d68 to ed2124b Compare August 10, 2026 21:52
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch from 50037a4 to bddc2c0 Compare August 11, 2026 02:59
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from ed2124b to fd283c5 Compare August 11, 2026 02:59
@anubhav756
anubhav756 force-pushed the anubhav-readonly-core branch from bddc2c0 to fd7a8e9 Compare August 11, 2026 03:06
@anubhav756
anubhav756 force-pushed the anubhav-readonly-alloydb branch from fd283c5 to 57a036c Compare August 11, 2026 03:06
Comment thread coverage.out Resolved
Comment thread docs/ALLOYDBADMIN_README.md Resolved
@github-actions

Copy link
Copy Markdown
Contributor

🧨 Preview deployments removed.

Cloudflare Pages environments for pr-3617 have been deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants