Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Calculate correct count for consistency check

We were using the non-deleted doc count from the by_id btree, but we
need the count of both undeleted and deleted documents, otherwise the
test fails as deletions aren't accounted for.

Change-Id: Ibbc69d2c60e0ebfc9273bcd9f6a70976a97c0f97
Reviewed-on: http://review.couchbase.org/16805
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
  • Loading branch information...
commit 833f411f836577f3f418ae3958f6cbe0c2298931 1 parent 04fae92
Damien Katz Damienkatz authored
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/couchdb/couch_db_consistency_check.erl
11 src/couchdb/couch_db_consistency_check.erl
View
@@ -103,7 +103,8 @@ check_db_file(Db) ->
true ->
ok
end,
- {ok, CountById, _Id} = couch_db:enum_docs(Db, fun(DocInfo, PrevId) ->
+ {ok, _NonDeletedByIdCount, {_Id, ByIdCount}} = couch_db:enum_docs(Db,
+ fun(DocInfo, {PrevId, ByIdCountAcc}) ->
[{_, DocInfo2}] = ets:lookup(EtsById, DocInfo#doc_info.id),
if DocInfo == DocInfo2 ->
ok;
@@ -120,8 +121,8 @@ check_db_file(Db) ->
[Filename, DocInfo])
end,
true = ets:delete(EtsById, DocInfo#doc_info.id),
- {ok, DocInfo#doc_info.id}
- end, 0, []), % first docid is num, as sorts lower than all strings
+ {ok, {DocInfo#doc_info.id, ByIdCountAcc + 1}}
+ end, {0, 0}, []), % first docid is num, as sorts lower than all strings
case ets:tab2list(EtsById) of
[] ->
ok;
@@ -130,9 +131,9 @@ check_db_file(Db) ->
[Filename, LeftOverDocInfos])
end,
ets:delete(EtsById),
- if CountById /= Count ->
+ if ByIdCount /= Count ->
fatal_error("Count of by id index is not the same as by seq DB ~s ~p ~p",
- [Filename, EncounteredCount, Count]);
+ [Filename, ByIdCount, Count]);
true ->
ok
end.
Please sign in to comment.
Something went wrong with that request. Please try again.