diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2018-04-26 11:39:58 -0500 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2018-04-26 13:07:28 -0500 |
commit | 9b1c4930102d35ff727351f377ca7a915e1810d6 (patch) | |
tree | 9028c7c87f8bab2c290c8ab0b78137d0622f63a6 | |
parent | 64b6ea9781633cdff800aec41bfd9132d8832fce (diff) | |
download | couchdb-9b1c4930102d35ff727351f377ca7a915e1810d6.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.erl | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl index 93ea07e65..3449274f6 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 |