Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Fix load_shards_from_disk/2
load_shards_from_disk/2 did not expect #ordered_shards to be returned
from load_shards_from_disk/1. Since it uses a list comprehension the
mistake is silently squashed, resulting in an empty list.

In production this manifests are the occasional failure, where 'n' is
calculated as 0, causing quorum reads to fail. The very next call
succeeds as it reads the cached versions and correctly downcasts.

BugzID: 20629
  • Loading branch information
Robert Newson authored and rnewson committed Jul 23, 2014
1 parent 1d50774 commit c9292bb3a204bd14ada2f28d5f7b3d7d96c88152
Showing 1 changed file with 5 additions and 1 deletion.
@@ -278,7 +278,11 @@ load_shards_from_db(#db{} = ShardDb, DbName) ->
load_shards_from_disk(DbName, DocId)->
Shards = load_shards_from_disk(DbName),
HashKey = mem3_util:hash(DocId),
[S || #shard{range = [B,E]} = S <- Shards, B =< HashKey, HashKey =< E].
[S || S <- Shards, in_range(S, HashKey)].

in_range(Shard, HashKey) ->
[B, E] = mem3:range(Shard),
B =< HashKey andalso HashKey =< E.

create_if_missing(Name) ->
DbDir = config:get("couchdb", "database_dir"),

0 comments on commit c9292bb

Please sign in to comment.