You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/07/09 16:04:21 UTC

[GitHub] [couchdb] nickva commented on a change in pull request #2952: Prototype/fdb layer db version as vstamps

nickva commented on a change in pull request #2952:
URL: https://github.com/apache/couchdb/pull/2952#discussion_r452327330



##########
File path: src/fabric/src/fabric2_fdb.erl
##########
@@ -1255,6 +1299,63 @@ load_validate_doc_funs(#{} = Db) ->
     }.
 
 
+ensure_current(#{} = Db0, CheckDbVersion) ->
+    require_transaction(Db0),
+    MDVersionChanged = check_metadata_version(Db0),
+
+    Db2 = case {MDVersionChanged, CheckDbVersion} of
+        {true, true} ->
+            ok = check_layer_prefix(Db0),
+            ok = check_db_version(Db0),
+
+            % Don't update check_current_ts if it doesn't exist
+            case maps:is_key(check_current_ts, Db0) of
+                true ->
+                    Now = erlang:monotonic_time(millisecond),
+                    Db1 = Db0#{check_current_ts := Now},
+                    fabric2_server:maybe_update(Db1),

Review comment:
       One thing that we are missing is that before the Db handle passed to the `fabric2_server:maybe_update/1` contained the latest md version:
   
   https://github.com/apache/couchdb/blob/prototype/fdb-layer/src/fabric/src/fabric2_fdb.erl#L1870-L1878
   
   That was how we were caching the knowledge that we have checked this db handle as of that md version and found that it was current. After that any clients which got the handle from the cache (via open or refresh), compared the md version and if it matched, they wouldn't bother reading the db version key at all.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org