Skip to content

Instantly share code, notes, and snippets.

@k3yss
Last active September 4, 2024 18:15
Show Gist options
  • Save k3yss/99719a404c446f9f458aaed15552e119 to your computer and use it in GitHub Desktop.
Save k3yss/99719a404c446f9f458aaed15552e119 to your computer and use it in GitHub Desktop.
Summer of Bitcoin'24 | Concluding Blog

The progress update prior to this can be found in the previous post made here

My post mid-term tasks mainly involved researching on PostgreSQL upgrade strategies for the managed CloudSQL PostgreSQL instances used in Galoy's infrastructure. The further post outlines my findings for performing seamless upgrades

PostgresSQL upgrade on Google CloudSQL

Google Cloud Platform (GCP) offers two primary methods for upgrading PostgreSQL instances on CloudSQL:

  • Using the in-place pg_upgrade tool provided by GCP
  • Utilizing the Database Migration Service (DMS) to perform upgrades

Below is a small report on finding using both the tools:

1. In-place pg_upgrade

The in-place upgrade using pg_upgrade is a straightforward method provided by GCP for upgrading PostgreSQL instances. With the infrastructure employed by Galoy you only need to edit the terraform config and change the database_version from POSTGRES_14 to POSTGRES_15 and doing a tofu apply upgrades the instances in-place.

While this method is very seamless and carries all the configuration in the upgraded instance, the downtime recorded was sometimes over 15 minutes, which exceeded the criteria of minimal downtime of 10 minutes, so research on DMS was done.

2. Database Migration Service (DMS)

Most of the post mid-term work focused on the Database Migration Service method, which offers more control over the upgrade process and keeps downtime under 10 minutes (including user migrations), but requires additional steps to migrate users and permissions as it doesn't automatically copy them during the upgrade. To address the user and permission migration issue with DMS, I created three scripts:

Conclusion on Database Upgradation

Based on the research and testing, the Database Migration Service (DMS) method is recommended for Galoy's infrastructure due to its ability to meet the minimal downtime requirement of under 10 minutes, despite the need for additional steps to handle user and permission migration.

For a complete guide on the DMS upgrade process, including user migration and permission updates, please refer to the documentation here.

Account of Work Done in Summer of Bitcoin

Conclusion

This report concludes my internship with Galoy through the Summer of Bitcoin. I am grateful for this opportunity and managed to learn a lot about DevOps tools and infrastructure in general. Kartik was helpful throughout the program, and I had a lot of fun being his mentee. Overall, the whole program was awesome, and I thoroughly enjoyed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment