CDCでAI Knowledgeを更新する
- 最終確認日
- 2026-10-06
- 記事ID
- EA-248
要点
Change Data Capture(CDC)は、databaseの変更をAI/RAG knowledgeへ低遅延で届ける経路として利用できます。ただし、CDCを導入しただけでsource databaseからretrieval indexまでexactly-onceに一致するわけではありません。 CDC transportと、document/chunk/embedding/search indexへのmaterializationを別のstate machineとして管理します。
どこまで当てはまるか
CDC対象table/columnがretrieval利用を許可されているとは限りません。 source scope、tenant、data classification、row/field authorizationをmaterialization前に確認します。database access権限とAI retrieval公開範囲を同一視しません。
詳しく理解する
SNAPSHOT AND STREAM
初回snapshotと継続change streamの境界を明示します。 connector/database/versionによってはsnapshotとstreamの切替付近でduplicateが発生し得ます。snapshot完了というcontrol eventだけでduplicate-freeを仮定せず、source positionとevent identityをconsumerへ渡します。
SOURCE POSITION AND DEDUPE
各materializationにsource database/table、entity/aggregate key、source offset/LSN/binlog position、event ID、operation、schema version、transform/chunker version、embedding model/version、materialized-at timestampを結び付けます。 同一eventの再配送をidempotentに処理し、既に適用済みのsource positionより古いeventを無条件に上書きしません。
EXACTLY ONCE BOUNDARY
Kafka Connectにはsource connector向けexactly-once supportがありますが、connector capability、worker configuration、distributed mode等の条件があります。 このexactly-once boundaryをembedding APIやvector/search indexへの外部writeまで拡張して解釈しません。 source→Kafkaがtransactionalでも、Kafka→transform→embedding→indexは別のfailure/transaction domainです。各段階でidempotency、precondition、readbackを設計します。
データ形式の変更と互換性
historical change eventを常にcurrent database schemaでdecodeしません。 Debeziumのようにschema historyを保持する実装では、eventが発生した時点のschemaを再構成する仕組みがあります。schema changeとconsumer rolloutの順序を管理し、未知schemaをsilent coercionしません。
MATERIALIZATION VERSION
database rowをそのままembedding identityにしません。 canonical document生成、chunking、normalization、embedding modelのversionをmaterialization identityへ含めます。transform/versionが変わった場合は、同じsource rowでもrebuild対象として識別します。 UPDATEでは新chunkを追加するだけでなく、旧chunkとの置換関係を確定します。
DELETE AND TOMBSTONE
source delete eventを受信したことと、knowledge surfaceから実際に消えたことを分けます。 delete/tombstoneを処理した後、vector/search index、cache、derived document等の対象をreadbackし、残存がないか確認します。privacy erasureではbackup/retentionを含む別のdata-lifecycle要件も確認します。
LAG AND WATERMARK
connector processがhealthyでもknowledgeがfreshとは限りません。 source positionからtransform、embedding、index commitまでのmaterialization watermarkを持ちます。source-to-index lag、oldest pending event、failed materializationを監視します。
REBUILD AND BACKFILL
full rebuildやbackfillをlive streamと無制御に並走させません。 rebuild開始時のcutover watermarkを固定し、snapshot由来recordとlive eventをdedupeします。rebuild完了後にwatermark以降のchangeを確実に適用してから切り替えます。
RECONCILIATION
CDC streamだけを唯一のcorrectness detectorにしません。 定期的にsource-of-truthとknowledge indexをreconcileし、entity inventory、version、hash/count、sampled content、delete stateを比較します。 missed event、offset rewind、transform failure、index partial write、stale chunkを検出した場合は、対象entityまたはbounded rangeを再materializeします。
よくある失敗・反証
snapshot/stream duplicate、source-log loss、offset rewind/loss、connector restart、schema evolution、key change、out-of-order/duplicate event、delete loss、transform/embed/index failure、stale chunk、model-version drift、lag、rebuild/live race、poison event、ACL drift、PII deletion residual、index eventual consistencyを想定します。
まだ確認できていないこと
対象database、CDC connector/version、managed CDC、log retention、snapshot mode、offset形式、schema history/registry、index/vector store、chunk/embed model、ACL propagation、delete/retention、RPO/RTO、rebuild procedure、reconciliation SLOは未確認です。
根拠資料
この根拠欄には、主張に対応づけて登録された外部出典がありません。本文中の引用・参考資料がある場合は、適用条件や未確認事項とあわせて確認してください。
このページから探す
種類
主題
やりたいこと
読み終えたら、次の判断へ
この記事で確かめた条件を、関連する用語・道具・手段・運用知識に接続して確認できます。実装や更新の判断には、各記事の確認時点・根拠・未確認事項を引き継いでください。
最初の知見から実務判断まで、3つの読み方を見る