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/03/26 19:01:12 UTC

[GitHub] [couchdb] davisp commented on a change in pull request #2666: soft-deletion for database

davisp commented on a change in pull request #2666: soft-deletion for database
URL: https://github.com/apache/couchdb/pull/2666#discussion_r398820068
 
 

 ##########
 File path: src/fabric/src/fabric2_fdb.erl
 ##########
 @@ -346,12 +350,68 @@ delete(#{} = Db) ->
     } = ensure_current(Db),
 
     DbKey = erlfdb_tuple:pack({?ALL_DBS, DbName}, LayerPrefix),
-    erlfdb:clear(Tx, DbKey),
-    erlfdb:clear_range_startswith(Tx, DbPrefix),
+    DoRecovery = fabric2_util:do_recovery(),
+    case DoRecovery of
+        true ->
+            Timestamp = list_to_binary(fabric2_util:iso8601_timestamp()),
+            DeletedDbKey = erlfdb_tuple:pack({?DELETED_DBS, DbName, Timestamp},
+                LayerPrefix),
+            erlfdb:set(Tx, DeletedDbKey, DbPrefix),
 
 Review comment:
   It just occurred to me, we need to read the `DeletedDbKey` and make sure that it comes back `not_found` or else we end up losing references to deleted databases if users create/delete databases too quickly.

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


With regards,
Apache Git Services