|
| 1 | +--- |
| 2 | +title: Troubleshooting guides - Azure portal - Azure Database for PostgreSQL - Flexible Server Preview |
| 3 | +description: Learn how to use Troubleshooting guides for Azure Database for PostgreSQL - Flexible Server from the Azure portal. |
| 4 | +ms.service: postgresql |
| 5 | +ms.subservice: flexible-server |
| 6 | +ms.topic: how-to |
| 7 | +ms.author: alkuchar |
| 8 | +author: AwdotiaRomanowna |
| 9 | +ms.date: 03/21/2023 |
| 10 | +--- |
| 11 | + |
| 12 | +# Troubleshooting guides - Azure portal - Azure Database for PostgreSQL - Flexible Server Preview |
| 13 | + |
| 14 | +[!INCLUDE [applies-to-postgresql-flexible-server](../includes/applies-to-postgresql-flexible-server.md)] |
| 15 | + |
| 16 | +> [!NOTE] |
| 17 | +> Troubleshooting guides for PostgreSQL Flexible Server are currently in preview. |
| 18 | +
|
| 19 | +The troubleshooting guides available in Azure Database for PostgreSQL - Flexible Server provide you with the necessary tools to analyze and troubleshoot prevalent performance issues, |
| 20 | +including: |
| 21 | +* high CPU usage, |
| 22 | +* high memory usage, |
| 23 | +* high IOPS usage, |
| 24 | +* high usage of temporary files, |
| 25 | +* autovacuum monitoring and blockers. |
| 26 | + |
| 27 | +Each guide is packed with multiple charts, guidelines, recommendations tailored to the specific problem you may encounter, which can help expedite the troubleshooting process. |
| 28 | +The troubleshooting guides are directly integrated into the Azure portal and your Azure Database for PostgreSQL - Flexible Server, making them convenient and easy to use. |
| 29 | + |
| 30 | +## Prerequisites |
| 31 | + |
| 32 | +To effectively troubleshoot specific issue, you need to make sure you have all the necessary data in place. |
| 33 | +Each troubleshooting guide requires a specific set of data, which is sourced from three separate features: Diagnostic settings, Query Store, and Enhanced Metrics. |
| 34 | +All troubleshooting guides require logs to be sent to the Log Analytics workspace, but the specific category of logs to be captured may vary depending on the particular guide. |
| 35 | + |
| 36 | +Please follow the steps described in the [Configure and Access Logs in Azure Database for PostgreSQL - Flexible Server](howto-configure-and-access-logs.md) article to configure diagnostic settings and send the logs to the Log Analytics workspace. |
| 37 | +Query Store, and Enhanced Metrics are configured via the Server Parameters. Please follow the steps described in the "Configure server parameters in Azure Database for PostgreSQL - Flexible Server" articles for [Azure Portal](howto-configure-server-parameters-using-portal.md) or [Azure CLI](howto-configure-server-parameters-using-cli.md). |
| 38 | + |
| 39 | +The table below provides information on the required log categories for each troubleshooting guide, as well as the necessary Query Store and Enhanced Metrics prerequisites. |
| 40 | + |
| 41 | +| Troubleshooting guide | Diagnostic settings log categories | Query Store | Enhanced Metrics | |
| 42 | +|:------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|-------------------------------------| |
| 43 | +| Autovacuum blockers & wraparound identification | "PostgreSQL Sessions", "PostgreSQL Database Remaining Transactions" | :x: | :x: | |
| 44 | +| Autovacuum monitoring | "PostgreSQL Server Logs", "PostgreSQL Tables Statistics", "PostgreSQL Database Remaining Transactions" | :x: | :x: | |
| 45 | +| High CPU utilization | "PostgreSQL Server Logs", "PostgreSQL Sessions", "AllMetrics" | pg_qs.query_capture_mode to TOP or ALL | metrics.collector_database_activity | |
| 46 | +| High IOPS utilization | "PostgreSQL Query Store Runtime", "PostgreSQL Server Logs", "PostgreSQL Sessions", "PostgreSQL Query Store Wait Statistics" | pgms_wait_sampling.query_capture_mode to ALL | metrics.collector_database_activity | |
| 47 | +| High memory usage | "PostgreSQL Server Logs", "PostgreSQL Sessions" | pg_qs.query_capture_mode to TOP or ALL | metrics.collector_database_activity | |
| 48 | +| High temporary file usage | "PostgreSQL Query Store Runtime", "PostgreSQL Query Store Wait Statistics" | pg_qs.query_capture_mode to TOP or ALL | metrics.collector_database_activity | |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +> [!NOTE] |
| 53 | +> When deploying read replicas for persistent heavy write-intensive primary workloads, the replication lag could continue to grow and may never be able to catch-up with the primary. This may also increase storage usage at the primary as the WAL files are not deleted until they are received at the replica. |
| 54 | +
|
| 55 | +## Create a read replica |
| 56 | + |
| 57 | +To create a read replica, follow these steps: |
| 58 | + |
| 59 | +1. Select an existing Azure Database for PostgreSQL server to use as the primary server. |
| 60 | + |
| 61 | +2. On the server sidebar, under **Settings**, select **Replication**. |
| 62 | + |
| 63 | +3. Select **Add Replica**. |
| 64 | + |
| 65 | + :::image type="content" source="./media/how-to-read-replicas-portal/add-replica.png" alt-text="Add a replica"::: |
| 66 | + |
| 67 | +4. Enter the Basics form with the following information. |
| 68 | + |
| 69 | + :::image type="content" source="./media/how-to-read-replicas-portal/basics.png" alt-text="Enter the Basics information"::: |
| 70 | + |
| 71 | + > [!NOTE] |
| 72 | + > To learn more about which regions you can create a replica in, visit the [read replica concepts article](concepts-read-replicas.md). |
| 73 | +
|
| 74 | +6. Select **Review + create** to confirm the creation of the replica or **Next: Networking** if you want to add, delete or modify any firewall rules. |
| 75 | + :::image type="content" source="./media/how-to-read-replicas-portal/networking.png" alt-text="Modify firewall rules"::: |
| 76 | +7. Leave the remaining defaults and then select the **Review + create** button at the bottom of the page or proceed to the next forms to add tags or change data encryption method. |
| 77 | +8. Review the information in the final confirmation window. When you're ready, select **Create**. |
| 78 | + :::image type="content" source="./media/how-to-read-replicas-portal/review.png" alt-text="Review the information in the final confirmation window"::: |
| 79 | + |
| 80 | +After the read replica is created, it can be viewed from the **Replication** window. |
| 81 | + |
| 82 | +:::image type="content" source="./media/how-to-read-replicas-portal/list-replica.png" alt-text="View the new replica in the Replication window"::: |
| 83 | + |
| 84 | +> [!IMPORTANT] |
| 85 | +> Review the [considerations section of the Read Replica overview](concepts-read-replicas.md#considerations). |
| 86 | +> |
| 87 | +> To avoid issues during promotion of replicas always change the following server parameters on the replicas first, before applying them on the primary: max_connections, max_prepared_transactions, max_locks_per_transaction, max_wal_senders, max_worker_processes. |
| 88 | +
|
| 89 | +## Promote replicas |
| 90 | + |
| 91 | +You can promote replicas to become stand-alone servers serving read-write requests. |
| 92 | + |
| 93 | +> [!IMPORTANT] |
| 94 | +> Promotion of replicas cannot be undone. The read replica becomes a standalone server that supports both reads and writes. The standalone server can't be made into a replica again. |
| 95 | +
|
| 96 | +To promote replica from the Azure portal, follow these steps: |
| 97 | + |
| 98 | +1. In the Azure portal, select your primary Azure Database for PostgreSQL server. |
| 99 | + |
| 100 | +2. On the server menu, under **Settings**, select **Replication**. |
| 101 | + |
| 102 | +3. Select the replica server for which to stop replication and hit **Promote**. |
| 103 | + |
| 104 | + :::image type="content" source="./media/how-to-read-replicas-portal/select-replica.png" alt-text="Select the replica"::: |
| 105 | + |
| 106 | +4. Confirm promote operation. |
| 107 | + |
| 108 | + :::image type="content" source="./media/how-to-read-replicas-portal/confirm-promote.png" alt-text="Confirm to promote replica"::: |
| 109 | + |
| 110 | +## Delete a primary server |
| 111 | +You can only delete primary server once all read replicas have been deleted. Follow the instruction in [Delete a replica](#delete-a-replica) section to delete replicas and then proceed with steps below. |
| 112 | + |
| 113 | +To delete a server from the Azure portal, follow these steps: |
| 114 | + |
| 115 | +1. In the Azure portal, select your primary Azure Database for PostgreSQL server. |
| 116 | + |
| 117 | +2. Open the **Overview** page for the server and select **Delete**. |
| 118 | + |
| 119 | + :::image type="content" source="./media/how-to-read-replicas-portal/delete-server.png" alt-text="On the server Overview page, select to delete the primary server"::: |
| 120 | + |
| 121 | +3. Enter the name of the primary server to delete. Select **Delete** to confirm deletion of the primary server. |
| 122 | + |
| 123 | + :::image type="content" source="./media/how-to-read-replicas-portal/confirm-delete.png" alt-text="Confirm to delete the primary server"::: |
| 124 | + |
| 125 | +## Delete a replica |
| 126 | + |
| 127 | +You can delete a read replica similar to how you delete a standalone Azure Database for PostgreSQL server. |
| 128 | + |
| 129 | +- In the Azure portal, open the **Overview** page for the read replica. Select **Delete**. |
| 130 | + |
| 131 | + :::image type="content" source="./media/how-to-read-replicas-portal/delete-replica.png" alt-text="On the replica Overview page, select to delete the replica"::: |
| 132 | + |
| 133 | +You can also delete the read replica from the **Replication** window by following these steps: |
| 134 | + |
| 135 | +1. In the Azure portal, select your primary Azure Database for PostgreSQL server. |
| 136 | + |
| 137 | +2. On the server menu, under **Settings**, select **Replication**. |
| 138 | + |
| 139 | +3. Select the read replica to delete and hit the **Delete** button. |
| 140 | + |
| 141 | + :::image type="content" source="./media/how-to-read-replicas-portal/delete-replica02.png" alt-text="Select the replica to delete"::: |
| 142 | + |
| 143 | +4. Acknowledge **Delete** operation. |
| 144 | + |
| 145 | + :::image type="content" source="./media/how-to-read-replicas-portal/delete-confirm.png" alt-text="Confirm to delete te replica"::: |
| 146 | + |
| 147 | +## Monitor a replica |
| 148 | + |
| 149 | +Two metrics are available to monitor read replicas. |
| 150 | + |
| 151 | +### Max Physical Replication Lag |
| 152 | +> Available only on the primary. |
| 153 | +
|
| 154 | +The **Max Physical Replication Lag** metric shows the lag in bytes between the primary server and the most-lagging replica. |
| 155 | + |
| 156 | +1. In the Azure portal, select the primary server. |
| 157 | + |
| 158 | +2. Select **Metrics**. In the **Metrics** window, select **Max Physical Replication Lag**. |
| 159 | + |
| 160 | + :::image type="content" source="./media/how-to-read-replicas-portal/metrics_max_physical_replication_lag.png" alt-text="Screenshot of the Metrics blade showing Max Physical Replication Lag metric."::: |
| 161 | + |
| 162 | +3. For your **Aggregation**, select **Max**. |
| 163 | + |
| 164 | +### Read Replica Lag metric |
| 165 | +> Available only on replicas. |
| 166 | +
|
| 167 | +The **Read Replica Lag** metric shows the time since the last replayed transaction on a replica. If there are no transactions occurring on your primary, the metric reflects this time lag. For instance if there are no transactions occurring on your primary server, and the last transaction was replayed 5 seconds ago, then the Read Replica Lag will show 5 second delay. |
| 168 | + |
| 169 | +1. In the Azure portal, select read replica. |
| 170 | + |
| 171 | +2. Select **Metrics**. In the **Metrics** window, select **Read Replica Lag**. |
| 172 | + |
| 173 | + :::image type="content" source="./media/how-to-read-replicas-portal/metrics_read_replica_lag.png" alt-text=" screenshot of the Metrics blade showing Read Replica Lag metric."::: |
| 174 | + |
| 175 | +3. For your **Aggregation**, select **Max**. |
| 176 | + |
| 177 | +## Next steps |
| 178 | + |
| 179 | +* Learn more about [read replicas in Azure Database for PostgreSQL](concepts-read-replicas.md). |
| 180 | + |
| 181 | +[//]: # (* Learn how to [create and manage read replicas in the Azure CLI and REST API](how-to-read-replicas-cli.md).) |
0 commit comments