Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read replicas #132

Merged
merged 1 commit into from
Jan 10, 2024
Merged

Read replicas #132

merged 1 commit into from
Jan 10, 2024

Conversation

aaronblevy
Copy link
Contributor

@aaronblevy aaronblevy commented Dec 22, 2023

Allow managing a read replica using Terraform. A read replica is specified as a resource with the attribute read_replica_source set.

The provider applies some validation steps. The main one is to prevent multiple read replicas for the same service. If a user specifies multiple read replicas with the same source, Terraform will attempt to create these in parallel (unless the user specifies a parallelism of one). To get around this, we use a global read replica lock to synchronize the process of creating a read replica. Before we create the replica, we check if there is an existing read replica for a service. To do this, we fetch all the services the project and check if any of the fork configurations specify the same source.
This can be later optimized with service level mutexes. Since that would complicates the logic further, it's omitted in this PR.

@aaronblevy aaronblevy changed the title Aaron/read replicas Read replicas Dec 22, 2023
@aaronblevy aaronblevy force-pushed the aaron/read_replicas branch 4 times, most recently from e216948 to 3e5d746 Compare January 5, 2024 15:04
}

type ForkConfig struct {
ProjectID string `json:"projectID"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the input for ForkConfig when creating a service uses projectID, while the types for ForkSpec use projectId so I think I need different structs here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

@aaronblevy aaronblevy marked this pull request as ready for review January 5, 2024 15:28
@aaronblevy aaronblevy requested a review from a team as a code owner January 5, 2024 15:28
@aaronblevy aaronblevy force-pushed the aaron/read_replicas branch from 3e5d746 to a081780 Compare January 8, 2024 14:46
@aaronblevy
Copy link
Contributor Author

Looks like there's a bug where you can create a read replica off a read replica that I need to fix before merging

@aaronblevy
Copy link
Contributor Author

I also forgot to add validation on Update(), added those checks and some tests 😄.
Mainly, you can't change read_replica_source, or update the service to enable HA.

@aaronblevy aaronblevy merged commit 8c5c314 into main Jan 10, 2024
5 checks passed
@aaronblevy aaronblevy deleted the aaron/read_replicas branch January 10, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants