This is an automated email from the ASF dual-hosted git repository. davisp pushed a commit to branch COUCHDB-3288-mixed-cluster-upgrade in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 59e1f8e7bf0200783af6300277490158c65d2f30 Author: Paul J. Davis <paul.joseph.da...@gmail.com> AuthorDate: Fri Feb 3 09:44:29 2017 -0600 Allow for mixed db record definitions This change is to account for differences in the #db record when a cluster is operating in a mixed version state (i.e., when running a rolling reboot to upgrade). There are only a few operations that are valid on #db records that are shared between nodes so rather than attempt to map the entire API between the old and new records we're limiting to just the required API calls. COUCHDB-3288 --- src/couch/src/couch_db.erl | 18 ++++++++++--- src/couch/src/couch_db_int.hrl | 57 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl index 26d18c8..5e720c2 100644 --- a/src/couch/src/couch_db.erl +++ b/src/couch/src/couch_db.erl @@ -219,7 +219,9 @@ is_system_db(#db{options = Options}) -> is_clustered(#db{main_pid = nil}) -> true; is_clustered(#db{}) -> - false. + false; +is_clustered(?NEW_PSE_DB = Db) -> + ?PSE_DB_MAIN_PID(Db) == undefined. ensure_full_commit(#db{main_pid=Pid, instance_start_time=StartTime}) -> ok = gen_server:call(Pid, full_commit, infinity), @@ -232,6 +234,8 @@ ensure_full_commit(Db, RequiredSeq) -> close(#db{fd_monitor=Ref}) -> erlang:demonitor(Ref, [flush]), + ok; +close(?NEW_PSE_DB) -> ok. is_idle(#db{compactor_pid=nil, waiting_delayed_commit=nil} = Db) -> @@ -414,7 +418,9 @@ get_update_seq(#db{update_seq=Seq})-> Seq. get_user_ctx(#db{user_ctx = UserCtx}) -> - UserCtx. + UserCtx; +get_user_ctx(?NEW_PSE_DB = Db) -> + ?PSE_DB_USER_CTX(Db). get_purge_seq(#db{}=Db) -> couch_db_header:purge_seq(Db#db.header). @@ -632,7 +638,9 @@ get_members(#db{security=SecProps}) -> couch_util:get_value(<<"readers">>, SecProps, {[]})). get_security(#db{security=SecProps}) -> - {SecProps}. + {SecProps}; +get_security(?NEW_PSE_DB = Db) -> + {?PSE_DB_SECURITY(Db)}. set_security(#db{main_pid=Pid}=Db, {NewSecProps}) when is_list(NewSecProps) -> check_is_admin(Db), @@ -681,7 +689,9 @@ set_revs_limit(_Db, _Limit) -> throw(invalid_revs_limit). name(#db{name=Name}) -> - Name. + Name; +name(?NEW_PSE_DB = Db) -> + ?PSE_DB_NAME(Db). compression(#db{compression=Compression}) -> Compression. diff --git a/src/couch/src/couch_db_int.hrl b/src/couch/src/couch_db_int.hrl index fc739b7..da1e45d 100644 --- a/src/couch/src/couch_db_int.hrl +++ b/src/couch/src/couch_db_int.hrl @@ -35,4 +35,59 @@ compression, before_doc_update = nil, % nil | fun(Doc, Db) -> NewDoc after_doc_read = nil % nil | fun(Doc, Db) -> NewDoc -}). \ No newline at end of file +}). + + +-record(new_pse_db, { + vsn, + name, + filepath, + + engine = {couch_bt_engine, undefined}, + + main_pid = nil, + compactor_pid = nil, + + committed_update_seq, + + instance_start_time, % number of microsecs since jan 1 1970 as a binary string + + user_ctx = #user_ctx{}, + security = [], + validate_doc_funs = undefined, + + before_doc_update = nil, % nil | fun(Doc, Db) -> NewDoc + after_doc_read = nil, % nil | fun(Doc, Db) -> NewDoc + + waiting_delayed_commit = nil, + + options = [], + compression +}). + + +-define(NEW_PSE_DB, { + db, + _, % Version + _, % Name + _, % FilePath + _, % Engine + _, % MainPid + _, % CompactorPid + _, % CommittedUpdateSeq + _, % InstanceStartTime + _, % UserCtx + _, % Security + _, % ValidateDocFuns + _, % BeforeDocUpdate + _, % AfterDocRead + _, % WaitingDelayedCommit + _, % Options + _ % Compression +}). + + +-define(PSE_DB_NAME(Db), element(3, Db)). +-define(PSE_DB_MAIN_PID(Db), element(6, Db)). +-define(PSE_DB_USER_CTX(Db), element(10, Db)). +-define(PSE_DB_SECURITY(Db), element(11, Db)). -- To stop receiving notification emails like this one, please contact "commits@couchdb.apache.org" <commits@couchdb.apache.org>.