-
Notifications
You must be signed in to change notification settings - Fork 2
docs: Database Instance Operations #223
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
52295be
Docs: Database Instance Operations
GabriellePoncey 68d8e8f
Revise Managing Database Instances documentation to align with other …
GabriellePoncey 5505b1a
Revision to allign with coderabbit feedback
GabriellePoncey d2441c0
Revision to allign with final coderabbit feedback- corrected database id
GabriellePoncey 8369bdd
Update database-instances.md
susan-pgedge 7f2fb00
Update database-instances.md
susan-pgedge fe59703
Revision to allign with curl indentation feedback
GabriellePoncey a2659ec
typo
GabriellePoncey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| # Managing Database Instances | ||
|
|
||
|
|
||
|
|
||
|
|
||
| A Database instance is: | ||
|
|
||
|
|
||
| * A running Postgres server | ||
| * Bound to a specific host | ||
| * Identified by a node name (e.g. n1) | ||
| * Identified globally by an instance ID (eg 68f50878-44d2-4524-a823-e31bd478706d-n1-689qacsi) | ||
|
|
||
|
|
||
| Each instance maps to exactly one physical host, but a host can run multiple database instances as long as ports do not clash. | ||
|
|
||
|
|
||
| While a database is stable and persistent, database instances are runtime components with states that are not "identity-critical". This allows rolling updates, automatic failovers, and safe restarts. | ||
|
|
||
|
|
||
| Managing a database instance involves handling various operational needs throughout its lifecycle. For example, modifying certain POstgresSQL parameters can require a restart to take effect (eg shared_buffers), as the Control Plane does not automatically restart instances on a user’s behalf. Additionally, managing instances allows you to control costs by stopping unused development or test environments, troubleshoot issues when systems become unresponsive, and coordinate system updates in a controlled manner to minimize disruption to your applications. | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ## Monitoring Instances | ||
|
|
||
|
|
||
| To access important information about a database instance, call the GetDatabase endpoint by specifying its database ID as shown below for a database "example". | ||
|
|
||
|
|
||
| In the following example, the `curl` command retrieves database information for a database named "example": | ||
|
|
||
|
|
||
| ```sh | ||
| curl http://host-3:3000/v1/databases/example | ||
| ``` | ||
|
|
||
|
|
||
| The endpoint will return the following information pertaining to the database. | ||
|
|
||
|
|
||
| * `created_at`: Timestamp when the database was created | ||
| * `id`: Database identifier | ||
| * `instances`: Array of instance objects containing instance-specific information | ||
| * `spec`: Database specification | ||
| * `state`: Current state of the database | ||
| * `updated_at`: Timestamp of last update | ||
|
|
||
|
|
||
| ### Finding Instance IDs | ||
|
|
||
|
|
||
| The `instances` array contains information about a database instance, specifically: | ||
|
|
||
|
|
||
| * `id`: The instance identifier (e.g., `storefront-n1-689qacsi`) required for instance operations | ||
| * `node_name`: The node this instance belongs to (e.g., `n1`) | ||
| * `host_id`: The host where this instance runs | ||
| * `state`: Current operational state of the instance | ||
| * `postgres`: Postgres status information, including the `pending_restart` field which indicates if a configuration change requires a restart | ||
| * `connection_info`: Connection details for this instance | ||
| * `created_at` and `updated_at`: Instance timestamps | ||
|
|
||
|
|
||
| The `pending_restart` field within the `postgres` object is particularly important—when `true`, it signals that configuration changes have been applied that will only take effect after the instance is restarted. | ||
|
|
||
|
|
||
| ### Instance States | ||
|
|
||
|
|
||
| Postgres instances can be in different states as a result of database operations (start/stop/restart/etc): | ||
|
|
||
|
|
||
| * `available` | ||
| * `starting` | ||
| * `stopping` | ||
| * `restarting` | ||
| * `failed` | ||
| * `error` | ||
| * `unknown` | ||
|
|
||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Stopping Instances | ||
|
|
||
|
|
||
| Stopping an instance shuts down the Postgres process for that specific instance by scaling it to zero. The instance no longer accepts connections and is taken out of service, but its data and configuration are preserved. Other instances in the same database can continue running. As Stop Instance removes a database instance from service without deleting it, it can be used to isolate an instance not currently in use but that is expected to be restarted later. | ||
|
|
||
|
|
||
| * Transition: available → stopping → stopped | ||
| * Port remains reserved for this instance | ||
| * Other instances remain unaffected | ||
| * A stopped instance continues to appear under list-databases with state: "stopped" | ||
|
|
||
|
|
||
| In the following example, the `curl` command stops an instance named "n1" for a database named "example": | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ```sh | ||
| curl http://host-3:3000/v1/databases/example/instances/n1/stop | ||
| ``` | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ## Starting Instances | ||
|
|
||
|
|
||
| Starts a specific instance within a database by scaling it back up. This operation is only valid when the instance is in a stopped state. A successful start instance operation will transition an instance state from stopped to starting to available, allowing normal access and use to continue and restarting any activities. | ||
|
|
||
|
|
||
| * Transition: stopped → starting → available | ||
| * Retains same port as before stop | ||
| * Fails if port is already taken (a safety check) | ||
|
|
||
|
|
||
| In the following example, the `curl` command starts an instance with ID "example-n1-689qacsi" for a database named "example": | ||
|
|
||
|
|
||
| ```sh | ||
| curl -X POST http://host-3:3000/v1/databases/example/instances/example-n1-689qacsi/start | ||
| ``` | ||
|
|
||
|
|
||
| ## Restarting Instances | ||
|
|
||
|
|
||
| Restarting an instance stops and then starts the same Postgres instance, either immediately or at a scheduled time. This is typically used to recover from errors or apply changes that require a restart. The instance keeps its identity and data, but experiences a brief downtime during the restart. | ||
|
|
||
|
|
||
| * If no scheduled_at is provided → restart immediately. | ||
| * Transition: available → restarting → available | ||
| * Restart is blocked if: No configuration changes require a restart, Another update is in progress, or Instance is not stable | ||
|
|
||
|
|
||
| In the following example, the `curl` command restarts an instance with ID "example-n1-689qacsi" for a database named "example": | ||
|
|
||
|
|
||
| ```sh | ||
| curl -X POST http://host-3:3000/v1/databases/example/instances/example-n1-689qacsi/restart | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.