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 2020/06/08 17:35:15 UTC

[couchdb] branch prototype/fdb-layer-db-version-as-vstamps updated: WIP: Set versionstamp db_veresion on creation

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch prototype/fdb-layer-db-version-as-vstamps
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/prototype/fdb-layer-db-version-as-vstamps by this push:
     new f424cd1  WIP: Set versionstamp db_veresion on creation
f424cd1 is described below

commit f424cd1fa022463e9930d53c685483386506f38b
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Jun 8 12:34:52 2020 -0500

    WIP: Set versionstamp db_veresion on creation
---
 src/fabric/src/fabric2_fdb.erl | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index b2f04e5..fc777b0 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -184,7 +184,8 @@ create(#{} = Db0, Options) ->
     #{
         name := DbName,
         tx := Tx,
-        layer_prefix := LayerPrefix
+        layer_prefix := LayerPrefix,
+        md_version := MDVersion
     } = Db1 = ensure_current(Db0, false),
 
     DbKey = erlfdb_tuple:pack({?ALL_DBS, DbName}, LayerPrefix),
@@ -193,13 +194,17 @@ create(#{} = Db0, Options) ->
     DbPrefix = erlfdb_tuple:pack({?DBS, AllocPrefix}, LayerPrefix),
     erlfdb:set(Tx, DbKey, DbPrefix),
 
-    % This key is responsible for telling us when something in
-    % the database cache (i.e., fabric2_server's ets table) has
-    % changed and requires re-loading. This currently includes
-    % revs_limit and validate_doc_update functions.
+    % This is the key used by fabric2_server to determine when
+    % we need to reopen a database. Currently setting db config
+    % values or updating design documents triggers a change
+    % to this value.
+    %
+    % On creation we're setting this to the current MDVersion
+    % because it is a valid versionstamp on the current cluster
+    % and also so that we don't have to use two transactions
+    % when creating a database.
     DbVersionKey = erlfdb_tuple:pack({?DB_VERSION}, DbPrefix),
-    DbVersion = fabric2_util:uuid(),
-    erlfdb:set(Tx, DbVersionKey, DbVersion),
+    erlfdb:set(Tx, DbVersionKey, MDVersion),
 
     UUID = fabric2_util:uuid(),