You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/sharding/resharding/move.md
+11-12Lines changed: 11 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -219,26 +219,25 @@ The replication delay between the two database clusters is measured in bytes. Wh
219
219
220
220
### Shard failure during copy
221
221
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.
223
223
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. |
228
228
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`:
resharding_copy_retry_min_delay = 1000# base backoff in ms; doubles each attempt, max 32×
235
235
```
236
236
237
-
### Rows remaining in destination after failure
237
+
### Primary key violations when retrying after copy failure
238
238
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.
240
240
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.
242
241
243
242
PgDog catches this and tells you exactly what to run:
244
243
@@ -247,7 +246,7 @@ data sync for "public"."orders" failed with rows remaining in destination;
247
246
truncate manually before retrying: TRUNCATE "public"."orders_new";
248
247
```
249
248
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`.
See [Integer primary keys](#integer-primary-keys) for the other common reason to use text format.
262
261
263
-
### Replication slot not dropped after abort
262
+
### Replication slot not cleaned up after stop or crash
264
263
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:
0 commit comments