定義
getDefaultRWConcernThe
getDefaultRWConcernadministrative command retrieves the global default read or write concern settings.- For sharded clusters, issue the
getDefaultRWConcernon amongos.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
注意
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
コマンドの形式は次のとおりです。
db.adminCommand( { getDefaultRWConcern: 1 , inMemory: <boolean>, comment: <any> } )
コマンドフィールド
コマンドには次のフィールドがあります:
フィールド | タイプ | 説明 |
|---|---|---|
整数 |
| |
ブール値 | 任意。 を 配置のグローバルなデフォルトの読み取りまたは書込み保証 (write concern) のディスク上のコピーを返すには、 を | |
| any | 任意。このコマンドに添付するユーザー指定のコメント。設定すると、このコメントは以下の場所にこのコマンドの記録と合わせて表示されます。
コメントには、有効な BSON 型(string, integer, object, array など)を使用できます。 |
出力
出力には、次のフィールドが含まれる場合があります。
フィールド | タイプ | 説明 |
|---|---|---|
| グローバルなデフォルトの書込み保証 ( write concern ) の構成。 配置にグローバルなデフォルトの書込み保証 (write concern) 設定がない場合、このフィールドは | |
| グローバルのデフォルトの読み取り保証 ( read concern ) の構成。 配置にグローバルなデフォルトの読み取り保証がない場合、このフィールドは | |
文字列 | デフォルトの書込み保証 (write concern) のソース。デフォルトでは、値は | |
文字列 | デフォルトの読み取り保証 (read concern) のソース。デフォルトでは、値は | |
タイムスタンプ | グローバルのデフォルトの読み取りまたは書込み保証 (write concern) 設定が最後に変更されたときの操作タイムスタンプ。 クラスターにデフォルトが設定されている場合は存在します。 | |
日付 | 管理者がグローバルなデフォルトの読み取りまたは書込み保証 (write concern) を最後に設定したウォール クロックの日付。 この値は情報提供であり、最新性の比較には使用しないでください。 | |
日付 |
動作
注意
FeatureCompatibilityVersion 4.4 以上が必要です。
Each mongod in the replica set or sharded cluster must have featureCompatibilityVersion set to at least 4.4 to use getDefaultRWConcern. If you downgrade your deployment's featureCompatibilityVersion from 4.4 to 4.2, all cluster-wide read and write concern defaults are lost, but mongos instances may continue applying the defaults for up to 30 seconds.
レプリカセット
You can issue getDefaultRWConcern against any data-bearing member of the replica set (i.e. not against an arbiter).
セカンダリは、プライマリからの最新の変更をまだ複製していない場合、グローバル デフォルト設定の「古い」バージョンを返すことができます。
シャーディングされたクラスター
setDefaultRWConcernクラスター内の に対してmongos を発行します。
各mongosは、グローバル デフォルト設定のローカル コピーを定期的に更新します。 mongosは、グローバル デフォルト設定を最近更新した後にローカル コピーをまだ更新していない場合、または遅延したコンフィギュレーションサーバーのセカンダリから設定を取得した場合、グローバル デフォルト設定の「古い」バージョンを返すことがあります。
The global default settings do not propagate to the individual shards. You cannot run getDefaultRWConcern against a shard.
アクセス制御
For replica sets or sharded clusters enforcing Authentication on Self-Managed Deployments, getDefaultRWConcern requires that the authenticated user have the getDefaultRWConcern privilege action.
The clusterManager or clusterMonitor built-in roles provides the required privileges to run getDefaultRWConcern.
例
次の操作は、 mongodに対して現在構成されているグローバルのデフォルトの読み取りおよび書込み保証を取得します。
db.adminCommand({ "getDefaultRWConcern": 1 })
この操作は、次のような出力を返します。
{ "defaultWriteConcern" : { "w" : "majority" }, "defaultReadConcern" : { "level" : "majority" }, "defaultWriteConcernSource" : "global", "defaultReadConcernSource" : "global", "updateOpTime" : Timestamp(1586290895, 1), "updateWallClockTime" : ISODate("2020-04-07T20:21:41.849Z"), "localUpdateWallClockTime" : ISODate("2020-04-07T20:21:41.862Z"), "ok" : 1, "$clusterTime" : { ... } "operationTime" : Timestamp(1586290925, 1) }