定義
構文
配置用にchangeStreamOptionsを設定するには、 adminデータベースで次のコマンドを実行します。
db.adminCommand( { setClusterParameter: { changeStreamOptions: <value> } } )
changeStreamOptionsクラスター パラメータの現在の値を表示するには、 adminデータベースで次のコマンドを実行します。
db.adminCommand( { getClusterParameter: "changeStreamOptions" } )
パラメーター フィールド
changeStreamOptions.preAndPostImages.expireAfterSecondsバージョン6.0の新機能。
デフォルト: オフ
変更ストリームの変更前と変更後のイメージの保持ポリシーを制御します。 変更前と変更後のイメージは、それぞれドキュメント変更前と変更後のドキュメントのバージョンです。
expireAfterSecondsは、MongoDB が変更前と変更後のイメージを保持する期間を制御します。expireAfterSecondsがoffの場合、MongoDB はデフォルトの保持ポリシーを使用します。対応する変更ストリーム イベントがoplog から削除されるまで、変更前と変更後のイメージは保持されます。変更前と変更後のイメージの最小保持時間を設定するには、
expireAfterSecondsの整数値を指定します。重要
Services that use change streams, including Triggers and Device Sync, might rely on the availability of pre-image data. If you set
expireAfterSecondstoo low, you may increase the risk of interrupting sync or triggers processing.変更前イメージに
expireAfterSecondsを設定する場合は、以下を確認します。サービスの通常の変更ストリームの遅延よりも小さくない値を指定します。
oplogデータが失われるリスクを負うことなく、サービスが手動で再開できるようにバッファ時間を追加します。
動作
If a change stream event is removed from the oplog, then the corresponding pre- and post-images are also deleted regardless of the retention time specified with changeStreamOptions.preAndPostImages.expireAfterSeconds.
例
次の例では、変更ストリーム内の変更前と変更後のイメージの保持時間を100秒に設定します。
db.runCommand( { setClusterParameter: { changeStreamOptions: { preAndPostImages: { expireAfterSeconds: 100 } } } } )