Discussion Forums
Discussion Forums > Category: Database > Forum: Amazon Relational Database Service >Thread: RDS postgres: streaming replication / WAL archiving into/out of RDS
Advanced search options
RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: ringerc_2q
Posted on: Jun 1, 2014 10:13 PM
  Click to reply to this thread Reply
This question is answered.
Hi all

I have customers who're becoming interested in using RDS PostgreSQL to replace self-managed AWS EC2 setups with all the attendant backups, replication, failover, etc. Feature-wise, RDS is acceptable for most of them as it includes the key extensions that most users require.

I can't move any of them over to RDS, though, because they're operations that can't afford multi-hour downtime. Right now, the only way to move data into or out of RDS PostgreSQL is with pg_dump and pg_restore. Even with parallel dump and restore a migration would take much too long.

Personally I'm also concerned about being able to get their data back out if they want to move off RDS Postgres later or use a hybrid setup later.

When looking around in RDS I can see that WAL archiving is clearly enabled. WAL seems to handed to an Amazon-internal script that presumably stashes it in S3. RDS Postgres uses streaming replication for multi-AZ. So the functionality is present internally and working.

What I need to be able to move people onto (and off) RDS Postgres is to expose that externally. For inward migration:

  • Ability to "seed" an RDS Postgres instance with a data directory from outside RDS (created by pg_basebackup or by pg_start_backup + rsync + pg_stop_backup)
  • Ability to set the new RDS postgres instance up with a recovery.conf that replays from a remote streaming replica and also restores WAL from a restore_command (an amazon-provided script, of course) that can read WAL from S3, perhaps as archived by WAL-E. Streaming replication only isn't good enough, WAL archiving fallback is really necessary.

For outward migration, which would be very reassuring to have:

  • Ability to create replication{} entries in pg_hba.conf to allow remote streaming replication connections and pg_basebackup.
  • Ability to set up the RDS Postgres instance to store WAL segments (and any backup label etc it creates) in an S3 bucket accessible to the user.

Possible caveats and concerns include:

  • Mismatched compile time options or mismatched architecture. There's no way around this except for the user to migrate (using slony-I, Londiste, BDR when it's ready, etc) to a compatible DB instance then migrate into RDS.
  • If RDS requires any special initdb-time options. Without knowing more about the innards of RDS PostgreSQL it's hard to say whether that could be a concern.
  • Security concerns with "untrusted" procedural languages, adminpack, etc already installed in the DB before migration. Disabling these in your version of plperl.so, plpython.so, etc will be trivial, so attempting to use them post-migration will result in an ERROR.
  • Security concerns with user defined C extensions. This is a non-issue, because C extensions can't be embedded inside the database, they have to be in the libdir, and the user can't modify the libdir in RDS instances.
  • Security concerns with user GRANTs and REVOKEs, especially for superuser. You'd probably need code that walked pg_authid on startup to transform any superuser rights into grants to rds_superuser instead.
  • Missing extensions. Just like with an existing PostgreSQL filesystem level dump and restore, this just results in ERRORs when attempting to use extension functionality. Users can drop the objects that use the extensions.

So while there are a few challenges, there's nothing insurmountable unless Amazon have patched their version of PostgreSQL so it's no longer on-disk compatible with community PostgreSQL.

If inward and outward migration by replication can be made possible, it'd be a real boost, so I'd love your thoughts on this.

See also this related Stack Overflow question: http://dba.stackexchange.com/q/61305/7788

