Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Since PgDog uses TOML, both `5000` and `5_000` are valid numbers. Configuration
|------|-------------|
| [General](pgdog.toml/general.md) | General pooler settings like `host`, `port` and various timeouts. |
| [Databases](pgdog.toml/databases.md) | PostgreSQL databases proxied by PgDog. |
| [Mirroring](pgdog.toml/mirroring.md) | Configuration to [mirror](../features/mirroring.md) databases for testing |
| [Sharded Tables](pgdog.toml/sharded_tables.md) | Configuration for [sharding](../features/sharding/basics.md) databases |
| [Plugins](pgdog.toml/plugins.md) | Plugins configuration. |
| [Users](users.toml/users.md) | List of users (with passwords) that are allowed to connect to PgDog. |
| [Admin](pgdog.toml/admin.md) | Admin database settings like admin password. |
8 changes: 0 additions & 8 deletions docs/configuration/pgdog.toml/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ The shard number for this database. Only required if your database contains more

Default: **`0`**

### `mirror_of`

Indicates this database is a mirror of another one. All traffic sent to the `mirror_of` database will also be replayed against this database, subject to [`mirror_exposure`](general.md#mirror_exposure) setting.

For clusters with multiple databases, `mirror_of` must be identical in all entries. Otherwise, mirroring will be automatically disabled for that database.

Default: **`none`**

!!! note
All settings below take priority over values in [`[general]`](general.md) and [`[[users]]`](../users.toml/users.md) config sections.

Expand Down
259 changes: 0 additions & 259 deletions docs/configuration/pgdog.toml/general.md.bak

This file was deleted.

37 changes: 37 additions & 0 deletions docs/configuration/pgdog.toml/mirroring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Mirroring

Mirroring settings configure a mirroring setup between two databases. This causes traffic to be copied to the destination database for testing purposes: More details on [mirroring](../../features/mirroring.md)

```toml
[[mirroring]]
source_db = "source"
destination_db = "dest"
queue_depth = 500 # optional, overrides global setting
exposure = 0.1 # optional, overrides global setting
```

### `source_db`

Name of the source database. This should be a `name` set up in
[the `databases` section of the configuration.](./databases.md)

Default: **none** (required)

### `destination_db`

Name of the destination database. This should be a `name` set up
in [the `databases` section of the configuration.](./databases.md)

Default: **none** (required)

### `queue_depth`

The length of the queue to provision. See [mirroring](../../features/mirroring.md) for more details. This overrides the [general](./general.md) setting `mirror_queue`

Default: **none** (optional)

### `exposure`

The percent of transactions to mirror, as a floating point number between 0.0 and 1.0 . See [mirroring](../../features/mirroring.md) for more details. This overrides the [general](./general.md) setting `mirror_exposure`

Default: **none** (optional)
31 changes: 29 additions & 2 deletions docs/features/mirroring.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Mirroring in PgDog is asynchronous and should have minimal impact production dat

### Configure mirroring

To use mirroring, first configure both the mirror and the production database in [`pgdog.toml`](../configuration/pgdog.toml/general.md). Once both databases are running, add `mirror_of` to all instances of the mirror database:
To use mirroring, first configure both the mirror and the production database in [`pgdog.toml`](../configuration/pgdog.toml/general.md). Once both databases are running, add a `[[mirroring]]` section:

```toml
[[databases]]
Expand All @@ -27,7 +27,12 @@ host = "10.0.0.1"
[[databases]]
name = "staging_db"
host = "10.0.2.25"
mirror_of = "prod"

[[mirroring]]
source_db = "prod"
destination_db = "staging_db"
# queue_length = 256 # Optional: overrides general.mirror_queue
# exposure = 0.5 # Optional: overrides general.mirror_exposure
```

!!! note
Expand All @@ -48,6 +53,17 @@ If the mirror database(s) can't keep up with production traffic, queries will ba
mirror_queue = 500
```

Or in the individual `[[mirroring]]` section:

```toml
[[mirroring]]
source_db = 'source'
destination_db = 'dest'
queue_depth = 500
```

Note that local `[[mirroring]]` configuration overrides the `general` settings for that mirror only.

If the queue gets full, all subsequent mirrored transactions will be dropped until there is space in the queue again.

!!! note
Expand All @@ -64,6 +80,17 @@ This is configurable using a percentage, relative to the amount of transactions
mirror_exposure = 0.5 # 50%
```

Or in the specific mirroring section:

```toml
[[mirroring]]
source_db = 'source'
destination_db = 'dest'
exposure = 0.5
```

Local config in `[[mirroring]]` overwrites the `[general]` value for that mirror.

Acceptable values are between **0.0** (0%) and **1.0** (100%).

This is changeable at runtime, without restarting PgDog. When adding a mirror, it's a good idea to start slow, e.g., with only 0.1% exposure (`mirror_exposure = 0.01`), and gradually increase it over time.
Expand Down
Loading