diff options
author | jiangphcn <jiangph@cn.ibm.com> | 2018-04-23 12:20:00 +0800 |
---|---|---|
committer | jiangphcn <jiangph@cn.ibm.com> | 2018-05-02 16:36:43 +0800 |
commit | e63917da77a0aca6e48ce1233299a8a804eebcd0 (patch) | |
tree | 4b1474b3c1a719601e600614cf79bca40d2f7d50 | |
parent | 168c694bec1af1d8b5d2837d4ccedeb8b275c7e6 (diff) | |
download | couchdb-e63917da77a0aca6e48ce1233299a8a804eebcd0.tar.gz |
Fix test failure of upgrade_test_
COUCHDB-3326
-rw-r--r-- | src/couch/src/couch_bt_engine.erl | 33 | ||||
-rw-r--r-- | src/couch/test/couchdb_views_tests.erl | 2 |
2 files changed, 19 insertions, 16 deletions
diff --git a/src/couch/src/couch_bt_engine.erl b/src/couch/src/couch_bt_engine.erl index c4ee73bc9..bfecca0b5 100644 --- a/src/couch/src/couch_bt_engine.erl +++ b/src/couch/src/couch_bt_engine.erl @@ -899,33 +899,36 @@ upgrade_purge_info(Fd, Header) -> PurgeSeq when is_integer(PurgeSeq)-> % Pointer to old purged ids/revs is in purge_seq_tree_state Ptr = couch_bt_engine_header:get(Header, purge_seq_tree_state), - {ok, PurgedIdsRevs} = couch_file:pread_term(Fd, Ptr), - {Infos, NewSeq} = lists:foldl(fun({Id, Revs}, {InfoAcc, PSeq}) -> - Info = {PSeq, couch_uuids:random(), Id, Revs}, - {[Info | InfoAcc], PSeq + 1} - end, {[], PurgeSeq}, PurgedIdsRevs), + case Ptr of nil -> Header; _ -> + {ok, PurgedIdsRevs} = couch_file:pread_term(Fd, Ptr), - {ok, PurgeTree} = couch_btree:open(nil, Fd, [ + {Infos, NewSeq} = lists:foldl(fun({Id, Revs}, {InfoAcc, PSeq}) -> + Info = {PSeq, couch_uuids:random(), Id, Revs}, + {[Info | InfoAcc], PSeq + 1} + end, {[], PurgeSeq}, PurgedIdsRevs), + + {ok, PurgeTree} = couch_btree:open(nil, Fd, [ {split, fun ?MODULE:purge_tree_split/1}, {join, fun ?MODULE:purge_tree_join/2}, {reduce, fun ?MODULE:purge_tree_reduce/2} ]), - {ok, PurgeTree2} = couch_btree:add(PurgeTree, Infos), - {ok, PurgeTreeSt} = couch_btree:get_state(PurgeTree2), + {ok, PurgeTree2} = couch_btree:add(PurgeTree, Infos), + {ok, PurgeTreeSt} = couch_btree:get_state(PurgeTree2), - {ok, PurgeSeqTree} = couch_btree:open(nil, Fd, [ + {ok, PurgeSeqTree} = couch_btree:open(nil, Fd, [ {split, fun ?MODULE:purge_seq_tree_split/1}, {join, fun ?MODULE:purge_seq_tree_join/2}, {reduce, fun ?MODULE:purge_tree_reduce/2} ]), - {ok, PurgeSeqTree2} = couch_btree:add(PurgeSeqTree, Infos), - {ok, PurgeSeqTreeSt} = couch_btree:get_state(PurgeSeqTree2), + {ok, PurgeSeqTree2} = couch_btree:add(PurgeSeqTree, Infos), + {ok, PurgeSeqTreeSt} = couch_btree:get_state(PurgeSeqTree2), - couch_bt_engine_header:set(Header, [ - {purge_tree_state, PurgeTreeSt}, - {purge_seq_tree_state, PurgeSeqTreeSt} - ]) + couch_bt_engine_header:set(Header, [ + {purge_tree_state, PurgeTreeSt}, + {purge_seq_tree_state, PurgeSeqTreeSt} + ]) + end end. diff --git a/src/couch/test/couchdb_views_tests.erl b/src/couch/test/couchdb_views_tests.erl index dd176c0c9..1b1a8e56b 100644 --- a/src/couch/test/couchdb_views_tests.erl +++ b/src/couch/test/couchdb_views_tests.erl @@ -147,7 +147,7 @@ backup_restore_test_() -> }. -upgrade_test() -> +upgrade_test_() -> { "Upgrade tests", { |