diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-03-27 09:32:13 -0500 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-03-27 09:32:13 -0500 |
commit | 4e16c9610b6bd1c2438e7e3a224985689b830ef5 (patch) | |
tree | 6ee21233d04b958804752f43392f82c7b3a15841 | |
parent | 971bb98989c7226bb96f38e13cb4a61acbbb12d2 (diff) | |
download | couchdb-4e16c9610b6bd1c2438e7e3a224985689b830ef5.tar.gz |
WIP: Bugs and tweaks
-rw-r--r-- | src/fabric/src/fabric2_db.erl | 5 | ||||
-rw-r--r-- | src/fabric/src/fabric2_fdb.erl | 18 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/fabric/src/fabric2_db.erl b/src/fabric/src/fabric2_db.erl index 88f6bd953..98327874c 100644 --- a/src/fabric/src/fabric2_db.erl +++ b/src/fabric/src/fabric2_db.erl @@ -439,7 +439,7 @@ update_docs(Db, Docs) -> update_docs(Db, Docs, Options) -> with_tx(Db, fun(TxDb) -> {Resps, Status} = lists:mapfoldl(fun(Doc, Acc) -> - case fabric2_doc:update(TxDb, Doc, Options) of + case update_doc_int(TxDb, Doc, Options) of {ok, _} = Resp -> {Resp, Acc}; {error, _} = Resp -> @@ -615,6 +615,7 @@ update_doc_int(#{} = Db, #doc{} = Doc0, Options) -> % Need to count design documents % Need to track db size changes + % Need to update VDUs on ddoc change #doc{ revs = {RevStart, [Rev | _]} @@ -624,6 +625,7 @@ update_doc_int(#{} = Db, #doc{} = Doc0, Options) -> Return end. + prep_and_validate(Db, not_found, Doc, UpdateType) -> case Doc#doc.revs of {0, []} -> @@ -889,4 +891,3 @@ with_tx(#{tx := undefined} = Db, Fun) -> with_tx(#{tx := {erlfdb_transaction, _}} = Db, Fun) -> Fun(Db). - diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl index 68d148ea0..fb9cf1f91 100644 --- a/src/fabric/src/fabric2_fdb.erl +++ b/src/fabric/src/fabric2_fdb.erl @@ -38,7 +38,7 @@ ]). --include("couch/include/couch_db.hrl"). +-include_lib("couch/include/couch_db.hrl"). -include("fabric2.hrl"). @@ -298,7 +298,8 @@ set_config(#{} = Db, ConfigKey, ConfigVal) -> } = Db, Key = erlfdb_tuple:pack({?DB_CONFIG, ConfigKey}, DbPrefix), - erlfdb:set(Tx, Key, ConfigVal). + erlfdb:set(Tx, Key, ConfigVal), + bump_metadata_version(Tx). get_stat(#{} = Db, StatKey) -> @@ -313,11 +314,10 @@ get_stat(#{} = Db, StatKey) -> % Might need to figure out some sort of type % system here. Uints are because stats are all % atomic op adds for the moment. - ?bin2uint(erlfdb:wait(erlfdb:get(Tx, Key))), - bump_metadata_version(Tx). + ?bin2uint(erlfdb:wait(erlfdb:get(Tx, Key))). -incr_stat(_Db, _Statey, 0) -> +incr_stat(_Db, _StatKey, 0) -> ok; incr_stat(#{} = Db, StatKey, Increment) when is_integer(Increment) -> @@ -343,14 +343,14 @@ get_full_doc_info(#{} = Db, DocId) -> fdb_to_fdi(Db, DocId, Val). -get_doc_body(#{} = Db, DocId, {Pos, [Rev | _]} = Path) -> +get_doc_body(#{} = Db, DocId, {Pos, [Rev | _] = Path}) -> ?REQUIRE_CURRENT(Db), #{ tx := Tx, db_prefix := DbPrefix } = Db, - Key = erlfdb_tupe:pack({?DB_REVS, DocId, Pos, Rev}, DbPrefix), + Key = erlfdb_tuple:pack({?DB_REVS, DocId, Pos, Rev}, DbPrefix), Val = erlfdb:wait(erlfdb:get(Tx, Key)), fdb_to_doc(Db, DocId, Pos, Path, Val). @@ -372,7 +372,7 @@ store_doc(#{} = Db, #full_doc_info{} = FDI, #doc{} = Doc) -> erlfdb:clear(Tx, OldSeqKey), % Add new entry to changes feed - NewSeqKey = erlfdb_tuple:pack({?DB_CHANGES, ?UNSET_VS}, DbPrefix), + NewSeqKey = erlfdb_tuple:pack_vs({?DB_CHANGES, ?UNSET_VS}, DbPrefix), erlfdb:set_versionstamped_key(Tx, NewSeqKey, DocId), % Write document data @@ -399,8 +399,6 @@ get_changes(#{} = Db, Options) -> end, erlfdb:wait(Future)). - - bump_metadata_version(Tx) -> % The 14 zero bytes is pulled from the PR for adding the % metadata version key. Not sure why 14 bytes when version |