Why AWS DMS Reports Error 1032 and How to Investigate It
公開日 2026-08-13 · 更新日 2026-08-13 · 最終検証日 2026-08-13
結論
MySQL Error 1032 is `ER_KEY_NOT_FOUND`, and in a DMS CDC task it means "the target-side row that a change was supposed to apply to does not exist." The cause is almost always one of: a gap at the boundary between the full load and CDC, a primary key mismatch between source and target, a target table with no primary key, rows excluded by a filter or transformation rule, or another process writing to the target. Start by reading `awsdms_apply_exceptions` on the target to identify the failed statement and the target key.
この文書の適用条件
| 対象製品 | AWS DMS (target: Aurora MySQL / RDS for MySQL) |
|---|---|
| 確認バージョン | MySQL 5.7-compatible / 8.0-compatible targets. DMS task setting names vary by the replication instance's engine version, so verify using the actual task's JSON |
| 適用環境 | AWS (DMS replication instance + Aurora MySQL target) |
| 必要権限 | Reading the control tables requires `SELECT` on the target DB. Changing task settings requires IAM `dms:ModifyReplicationTask` |
| 実行影響 | No impact for reading control tables. Changing task settings involves stopping and resuming the task |
| 再起動 | No DB restart required. Changing task settings requires stopping and resuming the DMS task |
| 最終検証日 | 2026-08-13 |
そのまま実行できるコマンド
- 対象
- Aurora MySQL / RDS for MySQL (DMS target)
- 権限
- Connection privilege on the target DB
- 変更作業
- None (read-only)
- Production実行
- Possible
-- 対象: Aurora MySQL / RDS for MySQL(DMSターゲット)
-- 権限: ターゲットDBへの接続権限
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_ROWS
FROM information_schema.TABLES
WHERE TABLE_NAME IN (
'awsdms_apply_exceptions',
'awsdms_validation_failures_v1',
'awsdms_status',
'awsdms_suspended_tables',
'awsdms_history'
)
ORDER BY TABLE_SCHEMA, TABLE_NAME;The schema where the control tables are created is determined by the task setting `ControlSchema`. Left at its default, which schema they end up in on the target varies by environment, so check the actual placement with this SQL first, then substitute the schema name in the next queries.
- 対象
- Control schema on the DMS target
- 権限
- `SELECT` on the control schema
- 変更作業
- None (read-only)
- Production実行
- Possible
-- 対象: DMSターゲット上の制御スキーマ(既定名は ControlSchema 設定に依存)
-- 権限: 制御スキーマへの SELECT
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
SELECT
TASK_NAME,
TABLE_OWNER,
TABLE_NAME,
ERROR_TIME,
LEFT(STATEMENT, 500) AS statement_head,
LEFT(ERROR, 500) AS error_head
FROM awsdms_control.awsdms_apply_exceptions
ORDER BY ERROR_TIME DESC
LIMIT 50;`STATEMENT` contains the failed UPDATE/DELETE statement, and `ERROR` contains the error text returned by the engine (including 1032). The value appearing in the `WHERE` clause of `STATEMENT` is the key that did not exist on the target.
- 対象
- Control schema on the DMS target (generated only when `EnableValidation` is on)
- 権限
- `SELECT` on the control schema
- 変更作業
- None (read-only)
- Production実行
- Possible
-- 対象: DMSターゲット上の制御スキーマ(EnableValidation 有効時のみ生成)
-- 権限: 制御スキーマへの SELECT
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
SELECT
TASK_NAME,
TABLE_OWNER,
TABLE_NAME,
FAILURE_TIME,
KEY_TYPE,
`KEY` AS row_key,
FAILURE_TYPE,
LEFT(DETAILS, 500) AS details_head
FROM awsdms_control.awsdms_validation_failures_v1
ORDER BY FAILURE_TIME DESC
LIMIT 50;`KEY` is a MySQL reserved word, so it's wrapped in backticks. If a table reporting 1032 also shows up here, it's not a one-off apply failure — the data itself has diverged.
- 対象
- Both the source and target MySQL-compatible DBs
- 権限
- Metadata read privilege on the target schema
- 変更作業
- None (read-only)
- Production実行
- Possible
-- 対象: ソース・ターゲット双方で同じSQLを実行して結果を比較する
-- 権限: 対象スキーマのメタデータ参照権限
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
SELECT
t.TABLE_SCHEMA,
t.TABLE_NAME,
(SELECT GROUP_CONCAT(k.COLUMN_NAME ORDER BY k.ORDINAL_POSITION)
FROM information_schema.KEY_COLUMN_USAGE k
WHERE k.TABLE_SCHEMA = t.TABLE_SCHEMA
AND k.TABLE_NAME = t.TABLE_NAME
AND k.CONSTRAINT_NAME = 'PRIMARY') AS pk_columns,
(SELECT COUNT(DISTINCT s.INDEX_NAME)
FROM information_schema.STATISTICS s
WHERE s.TABLE_SCHEMA = t.TABLE_SCHEMA
AND s.TABLE_NAME = t.TABLE_NAME
AND s.NON_UNIQUE = 0) AS unique_index_count
FROM information_schema.TABLES t
WHERE t.TABLE_SCHEMA = 'SampleDB'
AND t.TABLE_TYPE = 'BASE TABLE'
ORDER BY t.TABLE_NAME;A table where `pk_columns` is NULL has no primary key. For a table with no primary key, DMS looks up the target row by matching every column for CDC UPDATE/DELETE, which makes 1032 more likely due to differences in floating-point representation, character encoding, or LOB handling. The same applies when `pk_columns` differs between source and target.
- 対象
- Aurora MySQL on the DMS target
- 権限
- `SELECT` on the target table
- 変更作業
- None (read-only)
- Production実行
- Possible
-- 対象: DMSターゲットのAurora MySQL
-- 権限: 対象テーブルへの SELECT
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
-- awsdms_apply_exceptions の STATEMENT に出ていたキー値をそのまま当てる
SELECT COUNT(*) AS target_row_count
FROM SampleDB.sample_table
WHERE id = 1001;
-- 併せてソース側でも同じ条件で確認し、片方にしか無いのかを判定する
SELECT COUNT(*) AS source_row_count
FROM SampleDB.sample_table
WHERE id = 1001;If the row exists on the source but not the target, it's either a full-load gap or a filter exclusion. If it exists on neither, it can be judged as a delayed change arriving for an already-deleted row (an ordering issue).
- 対象
- AWS DMS replication task
- 権限
- IAM: `dms:DescribeReplicationTasks`
- 変更作業
- None (read-only)
- Production実行
- Possible
# 対象: AWS DMS レプリケーションタスク
# 権限: IAM dms:DescribeReplicationTasks
# 変更作業: なし(参照のみ)
# Production 実行: 可能
# 1) タスク一覧と状態
aws dms describe-replication-tasks \
--query 'ReplicationTasks[].{Id:ReplicationTaskIdentifier,Type:MigrationType,Status:Status}' \
--output table
# 2) 対象タスクの設定JSONをそのまま取り出す(設定名の実体はここで確認する)
aws dms describe-replication-tasks \
--filters Name=replication-task-id,Values=example-dms-task \
--query 'ReplicationTasks[0].ReplicationTaskSettings' \
--output textWhich DMS task settings are available varies by version. Don't take the setting names in this article at face value — output the actual task's JSON with this command and edit only the fields that exist. Task logs are written to the `dms-tasks-<replication-instance-name>` CloudWatch Logs log group.
- 対象
- AWS DMS replication task settings
- 権限
- IAM: `dms:ModifyReplicationTask` (requires stopping the task)
- 変更作業
- Yes (changes behavior on apply errors; IGNORE_RECORD discards the change)
- Production実行
- Only with a clear understanding of the impact. `IGNORE_RECORD` causes data divergence
// 対象: AWS DMS レプリケーションタスク設定(抜粋)
// 権限: IAM dms:ModifyReplicationTask(変更にはタスク停止が必要)
// 変更作業: あり(適用エラー時の挙動が変わる)
// Production 実行: 影響を理解したうえでのみ。IGNORE_RECORD は変更を黙って捨てる
{
"TargetMetadata": {
"TargetTablePrepMode": "DO_NOTHING"
},
"ErrorBehavior": {
"ApplyErrorInsertPolicy": "LOG_ERROR",
"ApplyErrorUpdatePolicy": "LOG_ERROR",
"ApplyErrorDeletePolicy": "IGNORE_RECORD",
"ApplyErrorEscalationPolicy": "LOG_ERROR",
"ApplyErrorEscalationCount": 0,
"TableErrorPolicy": "SUSPEND_TABLE"
},
"ValidationSettings": {
"EnableValidation": true,
"ValidationMode": "ROW_LEVEL",
"ThreadCount": 5
}
}Setting `ApplyErrorDeletePolicy` to `IGNORE_RECORD` silently discards changes that could not be deleted, without recording them. The error stops, but the source and target data diverge. Keep it at `LOG_ERROR` until you've finished isolating the cause, and if you do switch to `IGNORE_RECORD`, first make sure you can track "which table, which period of changes was discarded" through validation. Setting `TargetTablePrepMode` to `DROP_AND_CREATE` recreates the target table during a full load, losing existing data.
結果の読み方
| 列 | 意味 | 確認するポイント |
|---|---|---|
| TASK_NAME | Name of the DMS task that recorded the error | Check whether multiple tasks are writing to the same target |
| TABLE_OWNER | Schema (owner) of the target table | Whether this is the expected migration target schema |
| TABLE_NAME | Target table name | If concentrated on one table, suspect that table's primary key definition and mapping |
| ERROR_TIME | Time the error occurred | Whether errors cluster right after full-load completion or a task resume |
| statement_head | Beginning of the failed statement | Whether it is UPDATE or DELETE, and which key value is used in the WHERE clause |
| error_head | Error text returned by the engine | Whether anything other than 1032 (such as 1062 duplicate key) is mixed in |
| row_key (validation side) | Key value of the mismatched row | Query the same key on the source to check which side it actually exists on |
| FAILURE_TYPE (validation side) | Type of mismatch | The response differs depending on whether it is a missing row or a value difference |
こういう状況で使います
- The DMS task log repeatedly shows `Error 1032` or `ER_KEY_NOT_FOUND`
- Errors increase right after entering the CDC phase, and only a specific table is stuck
- The task status stays `Running`, but the target's row count never catches up with the source
- The DMS console's table statistics show a specific table as `Table error` / suspended
- After enabling validation, a large number of rows appeared in `awsdms_validation_failures_v1`
考えられる原因(可能性の高い順)
01
The target row was never loaded at the full-load/CDC boundary
A row inserted after the full-load snapshot and later updated or deleted may not exist on the target even if the CDC update arrives first. Check the relationship between the task start position and the full-load completion time.
02
The primary key / unique key doesn't match between source and target
If the target's primary key column differs, or the primary key has been redefined, the WHERE clause DMS generates won't match the target row. Cross-check `KEY_COLUMN_USAGE` on both sides.
03
The target table has no primary key
Without a primary key, DMS looks up the target row by matching all columns. Differences in floating-point representation, character encoding, or LOB handling can cause a mismatch, resulting in 1032. Tables targeted for CDC are expected to have a primary key or unique key.
04
Rows or columns are excluded by selection/transformation rules
If table mapping filters migrate only some rows, a CDC update for an excluded row arrives but doesn't exist on the target, causing an error. Column renaming or exclusion has the same effect.
05
Another process is writing to the target
If the application, another DMS task, or a batch job writes to the target, it breaks the row state DMS assumes. As a rule, writes to a migrating target should be limited to DMS alone.
06
The binlog was purged sooner than needed, causing a gap in changes
If the source's binlog retention period is too short, CDC can miss reads, and applying changes can start from an inconsistent state upon resume. See the related article for checking retention time.
確認手順
- 1
Check the substance of the error via the control tables
参照のみRead `awsdms_apply_exceptions` in descending time order to identify the target table, statement, and key value. This is read-only and safe.
- 2
Check the task log in CloudWatch Logs
参照のみIn the `dms-tasks-<replication-instance-name>` log group, check what happened around the error (resume, table suspension, connection drop).
- 3
Cross-check the primary key definitions between source and target
参照のみRun the metadata SQL above on both sides and check whether `pk_columns` match and whether any table shows NULL.
- 4
Check whether the row for the given key exists on both source and target
参照のみWhich side it exists on determines whether this is a load gap or an ordering issue.
- 5
Check the task's table mapping and settings JSON
参照のみPull the actual settings with `describe-replication-tasks` and check the current values of filters, transformation rules, and `ErrorBehavior`.
- 6
Enable validation to measure the extent of the divergence
中Enabling `EnableValidation` puts comparison load on both source and target. Run it during a window that can tolerate the load.
対応方法
すぐに実施できる低リスクの対応
Identify the table reporting errors and isolate it
参照のみBefore stopping everything, narrow it down to a specific table with `awsdms_apply_exceptions`. If it is just one table, reloading that table alone often resolves it.
Stop other processes from writing to the target
中If there are writes other than DMS, the issue will recur even after a setting change. First consolidate to a single write path.
事前検討が必要な変更
Add a primary key or unique key to the table
高If the cause is that the CDC target table has no primary key, define a key on the target (and on the source too, if needed). Since this is a schema change, it requires verification in a test environment and scheduling for an appropriate time window.
Reload only the affected table
高Use DMS's "reload table" to rerun a full load for just that table. Since the target table passes through a temporarily inconsistent state, check the impact on readers before doing this.
Review the table mapping filters
中If a row filter migrates only some rows, align it with the range of updates arriving via CDC. If they cannot be aligned, migrate that table without a filter.
再起動・サービス影響を伴う変更
Set `ApplyErrorDeletePolicy` to `IGNORE_RECORD`
中The error stops, but since unapplicable deletes are discarded without being recorded, the data diverges. Do not use this as a "quick fix" before finishing the root-cause investigation.
Recreate the task and re-establish CDC
高If restarting from a full load, first decide how to handle the existing target data (`TargetTablePrepMode`) and the cutover time. Re-establishing CDC is a high-impact operation.
!注意事項
- `ApplyErrorDeletePolicy = IGNORE_RECORD` silently discards changes that could not be applied. The error disappears from view, but the source and target data diverge. Only make this setting after ensuring you can track the divergence through validation.
- Setting `TargetTablePrepMode` to `DROP_AND_CREATE` drops and recreates the target table during a full load. Existing data is lost.
- Validation places read load on both source and target. Do not enable it abruptly during a production time window.
- The contents of the control tables include part of the migrated data (key values and statements). Handle them carefully when sharing or exporting.
- DMS task setting names vary by version. Some items may be missing from this article or named differently, so always check the actual task JSON before editing.
バージョン・環境による違い
これで解決しない場合に確認すること
Check the source's binlog retention period
If retention is too short and CDC is missing reads, a setting change will not fix it.
Check the DMS replication instance's resources
If CPU, memory, or storage is under pressure, apply delays and task resumes increase, making boundary issues more likely.
Check for cascading updates from triggers or foreign keys on the source
Rows that cascade-update on the source may not be reproduced on the target.
Check whether errors other than 1032 are mixed in
If duplicate key (1062) and others occur at the same time, the cause is a separate issue.
Cross-check the list of migrated tables against the application's write paths
Confirm via actual connection sources — not just the design — that DMS is the only thing writing to the target.
この文書の根拠と限界
製品の公式ドキュメントに基づく説明
Based on the definition of MySQL error code `1032` (`ER_KEY_NOT_FOUND`) and the public specifications of AWS DMS control tables (`awsdms_apply_exceptions`, `awsdms_validation_failures_v1`, and others) and task settings (`ErrorBehavior`, `TargetMetadata`, `ValidationSettings`). Since which settings exist depends on the DMS version, this assumes verification against the actual task's JSON. It does not include any specific customer's migration case.
よくある質問
What causes Error 1032?
It is MySQL's `ER_KEY_NOT_FOUND`, meaning the row that an UPDATE or DELETE was trying to apply to does not exist on the target. In DMS CDC, the main causes are a gap at the full-load/CDC boundary, a primary key mismatch, a table without a primary key, rows excluded by a filter, or another process writing to the target.
Can this be run in production?
All the control table and metadata lookup SQL is read-only and can be run in production as well. Changing task settings involves stopping and resuming the task, and `IGNORE_RECORD` causes data divergence, so check the impact before making these changes.
What permissions are required?
Reading the control tables requires `SELECT` on the target DB; retrieving or changing task settings requires IAM `dms:DescribeReplicationTasks` / `dms:ModifyReplicationTask`.
Does setting ApplyErrorDeletePolicy to IGNORE_RECORD resolve this?
The error stops, but it is not a resolution. Since unapplicable deletes are discarded, the source and target data diverge. Only make this setting after identifying the cause and deciding whether the divergence is acceptable.
How should the results be interpreted?
If the errors in `awsdms_apply_exceptions` are concentrated on a specific table, suspect that table's primary key definition and mapping. If they're spread across many tables and clustered around task resumes, suspect the CDC start position or a binlog gap. If a row exists only on the source, it's a full-load gap.
What should be done about a table with no primary key?
As a rule, you should provision a primary key or unique key if the table is a CDC target. If that is not possible, consider a design change such as synchronizing that one table via repeated full loads, or excluding it from migration and handling it through another means.
この文書がカバーする質問
- DMS CDC cannot apply an UPDATE and the task stops
- How to read awsdms_apply_exceptions
- Can a table with no primary key be migrated via DMS CDC
- How to investigate a mismatch reported by DMS validation
リスク表示の意味
- 参照のみデータと設定を変更しません。
- 低影響は限定的ですが、権限と負荷の確認が必要です。
- 中性能・ロック・コストに影響する可能性があります。
- 高障害・データ損失・復旧作業が発生する可能性があります。
- 専門家レビュー必須本番適用前に別途レビューが必須です。
GIIPの対応範囲
Tracking down a single Error 1032 is as simple as reading the control tables. What's difficult operationally is having to keep watching the task state and divergence status throughout the entire migration period. GIIP periodically collects the trend of DMS task status, error counts, and validation results, and also preserves the control table contents at the moment an error occurs. An AI agent handles the day-to-day isolation and initial reporting, and for decisions that involve data divergence, such as `IGNORE_RECORD`, human approval is always required.
執筆・技術検証
GIIP プロダクション運用チーム
大規模Webサービス、SQL Server、Oracle、AWS、Azureの設計・移行・運用に約30年従事。x12largeクラスのAWS RDS for SQL Server環境12セット、約12万テーブルのOracle環境、約3TBのTiDBからAurora MySQLへの移行を経験。現在も複数のクラウドデータベースと約30のWebサービスを、AIエージェントと人間の専門家が継続的に監視・運用しています。
How to Check and Configure binlog Retention in Aurora MySQL
Check binlog retention with `mysql.rds_show_configuration` and set it in hours via `mysql.rds_set_configuration`. `binlog_format` is a cluster parameter and changing it requires a restart.
database-migrationHow to Plan a 3TB-Scale Database Migration
A 3TB-class migration plan is built in this order: measure actual size, choose a cutover method, measure duration with a trial run, and design verification and rollback. This is a procedure for setting the schedule from measured values rather than rule-of-thumb figures.
sql-serverHow to Check Whether CDC Log Scanning Has Stopped in SQL Server
A procedure for checking whether CDC's log scan is progressing, using sys.dm_cdc_log_scan_sessions, cdc.lsn_time_mapping, and the state of the capture job.
tidbChecklist for Migrating from TiDB to Aurora MySQL
TiDB is MySQL-compatible, but not identical. This organizes the differences in primary keys, ID generation, transactions, statistics, and capacity into a pre-migration checklist with verification SQL.
関連サービス
Request an investigation into a DMS task error
同じ確認を複数の環境で継続する必要がある場合は、運用体制ごと相談できます。
Request an investigation into a DMS task error