Migration¶
dynodb migrate copies AWS DynamoDB, DynamoDB Local or compatible tables into fdyno through the public DynamoDB API on both sides only.
Stream catch-up converges the target before cut-over. Before sending each write group, dynodb migrate checks the fdyno item size limit. It reports the first oversized item and stops. Earlier groups may already be on the target.
| Step | What happens | Kind | Run | Application writes | Target | If it fails |
|---|---|---|---|---|---|---|
| Schema | Creates the target table with the source's keys, indexes, stream setting, TTL attribute and tags. | command | dynodb migrate schema |
to the source | the source's keys and indexes | An existing target with other keys or indexes fails. |
| Copy | Parallel Scan of the source feeds Batch on the target. The checkpoint saves each segment's last finished page. |
command | dynodb migrate copy |
to the source | copied items, while the source keeps changing | Resume from the checkpoint with the same --segments. After an unknown target write, first stop the old process and confirm that the target and any proxy have no earlier requests queued or running. |
| Follow | Applies the source stream. The first run starts at the oldest retained record; a resume continues after the saved sequence number. Start before the copy start is 23 h old; run until lag_ stays near zero. |
runs until stopped | dynodb migrate catchup --follow |
to the source | converging; a key can show an older value | A detected gap or a trimmed position stops catch-up: copy again. |
| Pause | Stop source writes: application read-only mode, or remove the role's write permission. | operator action | — | paused | converging | — |
| Drain | Stop --follow with SIGINT and wait for a clean exit. Run catchup to "caught_. |
command | dynodb migrate catchup |
paused | caught up; equality not yet verified | An unknown target write: stop here; do not cut over. |
| Verify | Counts and digest of both tables. Require "equal": true and recheck deferred TTL boundary rows. |
command | dynodb migrate verify |
paused | equal for the compared rows | Exit 2 is a difference. |
| Switch | Switch clients to fdyno with fdyno credentials; resume writes. Keep the source and its stream until rollback is unnecessary. | operator action | — | to fdyno | serves clients | — |
Before you start¶
| Requirement | Rule |
|---|---|
| Source stream | Enable before copy, preferably NEW_ or NEW_IMAGE. KEYS_ONLY and OLD_IMAGE need one strongly consistent source GetItem per change. Copy saves the ARN; catch-up refuses a changed/disabled stream or missing needed records. |
| Retention | DynamoDB Streams retain records for 24 h. Start catch-up before the copy start is 23 h old. Follow continuously, or resume with time to spare before the last saved catch-up checkpoint is 23 h old. |
| Source role | Describe, Describe, List, Scan, GetItem; stream: Describe, Get, Get. |
| Read load | --source-rps caps Scan requests/s; --page-limit bounds each page. --consistent-read= halves read capacity; catch-up repairs stale pages. |
| Item sizes | Run dynodb migrate sizes first. An item over fdyno's 48,000-byte limit stops the copy. |
Check item sizes¶
dynodb migrate sizes reads the source table with a parallel Scan and writes
nothing. It needs no target. It counts the items by size, with the same rule
that the copy applies: the larger of the DynamoDB item size and the stored
encoding (formula).
dynodb migrate sizes --table orders --segments 16 --source-rps 50 \
--source-region us-east-1 --source-profile prod-readonly
{
"command": "migrate sizes",
"result": {
"table": "orders",
"items": 1250000,
"buckets": [
{"label": "0-4 KiB", "min_bytes": 0, "max_bytes": 4096, "count": 1190211},
{"label": "4-16 KiB", "min_bytes": 4096, "max_bytes": 16384, "count": 55120},
{"label": "16 KiB-48000 B", "min_bytes": 16384, "max_bytes": 48001, "count": 4602},
{"label": "48000 B-96 KiB", "min_bytes": 48001, "max_bytes": 98304, "count": 61},
{"label": "96-400 KiB", "min_bytes": 98304, "max_bytes": 409600, "count": 6},
{"label": "400 KiB+", "min_bytes": 409600, "count": 0}
],
"max_bytes": 211873,
"max_item_key": "{\"pk\":{\"S\":\"order#88123\"}}",
"limit_bytes": 48000,
"over_limit": 67,
"over_limit_share": 0.0000536,
"seconds": 41.2
},
"status": "ok"
}
A bucket counts sizes from min_bytes up to, but not including, max_bytes.
over_limit is the number of items that the copy would refuse. Shrink or
split those items on the source before you copy. --segments,
--source-rps, --page-limit and --consistent-read work as for copy.
Copy the schema¶
dynodb migrate schema --table orders \
--source-region us-east-1 --source-profile prod-readonly \
--target-endpoint https://fdyno.internal:8000
| Copies | Does not copy (listed in result) |
|---|---|
| Keys; GSIs/LSIs and projections; billing mode/throughput; stream setting; table class; deletion protection; tags; TTL attribute | KMS encryption, resource policy, point-in-time recovery, auto scaling, replicas |
--stream off omits the target stream; --target-table renames the target.
An existing target is accepted with the same keys and indexes; other differences fail.
Copy the items¶
dynodb migrate copy --table orders --checkpoint orders.json \
--segments 64 --writers 64 \
--source-region us-east-1 --source-profile prod-readonly \
--target-endpoint https://fdyno.internal:8000
Parallel Scan feeds BatchWriteItem with backoff for throttling and
UnprocessedItems. The checkpoint saves each segment's LastEvaluatedKey
after its page succeeds. Resume with the same --segments.
A restart can repeat a page that reached the target before its checkpoint was saved. Whole-item puts can replay after earlier requests finish, while only the migration writes to the target. See unknown target writes. The checkpoint is a cursor, not a snapshot of the source. Finish the copy before starting catch-up with that checkpoint. See the copy and checkpoint code.
How the copy runs¶
- A new copy writes its first checkpoint. The segments 0 to N-1 go to a pool of min(N,
--writers) segment workers. A resume assigns only the segments not marked done. - Each worker scans one page of its segment. With a positive
--source-rps, eachScanattempt, SDK retries included, takes a token first. - The worker splits the page into
BatchWriteItemcalls of up to 25 puts. - It waits until every call succeeds, under the target-write rules below. At most
--writerscalls are in flight across all workers. - It records
LastEvaluatedKey, then reads the next page, or marks the segment done. It saves this progress to the checkpoint file at most once per second.
When the workers return, the copy saves the checkpoint file. A copy that succeeds saves it once more, with its completion time.
| Step | Rule |
|---|---|
| Segments | --segments (default 16, at most 1,000,000). With more than one segment, each Scan carries Segment and Total. A resume skips segments marked done and refuses a different --segments. |
| Source reads | --page-limit sets Scan Limit (default 0: DynamoDB's 1 MB pages). --consistent-read defaults to true. --source-rps (default 0: no limit) is one token bucket for all segments, holding up to max(1, rate) tokens. It counts requests: every Scan attempt, the SDK's retries and the copy's own retries included, takes a token before it is sent, so retries during throttling do not raise the request rate above it. migrate verify uses the same rule for its source scan. |
| Scan retries | Each Scan call first uses the AWS SDK's standard retries: up to 10 attempts, backoff up to 20 s, no client-side retry quota. After that, Provisioned, Throttling, Request, Internal, Service, Limit, Transaction and errors without an API error code, such as transport errors but not a client timeout, are retried up to 20 more times. Other errors stop the copy. Each attempt has a two-minute client timeout; when the last of the 10 SDK attempts of one Scan times out, the copy stops with that error. So a source that accepts connections but stops answering stops the copy after about 20 minutes, and a resume with the same --checkpoint continues from the last finished page. |
| Target writes | The SDK's own retries are off for Batch. A whole-request rejection is retried only for Provisioned, Throttling or Request with HTTP 400, 403, 404 or 429; the same code with another status is an unknown outcome. Such a rejection on the batch's 21st or later attempt, Unprocessed rounds counted, stops the copy. Unprocessed are sent again; the copy fails after more than 50 attempts in a row that process nothing. Each attempt has a two-minute timeout. Any unknown outcome stops the run. |
| Backoff | Full jitter: a random wait up to 50 ms × 2ⁿ for retry n (n at most 12), capped at 10 s. For Unprocessed, n counts attempts without progress. |
| Checkpoint | It records, per segment, the Last of the last page whose writes all succeeded, the item count and whether the segment is done. It also records the copy start time and the source stream ARN and view type, which catch-up uses. A source without a stream logs a warning: catch-up is then not possible. |
| First error | One segment's error cancels the others. The checkpoint keeps the pages that finished. |
See the target writer and the backoff and rate limit.
Import an S3 export¶
aws s3 sync s3://bucket/AWSDynamoDB/01234567890123-abcdefgh/ ./export/
dynodb migrate schema --table orders --target-endpoint https://fdyno.internal:8000
dynodb migrate import --dir ./export --target-table orders --checkpoint import.json \
--target-endpoint https://fdyno.internal:8000
Import accepts full ExportTableToPointInTime exports: DYNAMODB_JSON or
ION, gzip or plain. It checks the count against manifest-summary.json.
Incremental exports are unsupported. Exports have no stream position:
catch-up cannot follow them. Stop writes for the whole import.
Catch up¶
While clients still write to the source:
dynodb migrate catchup --table orders --checkpoint orders.json --follow \
--source-region us-east-1 --source-profile prod-readonly \
--target-endpoint https://fdyno.internal:8000
Catch-up starts at the oldest retained record, before the live copy. It applies whole-item puts/deletes and checkpoints each shard's last sequence. A child shard waits for its parent. One key's records apply in order. A replay converges once earlier target requests have finished.
| Output or flag | Meaning |
|---|---|
lag_ on stderr |
Largest age of the newest applied record among running shards whose last poll was not empty. A shard without such a record contributes no age. Zero alone does not prove all records were read. |
Without --follow |
Stops with "caught_ after two consecutive checks pass. Every listed closed shard must reach the end of its iterator. Only an open shard can qualify by returning at least --idle-polls consecutive empty polls. This check does not compare ending sequence numbers or fence source writes. |
| Unknown target write | Catch-up stops with status: error and result.. Do not cut over from this run. See how to resume. |
Keep the checkpoint and the original source stream. The local age check refuses first catch-up if the copy start is more than 23 h old. It refuses a resume if the last saved catch-up checkpoint is more than 23 h old. That is one hour inside the 24 h stream retention. Copy again after this refusal, even if the source still has records.
Passing the check does not guarantee the source still has every needed record. Catch-up resumes after the saved sequence number and stops if the source reports that position trimmed. A pause is still necessary for cut-over: an empty poll cannot rule out a writer that is about to commit.
How catch-up converges¶
| Moment | Source item k | Copy (Scan) | Stream | Catch-up | Target item k | Why |
|---|---|---|---|---|---|---|
| Before the copy | v1 | r1 | The source stream already holds r1. Pictured: records carry new images and arrive on separate pages. | |||
| Copy starts | v2 | writes k = v2 | r2 | v2 (copy) | The copy reads k after it changed to v2. | |
| Later | v3 | r3 | Clients still write to the source. | |||
| Catch-up applies r1 | r1 | v1 | After the copy finishes, catch-up reads r1, which was recorded before the copy. A replayed older record can overwrite a newer copied item. | |||
| Apply r2 | r2 | v2 | ||||
| Apply r3 | r3 | v3 | ||||
| Writes paused, drain done | paused at v3 | v3 = source | After the pause and drain, k is v3 on both sides; verify both tables before switching. |
The target passes through v1 and v2 again only when r1, r2 and r3 come on separate pages; on one page only r3 is written.
| Step | Rule |
|---|---|
| Shard order | A shard whose parent is in the checkpoint and not done waits for that parent: closed and read to the end of its iterator. A shard whose parent is not in the checkpoint starts at once. Shards that do not wait are read in parallel. DynamoDB Streams writes each change once, in the order of the item's changes, and a parent shard comes before its children (Streams). |
| Start | A shard with no saved sequence number, on the first run or first seen on a resume: TRIM_, the oldest retained record. Otherwise: after the shard's saved sequence number. An expired iterator is opened again from that number. |
| Page | Up to 1,000 records per Get. For each key, only the record with the highest sequence number in the page is written, so a key appears at most once in a page's writes. |
| Write | REMOVE: delete the key, with no image and no source read. Other records on a NEW_IMAGE or NEW_ stream: put the record's new image. A new image over the item size limit, and every record on a KEYS_ONLY or OLD_IMAGE stream: one strongly consistent source GetItem, then put the item's current state, which can be newer than the record, or delete the key if the item is gone. If the current item is still over the limit, catch-up stops with the size error. Batch calls carry up to 25 requests, with at most --writers calls in flight. |
| Old oversized records | The stream keeps 24 h of history from before the copy. It can hold items that you deleted or shrank after sizes. Their images are over the limit, so catch-up reads the current source item instead (the Write row) and does not stop. |
| Checkpoint | After a page's writes succeed, the shard's last sequence number. The file is written at most once per second, and at once when a shard ends and when the run exits. After a crash, catch-up replays the pages after the last written checkpoint. |
| Gap | A shard that is in the checkpoint, not done and no longer listed by the stream, or a trimmed position, stops catch-up: copy again. |
Every write replaces the whole item or deletes it. After catch-up writes a key's last record, the target holds the source item as of that record. It can also hold a later state read from the source. This holds whatever the copy wrote.
The 23 h age check does not prove that the stream still holds every record.
A gap that catch-up can see stops it (the Gap row). A first read from
TRIM_HORIZON cannot tell that older records are gone, so verify is the
check. Before the drain, a replayed older record can overwrite a newer
copied item. So the target can show an older value for a key during
--follow.
A comparison in step 4 of the
checklist can show these differences. The target
matches the source only after the pause and the drain. It also needs three
conditions: catch-up found no gap, nothing else wrote to the target, and no
batch with an unknown outcome can still run. Run verify before switching anyway: a
key that exists only on the target, and that neither the copy nor the
stream touched, survives catch-up. See the
catch-up code.
Verify¶
dynodb migrate verify --table orders --segments 64 --sample-rate 0.01 \
--source-region us-east-1 --source-profile prod-readonly \
--target-endpoint https://fdyno.internal:8000
| Check | Rule |
|---|---|
| Counts and digest | Counts both tables. The order-independent digest normalizes numbers and set/map order. --digest= still counts both tables and can sample, but does not compare all item contents. |
| Sample | Reads random source keys from fdyno; reports missing or different items. |
| TTL | If the source reports a TTL attribute and TTL is not disabled, both scans skip near-expiry rows. The upper limit is the start time plus --ttl-margin (default 10 min, exclusive). Verification defers comparison of visible rows from five years before the start minus --target-ttl-skew-margin through the five-year boundary, inclusive. Older values such as TTL=0 stay in the comparison. |
| Exit | 0: equal; 2: difference. Live source writes can cause differences; run the exact check during the pause. |
Set --target-ttl-skew-margin to match the target's DYNODB_TTL_SKEW_MARGIN
(default 60 s; 0 disables deferral). If either scan finds boundary rows,
ttl_boundary reports separate source and target counts and a UTC recheck
time. The result can say equal for the compared rows and still report
pending boundary rows. Keep source writes paused and repeat verify after the
reported time before switching.
Counts and digests cover only rows each endpoint returns from Scan. Both
endpoints can hide a boundary row, so no warning does not prove that there are
no such rows. If you know of hidden boundary rows, recheck when Scan can see
them. See TTL visibility.
Cut-over checklist¶
- Run
sizes. Ifover_limitis not 0, shrink, split or delete those items on the source, and runsizesagain. - Run
schema, thencopyto"status": "ok". - Run
catchup --followuntillag_secondsstays near zero. - Optionally compare read-only traffic on fdyno.
- Stop source writes: application read-only mode or remove role write permission.
- Stop
--followwith SIGINT and wait for a clean exit. Runcatchupto"caught_up": true. On an unknown target write, stop here. - Run
verify. Require"equal": trueand recheck any deferred TTL boundary rows before switching. - Switch clients to fdyno with fdyno credentials; resume writes.
- Keep the source and stream until rollback is unnecessary.
The pause covers steps 5–8: drain remaining records and fully scan both tables. Keep the digest enabled for this check. Equal counts alone can miss a replaced or changed item. The migration drill checks both a missing item and a changed item.
Resume after an unknown target write¶
Copy, import and catch-up stop rather than retry a target BatchWriteItem
whose outcome is unknown. Examples are a timeout, a connection reset or any
HTTP 5xx response.
Only HTTP 200 can acknowledge a batch. A proxy reply
of 202 Accepted, like any other 2xx or 3xx response except HTTP 200,
leaves the outcome unknown and does not advance the checkpoint. The client
never follows a target write redirect. The target writer
retries only UnprocessedItems and explicit throttles that rejected the
whole request. On a planned stop, the client waits for dispatched writes
within their existing two-minute attempt timeouts.
Do not resume or cut over while an earlier request can still run. Stop the old migration process. Confirm that the target and any proxy have no earlier requests queued or running. The client timeout alone cannot prove that: a proxy could still deliver a delayed write that overwrites a newer one. After the requests have drained, resume from the checkpoint. With source writes paused, complete catch-up and verify before switching.
Not guaranteed¶
- ARNs, creation time and source stream records do not carry over.
- The target stream records copy/catch-up writes. To avoid this, use
--stream off, then enable it withUpdateTablebefore step 8. - Each item and its indexes must fit one fdyno write.
sizescounts the items that do not fit. - A target write with an unknown outcome stops the run; it is not retried. See unknown target writes.
- Do not write to the target before cut-over. Catch-up does not merge two sides.
Test against AWS DynamoDB (2026-11-30, main 8e7cc99de plus the old-oversized-records fix): the source was an on-demand table in us-east-2 with 2 GSIs, 1 LSI, TTL and a NEW_AND_OLD_IMAGES stream. It held 20,000 items of all attribute types; 50 were near the limit and 7 were over it. sizes found the 7; we deleted them. Then schema, then copy (18,768 items in 1.3 s) while a writer sent puts, updates, deletes and transactions for 120 s. Then catchup (29,813 records, caught_up true) and verify (equal true). An independent compare found 0 missing, 0 extra and 0 different items, equal DescribeTable and TTL settings, and equal results for 253 index queries. One strongly consistent full scan of that table used about 6,300 read units.
1 GB test with live writes¶
Test against AWS DynamoDB (2026-11-30, run dynb-mig-1g-1, main 54cc5a94d). The source was an on-demand table in us-east-2 with 1 GSI, TTL and a NEW_AND_OLD_IMAGES stream. It held 250,000 items, about 1.06 GB. Item sizes: 190,626 under 4 KiB, 40,737 from 4 to 16 KiB, 18,637 from 16 KiB to 46,271 bytes. dynodb migrate and an fdyno target ran on one 32-vCPU host in us-east-1, so every source read crossed regions.
A writer sent puts, updates, deletes and two-item transactions to the source at 191 operations per second. It started 5 s before copy and stopped 5 minutes after catchup --follow started.
| Step | Result |
|---|---|
sizes |
250,000 items in 10.9 s; 0 over the limit |
copy (16 segments, 32 writers) |
249,598 items in 28.5 s: about 8,800 items/s, about 37 MB/s |
catchup --follow |
69,387 stream records in 340 s, 24 shards. The records written during copy (about 8,800) were applied within the first 10 s after follow started. |
| Lag, one source write per second, timed until it was visible on fdyno | 290 samples while follow ran: median 0.52 s, p95 1.05 s, maximum 1.25 s. The 1 s --poll-interval sets most of this. |
| Cut-over | Writes stopped; follow drained; catchup found 0 new records in 3.2 s; verify scanned both tables in 10.6 s, equal true (239,484 items each). |
| Independent compare | 0 missing, 0 extra, 0 different items. Count and hash equal in each of 16 key-hash buckets. Each of the 62,510 keys that the writer last changed holds the writer's last acknowledged value or is absent after an acknowledged delete. Equal Describe and TTL settings. 100 index queries (238,807 rows) equal. |
The source showed 2,163 items whose TTL had passed and that DynamoDB had not deleted yet. fdyno does not return such items; verify and the compare do not count them. The test used 1,924,009 write units and 1,019,529 read units, about $1.33 at on-demand list price. Most of that was loading the source.
How we know: migration copy, replay and export-import drill.