Skip to content

Commit 4779ffa

Browse files
committed
fix review
1 parent 22e2988 commit 4779ffa

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

docs/features/sharding/resharding/move.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,26 +219,25 @@ The replication delay between the two database clusters is measured in bytes. Wh
219219

220220
### Shard failure during copy
221221

222-
If a shard goes down mid-copy, PgDog retries that table with exponential backoff - up to **5 attempts**, starting at **1 second** and doubling each time.
222+
If a shard goes down mid-copy, PgDog retries that table with exponential backoff. By default: up to **5 attempts**, starting at **1 second** and doubling each time.
223223

224-
The two cases behave differently:
225-
226-
- **Destination shard down** — PgDog opens a fresh connection on the next attempt.
227-
- **Source shard down** — the `TEMPORARY` slot for that table is re-created from scratch. No cleanup needed; `TEMPORARY` slots vanish when the connection closes (unlike the [permanent slot](#replication-slot) created at the start of the overall copy).
224+
| Situation | Behavior |
225+
|-|-|
226+
| Destination shard down | New connection opened on the next attempt. |
227+
| Source shard down | `TEMPORARY` replication slot re-created from scratch. It's cleaned up automatically when the connection closes before starting new attempt. |
228228

229-
To change the defaults:
229+
To change the defaults, configure [`resharding_copy_retry_max_attempts`](../../../configuration/pgdog.toml/general.md#resharding_copy_retry_max_attempts) and [`resharding_copy_retry_min_delay`](../../../configuration/pgdog.toml/general.md#resharding_copy_retry_min_delay) in `pgdog.toml`:
230230

231231
```toml
232232
[general]
233233
resharding_copy_retry_max_attempts = 5 # per-table retry attempts
234234
resharding_copy_retry_min_delay = 1000 # base backoff in ms; doubles each attempt, max 32×
235235
```
236236

237-
### Rows remaining in destination after failure
237+
### Primary key violations when retrying after copy failure
238238

239-
Most drops are clean: table copies run inside an implicit transaction, so Postgres rolls back on disconnect and the destination is left empty.
239+
In rare cases, if the connection drops after `COPY` commits but before PgDog records the table as done, some rows may remain in the destination. The next retry will hit primary key violations.
240240

241-
The awkward case: the connection drops *after* `COPY` commits on some or all shards but before PgDog records it as done. The rows survive, and the next attempt hits primary key violations immediately.
242241

243242
PgDog catches this and tells you exactly what to run:
244243

@@ -247,7 +246,7 @@ data sync for "public"."orders" failed with rows remaining in destination;
247246
truncate manually before retrying: TRUNCATE "public"."orders_new";
248247
```
249248

250-
Run the `TRUNCATE` on the destination (the table name is literal — copy it verbatim), then re-run `COPY_DATA`.
249+
Run the `TRUNCATE` on the destination (you can copy the command above, but make sure to run it strictly on the destination), then re-run `COPY_DATA`.
251250

252251
### Binary format mismatch
253252

@@ -260,9 +259,9 @@ resharding_copy_format = "text"
260259

261260
See [Integer primary keys](#integer-primary-keys) for the other common reason to use text format.
262261

263-
### Replication slot not dropped after abort
262+
### Replication slot not cleaned up after stop or crash
264263

265-
Aborting `COPY_DATA` without restarting it leaves the **permanent** replication slot sitting on the source. Postgres won't recycle WAL until it's gone. Drop it manually:
264+
If `COPY_DATA` is stopped via `STOP_TASK` or PgDog exits unexpectedly, the **permanent** replication slot will remain on the source. Postgres will not recycle WAL until it is dropped. Clean it up manually:
266265

267266
```postgresql
268267
SELECT pg_drop_replication_slot('slot_name');

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ plugins:
8585
'features/sharding/migrations.md': 'features/sharding/schema_management/migrations.md'
8686
'features/sharding/primary-keys.md': 'features/sharding/sequences.md'
8787
'features/sharding/schema_management/primary_keys.md': 'features/sharding/sequences.md'
88+
'features/sharding/resharding/hash.md': 'features/sharding/resharding/move.md'
8889
'features/sharding/cross-shard/index.md': 'features/sharding/cross-shard-queries/index.md'
8990

9091
extra:

0 commit comments

Comments
 (0)