You are managing a Cloud SQL for PostgreSQL instance that is experiencing high CPU usage and slow query performance. You notice that the database has a high number of idle-in-transaction connections. Which immediate action should you take to reduce CPU load without disrupting active transactions?
Trap 1: Use VPC firewall rules to block new connections until the issue…
Firewall rules block new connections but do not resolve existing idle-in-transaction connections or CPU issues.
Trap 2: Kill all idle-in-transaction connections using pg_terminate_backend.
Killing all idle-in-transaction connections indiscriminately may disrupt legitimate long-running transactions.
Trap 3: Set a statement_timeout at the session level for new connections.
Setting statement_timeout affects new connections only and does not terminate existing idle-in-transaction connections.
- A
Use VPC firewall rules to block new connections until the issue resolves.
Why wrong: Firewall rules block new connections but do not resolve existing idle-in-transaction connections or CPU issues.
- B
Kill all idle-in-transaction connections using pg_terminate_backend.
Why wrong: Killing all idle-in-transaction connections indiscriminately may disrupt legitimate long-running transactions.
- C
Set the cloudsql.enable_idle_in_transaction_session_timeout flag to true and configure idle_in_transaction_session_timeout.
This flag automatically terminates idle-in-transaction sessions after a specified timeout, reducing CPU usage without manual intervention.
- D
Set a statement_timeout at the session level for new connections.
Why wrong: Setting statement_timeout affects new connections only and does not terminate existing idle-in-transaction connections.