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/05 21:38:19 UTC
[couchdb] 04/05: WIP: Fix check_db_instance
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
commit df423c12b1063860c46763546d224e4187b3c718
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Fri Jun 5 15:55:49 2020 -0500
WIP: Fix check_db_instance
---
src/fabric/src/fabric2_fdb.erl | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index c5d8bfc..b2f04e5 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -1883,20 +1883,20 @@ check_db_instance(undefined) ->
check_db_instance(#{} = Db) ->
require_transaction(Db),
- case check_metadata_version(Db) of
- {current, Db1} ->
- Db1;
- {stale, Db1} ->
- #{
- tx := Tx,
- uuid := UUID,
- db_prefix := DbPrefix
- } = Db1,
- UUIDKey = erlfdb_tuple:pack({?DB_CONFIG, <<"uuid">>}, DbPrefix),
- case erlfdb:wait(erlfdb:get(Tx, UUIDKey)) of
- UUID -> Db1;
- _ -> error(database_does_not_exist)
- end
+ try check_metadata_version(Db) of
+ ok ->
+ Db
+ catch throw:{?MODULE, reopen} ->
+ #{
+ tx := Tx,
+ uuid := UUID,
+ db_prefix := DbPrefix
+ } = Db,
+ UUIDKey = erlfdb_tuple:pack({?DB_CONFIG, <<"uuid">>}, DbPrefix),
+ case erlfdb:wait(erlfdb:get(Tx, UUIDKey)) of
+ UUID -> Db;
+ _ -> error(database_does_not_exist)
+ end
end.