You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ji...@apache.org on 2018/08/21 01:34:37 UTC
[couchdb] branch COUCHDB-3326-clustered-purge-pr4-on-compact-plugin
updated (f698ffa -> 830240b)
This is an automated email from the ASF dual-hosted git repository.
jiangphcn pushed a change to branch COUCHDB-3326-clustered-purge-pr4-on-compact-plugin
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
omit f698ffa Create new on_compact trigger
omit bff390d Resolve merge conflict
omit 91f6069 Enhance PSE tests with setup/teardown functions
omit ee01e0c Update to use new couch_pse_tests app
omit edc767d Update PSE test definitions for new util module
omit 95ac3a4 Rename PSE test modules
omit 52f9509 Move PSE tests to their own app
omit e66ae51 Rewrite the PSE test suite to use couch_server
omit b663478 Simplify logic in mem3_rep
omit 207b3b0 Update fabric_doc_open eunit tests
omit 2949d2a Fix race on couch_db:reopen/1
omit b899b50 Fix default security object handling
omit e994fc7 Fix bug during purge
omit 45f9c55 Fix typos in couch_db_engine.erl
add 39dede7 Expose document update errors to client
add d3453d2 Merge pull request #1486 from cloudant/fix-doc-update-case-clause
add 28ba48d Reduce size of #leaf.atts keys
add 0cb1110 Add `POST /_node/$node/_restart` endpoint
add d14869e Calculate uptime since application start instead of a beam start
add fbe98b6 Use "/_node/<node>/_restart" from JavaScript tests
add 7217481 Remove special handling of 'restart' from 'test/javascript/run'
add 91ff3f6 Remove _restart endpoint from non-clustered interface
add 9be1213 Remove no longer needed handle_restart_req handler
add b847adb Merge pull request #1543 from cloudant/implement-node-restart
add 3852a00 Fix typos in couch_db_engine.erl
add da2e22a Fix bug during purge
add 151b9b0 Fix default security object handling
add bb27d5e Fix race on couch_db:reopen/1
add aea2833 Update fabric_doc_open eunit tests
add da43788 Simplify logic in mem3_rep
add f45c036 Rewrite the PSE test suite to use couch_server
add db28f4c Move PSE tests to their own app
add 3c94bc4 Rename PSE test modules
add 0d85abe Update PSE test definitions for new util module
add c998aa4 Update to use new couch_pse_tests app
add 4c87d78 Enhance PSE tests with setup/teardown functions
new 830240b Create new on_compact trigger
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (f698ffa)
\
N -- N -- N refs/heads/COUCHDB-3326-clustered-purge-pr4-on-compact-plugin (830240b)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
rel/overlay/etc/default.ini | 1 -
src/chttpd/src/chttpd_misc.erl | 8 +++-
src/couch/src/couch_app.erl | 11 +++++-
src/couch/src/couch_att.erl | 10 ++++-
src/couch/src/couch_httpd_misc_handlers.erl | 23 +-----------
src/fabric/src/fabric.erl | 58 ++++++++++++++++++++++++++++-
src/fabric/src/fabric_doc_update.erl | 3 +-
test/javascript/run | 6 +--
test/javascript/test_setup.js | 11 +++++-
9 files changed, 96 insertions(+), 35 deletions(-)
[couchdb] 01/01: Create new on_compact trigger
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiangphcn pushed a commit to branch COUCHDB-3326-clustered-purge-pr4-on-compact-plugin
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 830240b6efd5808cdb964fdb05e584758fcc9f2f
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed May 30 14:34:44 2018 -0500
Create new on_compact trigger
This trigger allows any storage engine that makes use of compaction to
notify that compaction is starting. This is preparatory work for
clustered indexes so that existing indexes are allowed to ensure they
have a clustered purge local doc before compaction runs.
COUCHDB-3326
Co-Authored-By: jiangphcn <ji...@cn.ibm.com>
---
src/couch/src/couch_bt_engine_compactor.erl | 2 ++
src/couch/src/couch_db_engine.erl | 31 ++++++++++++++++++++++++++++-
src/couch/src/couch_db_plugin.erl | 5 +++++
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/src/couch/src/couch_bt_engine_compactor.erl b/src/couch/src/couch_bt_engine_compactor.erl
index 4e52064..2c5b78e 100644
--- a/src/couch/src/couch_bt_engine_compactor.erl
+++ b/src/couch/src/couch_bt_engine_compactor.erl
@@ -44,6 +44,8 @@ start(#st{} = St, DbName, Options, Parent) ->
} = St,
couch_log:debug("Compaction process spawned for db \"~s\"", [DbName]),
+ couch_db_engine:trigger_on_compact(DbName),
+
{ok, NewSt, DName, DFd, MFd, Retry} =
open_compaction_files(Header, FilePath, Options),
erlang:monitor(process, MFd),
diff --git a/src/couch/src/couch_db_engine.erl b/src/couch/src/couch_db_engine.erl
index 4974201..2fe0b0d 100644
--- a/src/couch/src/couch_db_engine.erl
+++ b/src/couch/src/couch_db_engine.erl
@@ -627,7 +627,8 @@
count_changes_since/2,
start_compaction/1,
- finish_compaction/2
+ finish_compaction/2,
+ trigger_on_compact/1
]).
@@ -891,3 +892,31 @@ finish_compaction(Db, CompactInfo) ->
end,
ok = gen_server:call(couch_server, {db_updated, NewDb}, infinity),
{ok, NewDb}.
+
+
+trigger_on_compact(DbName) ->
+ {ok, DDocs} = get_ddocs(DbName),
+ couch_db_plugin:on_compact(DbName, DDocs).
+
+
+get_ddocs(<<"shards/", _/binary>> = DbName) ->
+ {_, Ref} = spawn_monitor(fun() ->
+ exit(fabric:design_docs(mem3:dbname(DbName)))
+ end),
+ receive
+ {'DOWN', Ref, _, _, {ok, JsonDDocs}} ->
+ {ok, lists:map(fun(JsonDDoc) ->
+ couch_doc:from_json_obj(JsonDDoc)
+ end, JsonDDocs)};
+ {'DOWN', Ref, _, _, Else} ->
+ Else
+ end;
+get_ddocs(DbName) ->
+ couch_util:with_db(DbName, fun(Db) ->
+ FoldFun = fun(FDI, Acc) ->
+ Doc = couch_db:open_doc_int(Db, FDI, []),
+ {ok, [Doc | Acc]}
+ end,
+ {ok, Docs} = couch_db:fold_design_docs(Db, FoldFun, [], []),
+ {ok, lists:reverse(Docs)}
+ end).
diff --git a/src/couch/src/couch_db_plugin.erl b/src/couch/src/couch_db_plugin.erl
index 740b812..8163256 100644
--- a/src/couch/src/couch_db_plugin.erl
+++ b/src/couch/src/couch_db_plugin.erl
@@ -18,6 +18,7 @@
after_doc_read/2,
validate_docid/1,
check_is_admin/1,
+ on_compact/2,
on_delete/2
]).
@@ -56,6 +57,10 @@ check_is_admin(Db) ->
%% callbacks return true only if it specifically allow the given Id
couch_epi:any(Handle, ?SERVICE_ID, check_is_admin, [Db], []).
+on_compact(DbName, DDocs) ->
+ Handle = couch_epi:get_handle(?SERVICE_ID),
+ couch_epi:apply(Handle, ?SERVICE_ID, on_compact, [DbName, DDocs], []).
+
on_delete(DbName, Options) ->
Handle = couch_epi:get_handle(?SERVICE_ID),
couch_epi:apply(Handle, ?SERVICE_ID, on_delete, [DbName, Options], []).