버전 5.0에서 변경되었습니다.
읽기 고려 "snapshot"가 설정된 쿼리는 최근에 있었던 특정 단일 시점에 샤드 전체에 표시된 과반수 이상이 커밋한 데이터를 반환합니다. 읽기 고려 "snapshot"는 트랜잭션이 쓰기 고려 "majority"로 커밋되는 경우에만 보장을 제공합니다.
읽기 고려 "snapshot"은 다중 문서 트랜잭션에 사용할 수 있으며, MongoDB 5.0부터는 다중 문서 트랜잭션 외부의 특정 읽기 작업에 사용할 수 있습니다.
트랜잭션이 인과적으로 일관적인 세션의 일부가 아닌 경우, 쓰기 고려
"majority"로 트랜잭션을 커밋하면 트랜잭션 작업은 과반수 이상이 커밋한 데이터의 스냅샷에서 읽기를 보장합니다.트랜잭션이 인과적으로 일관적인 세션의 일부인 경우, 쓰기 고려
"majority"로 트랜잭션을 커밋하면 트랜잭션 작업은 트랜잭션 시작 직전의 작업에 인과적 일관성을 제공하는 과반수 이상이 커밋한 데이터의 스냅샷에서 읽기를 보장합니다.
중요
"snapshot" 읽기는 minSnapshotHistoryWindowInSeconds로 지정된 기간 내에만 수행할 수 있습니다. minSnapshotHistoryWindowInSeconds 이상 지속되는 읽기 작업은 종료될 수 있습니다.
Outside of multi-document transactions, read concern "snapshot" is available on primaries and secondaries for the following read operations:
distinct(샤딩되지 않은 컬렉션에서)
All other read commands prohibit "snapshot".
운영
읽기 고려를 허용하는 모든 작업의 목록은 읽기 고려를 지원하는 작업을 참조하세요.
읽기 고려 및 트랜잭션
Multi-document transactions support read concern "snapshot" as well as "local", and "majority".
참고
개별 작업 수준이 아닌 트랜잭션 수준에서 읽기 문제를 설정합니다. 트랜잭션에 대한 읽기 문제를 설정하려면 트랜잭션 및 읽기 문제를 참조하십시오.
읽기 고려 및 atClusterTime
Outside of multi-document transactions, reads with read concern "snapshot" support the optional parameter atClusterTime. The parameter atClusterTime allows you to specify the timestamp for the read. To satisfy a read request with a specified atClusterTime of T, the mongod performs the request based on the data available at time T. If the mongod has not yet reached time T in its oplog, it waits to service the request.
팁
지연되는 복제본 세트 노드로 읽기가 지정되는 경우 maxTimeMS 를 사용하여 지정된 atClusterTime로 읽기의 대기 시간을 제한할 수 있습니다. maxTimeMS 는 작업이 무기한으로 차단되지 않도록 하고, 대신 mongod 가 지정된 atClusterTime 에 시간 내에 도달하지 못하는 경우 오류를 반환합니다.
db.runCommand()의 응답 또는 Session() 객체에서 연산의 operationTime 또는 clusterTime을 얻을 수 있습니다.
The following command performs a find operation with read concern "snapshot" and specifies that the operation should read data from the snapshot at cluster time Timestamp(1613577600, 1).
db.runCommand( { find: "restaurants", filter: { _id: 5 }, readConcern: { level: "snapshot", atClusterTime: Timestamp(1613577600, 1) }, } )
매개변수 atClusterTime을 제공하지 않으면 mongos 또는 단일 멤버 복제본에서 mongod를 설정하고, 가장 최근에 커밋된 스냅샷의 타임스탬프를 atClusterTime으로 선택한 후 클라이언트에 반환합니다.
Outside of transactions, "snapshot" reads are guaranteed to read from majority-committed data.
atClusterTime 고려 사항 및 동작
The allowed values for
atClusterTimedepend on theminSnapshotHistoryWindowInSecondsparameter.minSnapshotHistoryWindowInSecondsis the minimum time window in seconds for which the storage engine keeps the snapshot history. If you specify an atClusterTime value older than the oldest snapshot retained according tominSnapshotHistoryWindowInSeconds,mongodreturns an error.If you perform a read operation with
"snapshot"without specifyingatClusterTimeagainst a delayed replica set member, the returned majority-committed data could be stale. If you specifyatClusterTime, themongodwaits for the specified timestamp instead of returning stale data, though the read may block or time out.It is not possible to specify
atClusterTimefor"snapshot"inside of causally consistent sessions.
고정 사이즈 컬렉션의 읽기 고려
MongoDB 부터는 고정 사이즈 8.0 "snapshot" 컬렉션에 읽기 고려 (read concern) 사용할 수 있습니다.