Troubleshoot mirrors¶
The following are known issues and limitations, with workarounds.
Postgres instance needs to be refreshed¶
create_mirror can fail on an existing Postgres instance with an error similar to:
This happens when the source instance predates the mirroring feature and doesn’t have the Postgres extensions that mirroring depends on.
Solution: Refresh the instance from the Postgres Manage options in Snowsight to install
the latest extensions, then retry create_mirror. See
prepare your Postgres instance
for details.
Mirror names are folded to lowercase¶
Mirror names containing uppercase letters are folded to lowercase.
This call will succeed, but will silently fold the mirror name to uppermirror.
Solution: Prefer lowercase characters in mirror names. For example, use mymirror instead
of MyMirror.
Target database names can’t be reused¶
After a database has been used as a mirror target, the same name can’t be reused for a new mirror, even if the mirror is dropped and the database itself is dropped.
Solution: Pick a new target_database name when creating a replacement mirror.
Active mirrors break if usage is revoked from the snowflake application¶
Apply runs will fail with error POSTGRES INSTANCE ... does not exist or not authorized if
the USAGE grant on the Postgres instance has been revoked from the snowflake application.
This can happen in two ways (see Roles and permissions):
- Explicit revoke:
REVOKE USAGE ON POSTGRES INSTANCE ... FROM APPLICATION SNOWFLAKE - Ownership transfer with
REVOKE CURRENT GRANTS: RunningGRANT OWNERSHIP ON POSTGRES INSTANCE ... TO ROLE ... REVOKE CURRENT GRANTSdrops all existing grants on the instance, including theUSAGEgrant that mirroring depends on.
Solution: Re-grant the privilege:
Changing a column type on a mirrored table fails¶
ALTER TABLE ... ALTER COLUMN ... TYPE is not supported on tables tracked by a mirror (see
DDL updates in $changes). Postgres rejects the statement with an error:
Solution: Build a new column in Postgres and migrate that data to the new type, instead of changing the column type.
Adding a virtual generated column to a mirrored table fails¶
ALTER TABLE ... ADD COLUMN ... GENERATED ALWAYS AS ... is not supported on tables tracked by a
mirror (see DDL updates in $changes). Postgres rejects the statement with an error:
Solution: To use a computed value alongside a mirrored table, create the equivalent expression as a view in Snowflake against the target table rather than as a generated column in Postgres.
CREATE MIRROR fails if max_ replication_ slots is too low¶
Each mirror uses one PostgreSQL replication slot. When the instance is close to the
max_replication_slots limit, which defaults to 10, CREATE MIRROR fails with:
Solution: Increase max_replication_slots and max_wal_senders together (the latter should
be set to at least the same value) using
server settings. Both settings require a
restart, so include APPLY IMMEDIATELY:
Granting postgres_ mirror_ admin fails¶
Granting the
postgres_mirror_admin role
fails with:
This error has two possible causes.
Cause 1: You ran the grant as ACCOUNTADMIN in an organization account. In an
organization account, the SNOWFLAKE application grants
postgres_mirror_admin to the GLOBALORGADMIN role, which sits above ACCOUNTADMIN in the role
hierarchy. ACCOUNTADMIN has no privilege on the application role, so ACCOUNTADMIN can’t grant the application role. Using
USE SECONDARY ROLES ALL doesn’t help unless your user also holds GLOBALORGADMIN.
Solution: Run the grant as GLOBALORGADMIN. You can grant the role to ACCOUNTADMIN or to a
custom role:
If you don’t know who holds GLOBALORGADMIN, run SHOW GRANTS OF ROLE GLOBALORGADMIN to see
which users have it.
Cause 2: The account is newly created. On newly created Snowflake accounts, the snowflake
application might not be fully provisioned immediately, so granting the role too soon fails.
Solution: Wait up to one hour after account creation before setting up mirroring. If the error persists after an hour, contact Snowflake Support.
Dropping the source Postgres database fails while mirrors are active¶
Postgres blocks dropping a database that has active snowflake_cdc replication slots:
Solution: Drop all mirrors on the database using drop_mirror, then drop the database.
Renaming the source database causes mirrors to fail¶
Renaming the source Postgres database on a mirrored instance is not supported. Doing so will cause existing mirrors to fail.
Solution: If you need to rename the database, drop existing mirrors first, rename the database, then create new mirrors.
Mirror re-snapshots all tables after a WAL-lag spike¶
If the Snowflake apply procedure falls behind and the write-ahead log (WAL) backlog grows beyond
max_slot_wal_keep_size, Postgres invalidates the replication slot to prevent the instance
disk from filling. Mirroring detects the invalidated slot and automatically re-snapshots all
tables 10 minutes later.
Symptoms:
- All mirrored tables revert to
SNAPSHOTTINGstatus without an explicitRESTART_MIRRORcall. - The
$changesfeed is rebuilt from a fresh snapshot baseline, losing incremental change history.
Solutions:
- Increase disk size.
max_slot_wal_keep_sizedefaults to one-tenth of the allocated disk. A larger disk raises the effective WAL retention limit without changing any parameter. See Modify an instance. - Increase
max_slot_wal_keep_sizedirectly. Adjust the value using server settings. Set it high enough to cover the longest expected apply lag for your workload.
Alert debugging¶
Alert doesn’t fire¶
The following conditions look correct but never match and therefore fail silently:
- The owning role doesn’t own any Postgres instance, so
list_mirrorsreturns nothing. statuswasNULLand the predicate used<> 'ACTIVE'—NULL <> 'ACTIVE'evaluates toNULL, notTRUE.last_operation_timewasNULLand the predicate had only a time comparison — without anIS NULLbranch, the mirror that has been failing since creation is the one the alert can’t see.- The condition required consecutive failed task runs — runs skipped by the failure backoff are recorded as successes and break the streak.
- A
TIMESTAMP_NTZcolumn was compared againstCURRENT_TIMESTAMP()— in a US-Pacific session this shifts the threshold by 420 minutes, so a 30-minute staleness test stays quiet for over seven hours. UseSYSDATE()instead.
Run the condition query on its own, as the owning role, before assuming the alert is at fault.
Alert fires when the mirror is healthy¶
If the condition reads last_apply_time and something has called refresh_mirror,
the alert may fire on a healthy mirror. refresh_mirror sets last_apply_time to NULL on
purpose to force the next run past the refresh-interval gate, so a manual refresh makes a
healthy mirror look like it has never applied anything. Use last_operation_time instead.