diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2017-02-03 09:44:29 -0600 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2017-09-27 15:35:59 -0500 |
commit | d5a261b92000eb2a24a8d0b84f34eea597e1aa87 (patch) | |
tree | db38b1f9cc1362556ac44e1a50452686e0df3940 | |
parent | cb610bf2fa96ab2d908769b0d0f844a2ad3096bf (diff) | |
download | couchdb-d5a261b92000eb2a24a8d0b84f34eea597e1aa87.tar.gz |
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
-rw-r--r-- | src/couch/src/couch_db.erl | 18 | ||||
-rw-r--r-- | 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 26d18c8e7..5e720c284 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 fc739b781..da1e45d75 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)). |