This page describes how to upgrade the database major version by upgrading your Cloud SQL instance in-place rather than by migrating data.
IntroductionDatabase software providers periodically release new major versions that contain new features, performance improvements, and security enhancements. Cloud SQL takes in new versions after they're released. After Cloud SQL offers support for a new major version, you can upgrade your instances to keep your database updated.
You can upgrade the database version of an instance in-place or by migrating data. In-place upgrades are a simpler way to upgrade your instance's major version. You don't need to migrate data or change application connection strings. With in-place upgrades, you can retain the name, IP address, and other settings of your current instance after the upgrade. In-place upgrades don't require you to move data files and can be completed faster. In some cases, the downtime is shorter than what migrating your data entails.
The Cloud SQL for the PostgreSQL in-place upgrade operation uses the
pg_upgrade
utility.
Plan a major version upgradeChoose a target major version.
gcloudFor information about installing and getting started with the gcloud CLI, see Install the gcloud CLI. For information about starting Cloud Shell, see Use Cloud Shell.
To check the database versions that you can target for an in-place upgrade on your instance, do the following:
gcloud sql instances describe INSTANCE_NAME
Replace INSTANCE_NAME with the name of the instance.
upgradableDatabaseVersions
.majorVersion
: the major version that you can target for the in-place upgrade.name
: the database version string that includes the major version.displayName
: the display name for the database version.To check which target database versions are available for a major version in-place upgrade, use the instances.get
method of the Cloud SQL Admin API.
Before using any of the request data, make the following replacements:
HTTP method and URL:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell) Note: The following command assumes that you have logged in to thegcloud
CLI with your user account by running gcloud init
or gcloud auth login
, or by using Cloud Shell, which automatically logs you into the gcloud
CLI . You can check the currently active account by running gcloud auth list
.
Execute the following command:
curl -X GET \PowerShell (Windows) Note: The following command assumes that you have logged in to the
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME"
gcloud
CLI with your user account by running gcloud init
or gcloud auth login
. You can check the currently active account by running gcloud auth list
.
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
upgradableDatabaseVersions: { major_version: "POSTGRES_15_0" name: "POSTGRES_15_0" display_name: "PostgreSQL 15.0" }REST v1beta4
To check which target database versions are available for major version in-place upgrade of an instance, use the instances.get
method of the Cloud SQL Admin API.
Before using any of the request data, make the following replacements:
HTTP method and URL:
GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_NAME
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell) Note: The following command assumes that you have logged in to thegcloud
CLI with your user account by running gcloud init
or gcloud auth login
, or by using Cloud Shell, which automatically logs you into the gcloud
CLI . You can check the currently active account by running gcloud auth list
.
Execute the following command:
curl -X GET \PowerShell (Windows) Note: The following command assumes that you have logged in to the
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_NAME"
gcloud
CLI with your user account by running gcloud init
or gcloud auth login
. You can check the currently active account by running gcloud auth list
.
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_NAME" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
upgradableDatabaseVersions: { major_version: "POSTGRES_15_0" name: "POSTGRES_15_0" display_name: "PostgreSQL 15.0" }
For the complete list of the database versions that Cloud SQL supports, see Database versions and version policies.
Consider the features offered in each database major version and address incompatibilities.
New major versions introduce incompatible changes that might require you to modify the application code, the schema, or the database settings. Before you can upgrade your database instance, review the release notes of your target major version to determine the incompatibilities that you must address.
Test the upgrade with a dry run.
Perform a dry run of the end-to-end upgrade process in a test environment before you upgrade the production database. You can clone your instance to create an identical copy of the data on which to test the upgrade process.
In addition to validating that the upgrade completes successfully, run tests to ensure that the application behaves as expected on the upgraded database.
Note: Ensure that you have enough disk space before running a major version upgrade. If you haven't enabled automatic storage increases, take note of the disk storage used by the upgraded dry run instance. This helps you determine whether you need to increase the storage capacity for the production instance before upgrading.Decide on a time to upgrade.
Upgrading requires the instance to become unavailable for a period of time. Plan to upgrade during a time period when database activity is low.
Before you upgrade, complete the following steps.
Check the LC_COLLATE
value for the template
and postgres
databases. The character set for each database must be en_US.UTF8
.
If the LC_COLLATE
value for the template
and postgres
databases isn't en_US.UTF8
, then the major version upgrade fails. To fix this, if either database has a character set other than en_US.UTF8
, then change the LC_COLLATE
value to en_US.UTF8
before you perform the upgrade.
To change the encoding of a database:
en_US.UTF8
).Another option is to rename the database:
We recommend that you perform these steps on a cloned instance before applying them to a production instance.
Manage your remaining PostgreSQL extensions.
Most extensions work on the upgraded database major version. Drop any extensions that are no longer supported in your target version. For example, drop the chkpass
extension if you're upgrading to PostgreSQL 11 or later versions.
You can upgrade PostGIS and its related extensions to their latest supported versions manually.
Sometimes, upgrading from PostGIS versions 2.x can create a situation where there are leftover database objects that aren't associated with the PostGIS extension. This can block the upgrade operation. For information about resolving this issue, see Fixing a broken postgis raster install.
Sometimes, upgrading to PostGIS version 3.1.7 or later can't complete due to objects using deprecated functions. This can block the upgrade operation. To check the upgrade status, run SELECT PostGIS_full_version();
. If there are warnings present, then drop any objects using the deprecated functions and update the PostGIS extension to any intermediate or higher version. After you complete these actions, run the SELECT PostGIS_full_version();
command again. Verify that no warnings appear. Then, proceed with the upgrade operation.
datallowconn
field for each database to ensure that a connection is allowed. A t
value means that it's allowed, and an f
value indicates that a connection can't be established.The following limitations affect in-place major version upgrades for Cloud SQL for PostgreSQL:
select * from pg_largeobject_metadata;
statement to query for the number of large objects in each PostgreSQL database of your Cloud SQL instance. If the result from all of your databases is more than 10 million large objects, then the upgrade fails. Cloud SQL rolls back to the previous version of your database.rdkit
extension for all of your databases to version 4.6.1.If you install the pg_ivm
or pg_squeeze
extensions for your instance, then you can't perform a major version upgrade. To fix this, uninstall these extensions and then perform the upgrade. For more information about the extensions, see Configure PostgreSQL extensions.
pg_squeeze
extension.If you enable the vacuum_defer_cleanup_age and force_parallel_mode flags, then you can't perform a major version upgrade. To fix this, delete these flags and then perform the upgrade. For more information about the flags, including how to delete them, see Configure database flags.
Note: For PostgreSQL 16 and later, thevacuum_defer_cleanup_age
flag is deprecated and the force_parallel_mode
flag is renamed to debug_parallel_query
. You can upgrade the major version of a single Cloud SQL instance, or you can upgrade the major version of a primary instance and include all of its replicas in the upgrade, including cascading replicas and cross-region replicas.
Upgrade the major version of a single instanceWhen you initiate an upgrade operation for a single instance, Cloud SQL does the following:
In the Google Cloud console, go to the Cloud SQL Instances page.
Verify that the upgraded database major version appears below the instance name on the instance Overview page.
gcloudStart the upgrade.
Use the gcloud sql instances patch
command with the --database-version
flag.
Before running the command, replace the following:
gcloud sql instances patch INSTANCE_NAME \ --database-version=DATABASE_VERSION
Major version upgrades take several minutes to complete. You might see a message indicating that the operation is taking longer than expected. You can either ignore this message or run the gcloud sql operations wait
command to dismiss the message.
Get the upgrade operation name.
Use the gcloud sql operations list
command with the --instance
flag.
Before running the command, replace the INSTANCE_NAME variable with the name of the instance.
gcloud sql operations list --instance=INSTANCE_NAME
Monitor the status of the upgrade.
Use the gcloud sql operations describe
command.
Before running the command, replace the OPERATION variable with the upgrade operation name retrieved in the previous step.
gcloud sql operations describe OPERATION
Start the in-place upgrade.
Use a PATCH request with the instances:patch
method.
Before using any of the request data, replace these variables:
HTTP method and URL:
PATCH https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME
Request JSON body:
{ "databaseVersion": DATABASE_VERSION }
Replace DATABASE_VERSION with the enum for the database major version, which must be later than the current version. Specify a database version for a major version that is available as an upgrade target for the instance. You can obtain this enum as the first step of Plan for upgrade. If you need a full list of database version enums, then see SqlDatabaseVersion.
Get the upgrade operation name.
Use a GET request with the operations.list
method after replacing PROJECT_ID with the ID of the project.
HTTP method and URL:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations
Monitor the status of the upgrade.
Use a GET request with the operations.get
method after replacing the following variables:
HTTP method and URL:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operation/OPERATION_NAME
To update the version of the database, use a Terraform resource and the Terraform provider for Google Cloud, version 4.34.0 or later.
Apply the changesTo apply your Terraform configuration in a Google Cloud project, complete the steps in the following sections.
Prepare Cloud ShellSet the default Google Cloud project where you want to apply your Terraform configurations.
You only need to run this command once per project, and you can run it in any directory.
export GOOGLE_CLOUD_PROJECT=PROJECT_ID
Environment variables are overridden if you set explicit values in the Terraform configuration file.
Each Terraform configuration file must have its own directory (also called a root module).
.tf
extension—for example main.tf
. In this tutorial, the file is referred to as main.tf
.
mkdir DIRECTORY && cd DIRECTORY && touch main.tf
If you are following a tutorial, you can copy the sample code in each section or step.
Copy the sample code into the newly created main.tf
.
Optionally, copy the code from GitHub. This is recommended when the Terraform snippet is part of an end-to-end solution.
terraform init
Optionally, to use the latest Google provider version, include the -upgrade
option:
terraform init -upgrade
terraform plan
Make corrections to the configuration as necessary.
yes
at the prompt:
terraform apply
Wait until Terraform displays the "Apply complete!" message.
To delete your changes, do the following:
deletion_protection
argument to false
.
deletion_protection = "false"
yes
at the prompt:
terraform apply
Remove resources previously applied with your Terraform configuration by running the following command and entering yes
at the prompt:
terraform destroy
When you place an in-place upgrade request, Cloud SQL first performs a pre-upgrade check. If Cloud SQL determines that your instance isn't ready for an upgrade, then your upgrade request fails with a message suggesting how you can address the issue. See also Troubleshoot a major version upgrade.
Note: Cloud SQL automatically provisions your instance on the default minor version. Include replicas in the major version upgradeIf your primary instance has replicas, then you can include all replicas in the upgrade. Cloud SQL can upgrade all replicas of the primary instance, including cross-region replicas and cascading replicas.
When you include replicas in a major version upgrade, Cloud SQL does the following:
Even if the major version upgrade of a replica fails, the primary instance continues to be available.
To include replicas in a major version upgrade, you can't use the Google Cloud console or Terraform. You can only use gcloud CLI or the Cloud SQL Admin API.
gcloudStart the upgrade.
Use the gcloud sql instances patch
command with the --database-version
and the --include-replicas-for-major-version-upgrade
flags.
Before running the command, replace the following:
gcloud sql instances patch INSTANCE_NAME \ --database-version=DATABASE_VERSION \ --include-replicas-for-major-version-upgrade
Major version upgrades take several minutes to complete. You might see a message indicating that the operation is taking longer than expected. You can either ignore this message or run the gcloud sql operations wait
command to dismiss the message. Upgrading replicas can take several minutes to complete. To check the status of the upgrade, do the following:
Get the upgrade operation name.
Use the gcloud sql operations list
command with the --instance
flag.
Before running the command, replace the INSTANCE_NAME variable with the name of the instance.
gcloud sql operations list --instance=INSTANCE_NAME
Monitor the status of the upgrade.
Use the gcloud sql operations describe
command.
Before running the command, replace the OPERATION variable with the upgrade operation name retrieved in the previous step.
gcloud sql operations describe OPERATION
Start the in-place upgrade.
Use a PATCH request with the instances:patch
method.
Before using any of the request data, replace these variables:
HTTP method and URL:
PATCH https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME
Request JSON body:
{ "databaseVersion": DATABASE_VERSION "includeReplicasForMajorVersionUpgrade": true }
includeReplicasForMajorVersionUpgrade
field, specify true
.Get the upgrade operation name.
Use a GET request with the operations.list
method after replacing PROJECT_ID with the ID of the project.
HTTP method and URL:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations
Monitor the status of the upgrade.
Use a GET request with the operations.get
method after replacing the following variables:
HTTP method and URL:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operation/OPERATION_NAME
When you perform a major version upgrade, Cloud SQL automatically makes two on-demand backups, called upgrade backups:
When you view your list of backups, the upgrade backups are listed with type On-demand
. Upgrade backups are labeled so that you can identify them quickly. For example, if you're upgrading from PostgreSQL 14 to PostgreSQL 15, your pre-upgrade backup is labeled Pre-upgrade backup, POSTGRES_14 to POSTGRES_15.
and your post-upgrade backup is labeled Post-upgrade backup, POSTGRES_14 to POSTGRES_15.
As with other on-demand backups, upgrade backups persist until you delete them or delete the instance. If you have PITR enabled, you can't delete your upgrade backups while they're in your retention window. If you need to delete your upgrade backups, you must disable PITR or wait until your upgrade backups are no longer in your retention window.
Complete the major version upgradeAfter you finish upgrading your primary instance, perform the following steps to complete your upgrade:
Refresh the database statistics.
Run ANALYZE
on your primary instance to update the system statistics after the upgrade. Accurate statistics make sure that the PostgreSQL query planner processes queries optimally. Missing statistics can lead to bad query plans, which in turn might degrade performance and take up excessive memory.
Perform acceptance tests.
Run tests to make sure that the upgraded system performs as expected.
Cloud SQL returns an error message if you attempt an invalid upgrade command, for example, if your instance contains invalid database flags for the new version.
If your upgrade request fails, check the syntax of your upgrade request. If the request has a valid structure, try looking into the following suggestions.
View pre-upgrade check failuresPre-upgrade check failures are issues or errors that Cloud SQL detects during the pre-upgrade verification or validation process. These failures occur before the actual upgrade process begins and are meant to identify potential problems or incompatibilities that can affect the success of the upgrade.
Pre-upgrade check failures are displayed for the following categories:
The following table lists pre-upgrade check failures and their error messages:
Pre-upgrade check failure Error message Cloud SQL detects an unknown data type.Please remove the following usages of 'Unknown' data types before attempting an upgrade: (database: db_name, relation: rel_name, attribute: attr_name)
When upgrading to PostgreSQL 12 or later versions, Cloud SQL detects the 'sql_identifier'
data type. Please remove the following usages of 'sql_identifier' data types before attempting an upgrade: (database: db_name, relation: rel_name, attribute: attr_name)
Cloud SQL detects the reg*
data type. Please remove the following usages of 'reg*' data types before attempting an upgrade: (database: db_name, relation: rel_name, attribute: attr_name)
Cloud SQL detects that the
LC_COLLATE
value for the postgres
database is a character set that's other than en_US.UTF8
. Please change the 'LC_COLLATE' value of the postgres database to 'en_US.UTF8' before attempting an upgrade
Cloud SQL detects tables that have object identifiers (OIDs). Please remove the following usages of tables with OIDs before attempting an upgrade: (database: db_name, relation: rel_name)
Cloud SQL detects composite data types. Please remove the following usages of 'composite' data types before attempting an upgrade: (database: db_name, relation: rel_name, attribute: attr_name)
Cloud SQL detects user-defined postfix operators. Please remove the following usages of 'postfix operators' before attempting an upgrade: (database: db_name, operation id: op_id, operation namespace: op_namespace, operation name: op_name, type namespace: type_namespace, type name: type_name)
Cloud SQL detects incompatible polymorphic functions. Please remove the following usages of 'incompatible polymorphic' functions before attempting an upgrade: (database: db_name, object kind: obj_kind, object name: obj_name)
Cloud SQL detects user-defined encoding conversions. Please remove the following usages of user-defined encoding conversions before attempting an upgrade: (database: db_name, namespace name: namespace_name, encoding conversions name: encod_name)
Cloud SQL detects empty search path for function ll_to_earth
Please update the search path of the 'll_to_earth' function
Cloud SQL detects the presence of unpacked PostGIS raster files. PostGIS version upgrade has not been completed, unpackaged raster files present. Follow the steps at https://postgis.net/documentation/tips/tip-removing-raster-from-2-3/ to fix before major version upgrade.
Fix the empty search path issue
This happens because the earthdistance
extension uses earth and cube types without specifying the search path of the function. You must specify this path which is required during the upgrade process.
To resolve this issue, fix the search path for the ll_to_earth
function by running this query: ALTER FUNCTION ll_to_earth SET search_path = public;
If any issues occur with a valid upgrade request, then Cloud SQL publishes error logs to projects/PROJECT_ID/logs/cloudsql.googleapis.com%2Fpostgres-upgrade.log
. Each log entry contains a label with the instance identifier to help you identify the instance with the upgrade error. Look for such upgrade errors and resolve them.
To view error logs, use the Google Cloud console::
In the Google Cloud console, go to the Cloud SQL Instances page.
In the Operations and logs pane of the instance Overview page, click the View PostgreSQL error logs link.
The Logs Explorer page opens.
View logs as follows:
For more information on query filters, see Advanced queries.
DATABASE_ID
with the project ID followed by the instance name in this format: project_id:instance_name
.
resource.type="cloudsql_database" resource.labels.database_id="DATABASE_ID" logName : "projects/PROJECT_ID/logs/cloudsql.googleapis.com%2Fpostgres-upgrade.log"
For example, to filter the upgrade error logs by an instance named shopping-db
running in the project buylots
, use the following query filter:
resource.type="cloudsql_database" resource.labels.database_id="buylots:shopping-db" logName : "projects/buylots/logs/cloudsql.googleapis.com%2Fpostgres-upgrade.log"
You can either review all logs reported within a given timeframe, or you can filter logs by severity. A common option for troubleshooting might include selecting the following filters:
Log entries with the pg_upgrade_dump
prefix indicate that an upgrade error had occurred. For example:
pg_upgrade_dump: error: query failed: ERROR: out of shared memory
HINT: You might need to increase max_locks_per_transaction.
Additionally, log entries labeled with a .txt
secondary filename might list other errors that you might want to resolve before attempting the upgrade again.
All filenames are found in the postgres-upgrade.log
file. To locate a filename, look at the labels.FILE_NAME
field.
Filenames that might contain errors to resolve include:
tables_with_oids.txt:
This file contains tables that are listed with object identifiers (OIDs). Either delete the tables or modify them so that they don't use OIDs.tables_using_composite.txt:
This file contains tables that are listed using system-defined composite types. Either delete the tables or modify them so that they don't use these composite types.tables_using_unknown.txt:
This file contains tables that are listed using the UNKNOWN
data type. Either delete the tables or modify them so that they don't use this data type.tables_using_sql_identifier.txt:
This file contains tables that are listed using the SQL_IDENTIFIER
data type. Either delete the tables or modify them so that they don't use this data type.tables_using_reg.txt:
This file contains tables that are listed using the REG*
data type (for example, REGCOLLATION
or REGNAMESPACE
). Either delete the tables or modify them so that they don't use this data type.postfix_ops.txt:
This file contains tables that are listed using postfix (right-unary) operators. Either delete the tables or modify them so that they don't use these operators.If the instance has insufficient shared memory, you might see this error message: ERROR: out of shared memory.
This error is more likely to occur if you have in excess of 10,000 tables.
Before you attempt an upgrade, set the value of the max_locks_per_transaction
flag to approximately twice the number of tables in the instance. The instance is restarted when you change the value of this flag.
If your instance has insufficient connection capacity, you might see this error message: ERROR: Insufficient connections.
Cloud SQL recommends that you increase the max_connections
flag value by the number of databases in your instance. The instance is restarted when you change the value of this flag.
If you have an ambiguous column reference in your views, then you might see this error message: ERROR: column reference "<column_name>" is ambiguous
. This issue occurs when a new PostgreSQL version introduces changes to the structure of system catalog views such as pg_stat_activity
and pg_stat_replication
. This can disrupt custom views that rely on the column order.
To check for this error message, add this query to the query editor: textPayload =~ "ERROR: column reference .+ is ambiguous at character \d+"
You can resolve this issue in the following ways:
Adapt your custom views.
Update the column references in your custom views to align with the new system catalog view (such as pg_stat_activity
and pg_stat_replication
) definition in the target PostgreSQL version.
Recreate your views.
Drop your custom views before performing a major version upgrade. Recreate the views after the upgrade is complete, ensuring that they're compatible with the new structure.
For a more-detailed example of the problem and further insights, see this stack overflow discussion
Check for SRFs in CASE statementsIf you are upgrading your instance from version 9.6 and using set returning functions in your CASE statements, then you might see this error message ERROR: set-returning functions are not allowed in CASE
. This issue occurs as from version 10 onwards using set-returning functions in CASE statements is disallowed.
To resolve this issue and upgrade your instance successfully, ensure that any CASE statements utilizing set-returning functions are modified to avoid their use before retrying the upgrade. Some commonly used SRFs include the following:
If you have a view created on a custom cast, then an error message similar to the following appears: ERROR: cannot cast type <type_1> to <type_2>
. This issue occurs because of permission issues on custom created casts.
To resolve this issue, update your instance to [PostgreSQL version].R20240910.01_02
For more information, see Self-service maintenance.
Check event trigger ownershipIf an event trigger is owned by a user who lacks the cloudsqlsuperuser role, you might get an error message such as ERROR: permission denied to change owner of event trigger "<trigger_name>"
. This issue is caused due to permission issues while trying to recreate these triggers during upgrade. You can use add the following query in the query editor to check for this error message textPayload =~ "ERROR: permission denied to change owner of event trigger .+ "
To address this, verify the ownership of all event triggers within your instance. Ensure that the owner of each trigger is a cloudsqlsuperuser. If any triggers are owned by other users, update their ownership to a cloudsqlsuperuser before attempting the upgrade again. You can use the following query to change ownership ALTER EVENT TRIGGER <trigger_name> OWNER TO <cloudsqlsuperuser>;
You can use the following query to get a list of event triggers and the owner details SELECT evtname AS trigger_name, evtowner::regrole AS owner FROM pg_event_trigger;
If you have an unlogged table which has generated columns you might see the error message ERROR: unexpected request for new relfilenumber in binary upgrade mode
. This issue occurs due to discrepancies in the persistence characteristics between tables and their sequences for generated columns.
To address this issue, do the following:
ALTER TABLE SET LOGGED;
ALTER TABLE SET UNLOGGED
You can identify all such tables by using the following query :
SELECT relnamespace::regnamespace, c.relname AS table_name, a.attname AS column_name, a.attidentity AS identity_type FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid WHERE a.attidentity IN ('a', 'd') AND c.relkind = 'r' AND c.relpersistence = 'u' ORDER BY c.relname, a.attname;Check the custom flags for your PostgreSQL instance
If you're upgrading to a PostgreSQL instance, version 14 or higher, then check the names of any custom database flags that you configured for the instance. This is because PostgreSQL placed additional restrictions on allowed names for custom parameters.
The first character of a custom database flag must be alphabetic (A-Z or a-z). All subsequent characters can be alphanumeric, the underscore (_) special character, or the dollar sign ($) special character.
Remove extensionsIf you're upgrading your Cloud SQL instance, then you might see this error message: pg_restore: error: could not execute query: ERROR: role "16447" does not exist
.
To resolve this issue, follow these steps:
pg_stat_statements
and pgstattuple
extensions.If your upgraded database system doesn't perform as expected, then you might need to restore your primary instance to the previous version. You do so by restoring your pre-upgrade backup to a Cloud SQL recovery instance, which is a new instance running the pre-upgrade version.
To restore a primary instance to the previous version, perform the following steps:
Identify your pre-upgrade backup.
Create a recovery instance.
Create a new Cloud SQL instance using the major version that Cloud SQL was running when the pre-upgrade backup was made. Set the same flags and instance settings that the original instance uses.
Restore your pre-upgrade backup.
Restore your pre-upgrade backup to the recovery instance. This might take several minutes to complete.
Add your read replicas.
If you're using read replicas, then add the read replicas individually.
Connect your application.
Having recovered your database system, update your application with details about the recovery instance and its read replicas. You can resume serving traffic on the pre-upgrade version of your database.
The following questions might come up when upgrading the database major version.
Upgrading a single instance typically takes less than 10 minutes. If your instance configuration has a small number of vCPUs or memory, then your upgrade might take more time.
If your instance hosts too many databases or tables, or your databases are very large, then the upgrade might take hours or even time out because the total upgrade time corresponds to the number of objects in your databases. If you have multiple instances that need to be upgraded, then your upgrade time increases proportionately. If you include replicas in your upgrade, then the upgrade operation can take up to an hour to complete, depending on the number of replicas that your primary instance has.
When you perform an in-place major version upgrade, Cloud SQL retains your database settings, including your instance name, IP address, explicitly configured flag values, and user data. However, the default value of the system variables might change. For example, the default value of the password_encryption
flag in PostgreSQL 13 and earlier is md5
. When you upgrade to PostgreSQL 14, the default value of this flag changes to scram-sha-256
.
To learn more, see Configure database flags. If a certain flag or value is no longer supported in your target version, then Cloud SQL automatically removes the flag during the upgrade.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4