couchbaselabs / cbforest

C++ wrapper library around ForestDB, for use in Couchbase Lite.
17 stars 12 forks source link

Fixed migration error from v1.2.x to v1.3.x #109

Closed hideki closed 8 years ago

hideki commented 8 years ago

Original Issue: https://github.com/couchbase/couchbase-lite-android/issues/974

CBL v1.2.x opens forestdb with FDB_COMPACTION_MANUAL. CBL 1.3.x fails to create c4View instance because v1.3.x use FDB_COMPACTION_AUTO option. So need to retry to open index with FDB_COMPACTION_MANUAL option, and update compaction mode to FDB_COMPACTION_AUTO.

ABOUT WORKAROUND: c4View's MapReduceIndex _index variable calls Database::getKeyStore(...) in constructor, and it calls fdb_kvs_open(...) with _viewDB. It increments reference count of _viewDB._fileHandle. So calling fdb_switch_compaction_mode(...) after c4View instance is created fails. Switching compaction mode before creating c4View instance is workaround.