summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2018-04-26 11:39:58 -0500
committerjiangph <jiangph@cn.ibm.com>2018-08-21 09:11:30 +0800
commitbb27d5ebb02a1034bf4e0b5c33c1ba3189d5f9b1 (patch)
tree55c28d99d00636efc92d076bebf3921b3e4b1679
parent151b9b05f42794062c021a40628e0ada168e5ccc (diff)
downloadcouchdb-bb27d5ebb02a1034bf4e0b5c33c1ba3189d5f9b1.tar.gz
Fix race on couch_db:reopen/1
This fixes a minor race by opening the database before closing it. This was never found to be an issue in production and was just caught while contemplating the PSE test suite.
-rw-r--r--src/couch/src/couch_db.erl7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index 65ca54a59..40c673a8b 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -161,8 +161,11 @@ reopen(#db{} = Db) ->
% We could have just swapped out the storage engine
% for this database during a compaction so we just
% reimplement this as a close/open pair now.
- close(Db),
- open(Db#db.name, [{user_ctx, Db#db.user_ctx} | Db#db.options]).
+ try
+ open(Db#db.name, [{user_ctx, Db#db.user_ctx} | Db#db.options])
+ after
+ close(Db)
+ end.
% You shouldn't call this. Its part of the ref counting between