문서 탐색 열기
R2D1 / 문서

일관성과 복구

R2D1은 두 store를 하나의 distributed transaction인 것처럼 가장하지 않습니다. DocumentStore는 content와 logical existence의 권위 있는 원본이고, IndexStore는 rebuildable materialized projection입니다.

Mutation 순서

두 mutation path 모두 authoritative document를 먼저 변경합니다. 이 순서라야 authoritative scan만으로 복구할 수 있습니다.

PUT:    DocumentStore.put    -> IndexStore.upsert
DELETE: DocumentStore.delete -> IndexStore.delete

PartialFailure

첫 단계가 성공하고 두 번째 단계가 실패하면 PersistenceException.PartialFailure이 발생합니다. 예외에는 영향을 받은 DocumentKey와 두 번째 단계의 원인이 남습니다. 자동 rollback, retry, compensating write는 없습니다.

예를 들어 authoritative delete 뒤 index cleanup이 실패하면 get(id)는 문서를 absent로 보고하지만 stale index row는 query에서 PersistenceException.InconsistentState를 만들 수 있습니다. stale row를 조용히 건너뛰지 않습니다.

Index projection 재구축

기반 failure를 해결한 뒤 collection에서 rebuildIndex()를 호출합니다. authoritative document key를 bounded page로 나열하고 각 document를 읽어 metadata로 index entry를 만든 뒤 derived rows만 교체합니다.

users.rebuildIndex();

비원자적 작업

rebuildIndex()는 unchanged collection에 대해 다시 실행할 수 있지만 atomic하지 않습니다. rows를 clear한 뒤 실패하면 projection이 불완전할 수 있으므로 collection write를 멈추고 failure를 해결한 다음 다시 실행하세요.

이 contract는 distributed transaction, background repair, automatic retry, concurrent rebuild coordination, lost-update prevention 또는 power-loss durability를 제공하지 않습니다.