apache / apache/couchdb

CouchDB consistent reading document by docId in the cluster with replicas.

Open
#4,508 1 comment 0 reactions 0 assignees View on GitHub
enhancement needs-triage
Dominant language
Erlang
Stars
7k
Forks
1.1k
Avg merge
1d 16h
Merged PRs (30d)
9

Description

I am using CouchDB cluster and my database has 3 replicas. When I write a document to the database, I specify w = 2 in the query parameter. If the response status is 201, then everything is fine and the document is present on most replicas. If the response status is 202, then I do not consider this write successful, because on subsequent reading (r = 2) I can get data from most of the non-updated replicas. Thus, I classify this document as garbage and make a new write attempt (without docId or with a new docId).
But I have a problem with read consistency. Even if a document is stored on most replicas, there is a chance that it has not replicated to all replicas. And at the time of reading, I will get the result from the non-updated replica. Even if I specify r = 3 in the query, it may turn out that only a non-updated replica is available at that moment and the result will return only from it with a status of 200. Thus, I have no way to know that the read returned the old data, because the status the response was 200.

Is it possible to make some mechanism so that if some of the replicas are unavailable(f.e. r = 3, but success reading was from only 1), a status other than 200 is returned when reading?

Contributor guide

Open the contributing guide

Research direction

No files, tests, or code entry points are named. Start by reproducing the cluster scenario with w=2 and r=3, then investigate how CouchDB reports reads when fewer replicas respond. Done means an unavailable replica is distinguishable from a successful, fully satisfied read without changing the document result.

Written by the indexing model from the issue text.

Assessment

Tech stack
erlang
Domain
databases, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.