Repository navigation
Conversation
Multi-region Spanner databases can migrate write leadership online using ALTER DATABASE ... SET OPTIONS (default_leader = ...) via UpdateDatabaseDdl. Add spanner_update_database_with_default_leader.
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new script and associated tests to update a Google Cloud Spanner database's default leader using DDL statements. Specifically, it adds update_database_with_default_leader.py which contains the logic to execute the ALTER DATABASE statement and handle potential errors, alongside a CLI entry point. It also adds comprehensive unit and live tests in update_database_with_default_leader_test.py to verify the functionality. There are no review comments, and I have no additional feedback to provide.
…_default_leader Problem: multi-line SQL and DDL statements were written as adjacent string fragments. That style is easy to get wrong (a missing trailing space joins two SQL tokens) and is harder to read than the statement itself, and the samples in this set mixed it with triple-quoted SQL. Solution: write each multi-line statement as a single triple-quoted string, matching the layout already used by the other samples. Only whitespace between SQL tokens changes; the statements are otherwise identical. Files updated: - spanner/database_admin/src/spanner_database_admin/update_database_with_default_leader.py
…t_leader Problem: review of this sample identified correctness and robustness improvements in the sample and its tests. Solution: apply the accepted review suggestions and extend the tests to cover the updated behavior. Details are in the review thread replies. Files updated: - spanner/database_admin/tests/update_database_with_default_leader_test.py
Description
Adds
spanner_update_database_with_default_leaderupdating thedefault_leaderoption on an existing multi-region database.Checklist
Testing
Compliance & Style
spanner/, which the default repository owners cover.Post-Approval Actions