(Please forgive the awful formatting, this forum markup is not familiar and not much fun. Don't suppose you guys will support Markdown at some point?)

Edited by: ringerc_2q on Jun 1, 2014 10:13 PM

Permlink Replies: 36 | Pages: 2 - Last Post: Nov 18, 2015 7:49 AM by: miend
Replies
« Previous | Page: 1 2 | Next »
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: ringerc_2q
Posted on: Jun 4, 2014 6:38 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
Nobody?

Has the AWS team looked at allowing external replication?
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: Jouni L
Posted on: Jun 5, 2014 12:07 AM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1

Your question is well written and perfectly describes my situation also. I need the way out just so I can sell the idea of RDS.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: MattDWH
Posted on: Jun 16, 2014 10:22 AM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
Yes, the company I work for is also looking for this functionality and it looks like we'll have to resort to using plain old EC2 instances. Everywhere online said to come here and bother AWS about it so here I am. Bother, bother, bother, bother!
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: dan_tbt
Posted on: Jun 17, 2014 6:38 AM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
We're looking to set up a streaming replica of a non-RDS database, and were surprised / sad to find out that this couldn't be done. This functionality would be great for customers who have already created their infrastructures with another service but want to keep RDS around as a fail-safe.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: bghidinelli
Posted on: Jun 22, 2014 10:13 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1. The first step for us to move our infrastructure to EC2/RDS is to first get disaster recover moved over. We have a relatively small ~15gb database but it would still be hours of dump, transfer and restore. We aim for 99.99% uptime so there's no way that will work for us until we can stream in.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: snikch
Posted on: Jun 23, 2014 11:25 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1 from me. Just came across this thread while looking for a migration strategy from Heroku hosted Postgres to RDS. We're a SAAS application, and our uptime is mission critical for many of our customers. Without a workable migration strategy for external Postgres db's, we aren't able to make the jump. MySQL on rds is able to become a replica for an external master db, so it would be great to see a solution for Postgres - which the OP has documented.

Please Amazon, at least let us know if this is in the works / ETA.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: slickchicken
Posted on: Jul 28, 2014 2:43 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1 - I believe this feature is stopping a lot of folks from using RDS
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: lotsinstore
Posted on: Jul 28, 2014 3:42 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: flightcar
Posted on: Jul 30, 2014 11:12 AM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1. Even just some way to get a read replica would sell us on postgres RDS.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: ryno75
Posted on: Jul 30, 2014 11:14 AM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: Nate Dudenhoeffer
Posted on: Aug 7, 2014 7:49 AM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
Another +1 here. It would be really nice to get a response from the folks at AWS on this.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: Michael M
Posted on: Aug 7, 2014 11:23 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1 This is something we'd also really like to see so we can move away from running postgres ourselves.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: 8357753
Posted on: Aug 20, 2014 5:23 PM
in response to: Michael M in response to: Michael M
  Click to reply to this thread Reply
Yep +1
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: timuckun
Posted on: Aug 20, 2014 9:37 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1 for me too.

It would be great to have access to the slaves for reporting and other read only queries.

It would be great to have multiple read only slaves (RDS or otherwise).

It would be great to be able to have standby servers in other countries for better failover coverage.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: Vinod Chandru
Posted on: Aug 23, 2014 12:43 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1. Definitely need this ability. We can't move to RDS otherwise.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: timuckun
Posted on: Aug 24, 2014 2:46 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
Is there anybody from Amazon willing to comment on this?
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: swaredev
Posted on: Aug 25, 2014 11:21 AM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: bartoszr
Posted on: Aug 27, 2014 11:47 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: michal_guminiak
Posted on: Aug 27, 2014 11:54 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: ringerc_2q
Posted on: Aug 30, 2014 3:14 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
Well, the AWS team don't seem to have much to say on this topic.

PostgreSQL 9.4 includes logical changeset extraction, which (unlike WAL archiving and streaming replication) isn't dependent on low level database format details and exact version. Hopefully they're looking at exposing that for when they go over to 9.4.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: booleanbetrayal
Posted on: Sep 1, 2014 11:43 AM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: JoshWiens
Posted on: Sep 8, 2014 7:21 AM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+100

It would be nice to get some sort of response from amazon on this.
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: Srikanth@AWS
Posted on: Sep 8, 2014 1:25 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
Thank you for your feedback. We have taken your inputs into consideration in our roadmap planning. We will update this thread when we have more information to share.

Edited by: Pavan@AWS on Sep 8, 2014 1:53 PM
Re: RDS postgres: streaming replication / WAL archiving into/out of RDS
Posted by: erve1879
Posted on: Sep 22, 2014 10:14 PM
in response to: ringerc_2q in response to: ringerc_2q
  Click to reply to this thread Reply
+1 from me as well.

Can AWS give us any indication of the timeline on implementing this? I'm at the point of decision and even a rough idea of timeline would most helpful.......
« Previous | Page: 1 2 | Next »