You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/03/27 14:33:00 UTC
[couchdb] branch prototype/fdb-layer updated: WIP: Bugs and tweaks
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/prototype/fdb-layer by this push:
new 4e16c96 WIP: Bugs and tweaks
4e16c96 is described below
commit 4e16c9610b6bd1c2438e7e3a224985689b830ef5
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Mar 27 09:32:13 2019 -0500
WIP: Bugs and tweaks
---
src/fabric/src/fabric2_db.erl | 5 +++--
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 88f6bd9..9832787 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 68d148e..fb9cf1f 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