summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2020-06-25 11:30:04 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2020-06-25 11:31:26 -0500
commit9425a6408274edc1713b990729d4dea4daa4787d (patch)
treea2199652a55b6111fe446551bb16780ac5735c12
parent596715783514a9edaa1295757e23f03c6f87e38f (diff)
downloadcouchdb-prototype/fdb-layer-db-version-as-vstamps.tar.gz
The `\xFFmetadataVersion` key is also used to coordinate between layers which includes the DirectoryLayer. This means if that key changes we also have to re-check that our Directory entry still exists.
-rw-r--r--src/fabric/src/fabric2_fdb.erl19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index 926b28cc9..1d40f4f39 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -1305,6 +1305,7 @@ ensure_current(#{} = Db0, CheckDbVersion) ->
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
@@ -1321,7 +1322,7 @@ ensure_current(#{} = Db0, CheckDbVersion) ->
% This means we've only been asked to check that the
% MDVersion has changed when operating at the database
% level for creation and deletion operations.
- ok;
+ ok = check_layer_prefix(Db0);
{false, _} ->
% The MDVersion hasn't changed which means we can
% skip the db version check. However, we want to
@@ -1380,6 +1381,22 @@ check_metadata_version(#{} = Db) ->
end.
+check_layer_prefix(#{} = Db) ->
+ #{
+ tx := Tx,
+ layer_prefix := OldLayerPrefix
+ } = Db,
+
+ Root = erlfdb_directory:root(),
+ Dir = fabric2_server:fdb_directory(),
+ CouchDB = erlfdb_directory:create_or_open(Tx, Root, Dir),
+ CurrLayerPrefix = erlfdb_directory:get_name(CouchDB),
+
+ if OldLayerPrefix == CurrLayerPrefix -> ok; true ->
+ throw({?MODULE, reopen})
+ end.
+
+
bump_db_version(#{} = Db) ->
#{
tx := Tx,