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/10 07:32:49 UTC

[GitHub] [couchdb] ppggff commented on a change in pull request #2261: Take better advantage of metadata version key feature

ppggff commented on a change in pull request #2261:
URL: https://github.com/apache/couchdb/pull/2261#discussion_r452673111



##########
File path: src/fabric/src/fabric2_fdb.erl
##########
@@ -864,6 +868,31 @@ bump_metadata_version(Tx) ->
     erlfdb:set_versionstamped_value(Tx, ?METADATA_VERSION_KEY, <<0:112>>).
 
 
+check_metadata_version(#{} = Db) ->
+    #{
+        tx := Tx,
+        layer_prefix := LayerPrefix,
+        name := DbName,
+        md_version := Version
+    } = Db,
+
+    AlreadyChecked = get(?PDICT_CHECKED_MD_IS_CURRENT),
+    if AlreadyChecked == true -> {current, Db}; true ->
+        case erlfdb:wait(erlfdb:get_ss(Tx, ?METADATA_VERSION_KEY)) of
+            Version ->
+                put(?PDICT_CHECKED_MD_IS_CURRENT, true),
+                % We want to set a read conflict on the db version as we'd want
+                % to to conflict with any writes to this particular db
+                DbPrefix = erlfdb_tuple:pack({?DBS, DbName}, LayerPrefix),
+                DbVersionKey = erlfdb_tuple:pack({?DB_VERSION}, DbPrefix),
+                erlfdb:add_read_conflict_key(Tx, DbVersionKey),

Review comment:
       Why add DbVersionKey as read_conflict_key if METADATA_VERSION_KEY is not changed?
   If METADATA_VERSION_KEY hasn't changed, DbVersionKey certainly hasn't changed.
   




----------------------------------------------------------------
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