1

I have an AWS RDS Postgresql instance with some data stored in it. Now, I want to take a snapshot of the mentioned RDS instance and create a new RDS instance from that snapshot. The issue is when the new RDS instance is created from the snapshot, the old RDS instance closes down all the active connections for some reason. I can not afford to do this as many others will be using the same database and closing of connection will be problematic for them. Any lead would be appreciated.

3
  • "when the new RDS instance is created from the snapshot, the old RDS instance closes down all the active connections for some reason" That is not possible as you have described. There has to be something else going on here. You need to provide a lot more detail about how you are creating the new instance. It sounds like you are somehow modifying the connection settings of the existing servers or something. Are you doing this via a CloudFormation or Terraform template? Commented Apr 12, 2023 at 13:43
  • Let me explain what I have tried. 1.Open a connection to the existing postgres RDS using python boto3 client 2.Take the snapshot of the DB manually from aws console. 3.Now restore the snapshot to a new RDS instance and wait for the process to complete. 4. Now, using the connection obtained in step 1, trying to query one of the tables of the DB. 5. Get the below error: "server closed the connection unexpectedly. This probably means the server terminated abnormally before or while processing the request". If I create a new connection as I did in 1st step, and try to query, everything works fine Commented Apr 12, 2023 at 19:08
  • 1
    That just sounds like your connection is timing out or something. Creating a new RDS instance in no way affects any of the other running RDS instances. Commented Apr 12, 2023 at 20:19

1 Answer 1

1

When an RDS snapshot is taken of instance, AWS creates a new storage volume from the snapshot which is used to create the new RDS instance. During this process, the original RDS instance remains in read-only mode to ensure data consistency in the snapshot.

However, the old RDS instance closing all active connections during the snapshot creation process seems unexpected. One solution to prevent this issue is to create a read replica of the original RDS instance and then take a snapshot of the replica instead of the original instance.

To create a read replica, follow these steps:

  1. Go to the Amazon RDS console and select the original RDS instance you want to create a read replica for.
  2. Click on "Create read replica" button and configure the replica instance.
  3. Once the replica is created and running, take a snapshot of the replica instance instead of the original instance.
  4. Create a new RDS instance from the snapshot of the replica instance.

This approach ensures that the original RDS instance remains unaffected and all active connections are maintained. The read replica can be used for reporting or backup purposes, and the snapshot of the replica can be used to create a new RDS instance.

Please be aware that creating a read replica may incur additional costs for running the replica instance.

Please share your feedback

Sign up to request clarification or add additional context in comments.

1 Comment

Same problem while creating the read replica as well. Let me explain what I have tried. 1. Open a connection to the existing postgres RDS using python boto3 client 2. Create the read replica manually and wait for the replica to get created 3. Now, using the connection obtained in the step 1, trying to query one of the tables of the DB. 4. Get the below error server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.