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/14 09:22:45 UTC
[couchdb] branch COUCHDB-3326-clustered-purge-pr4-on-compact-plugin
updated (5a58bef -> f698ffa)
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 5a58bef Create new on_compact trigger
omit 6a370e6 Resolve merge conflict
omit 163b02e Enhance PSE tests with setup/teardown functions
omit 5f4f413 Update to use new couch_pse_tests app
omit 811dca9 Update PSE test definitions for new util module
omit 622bfdc Rename PSE test modules
omit 56fbe19 Move PSE tests to their own app
omit fa45f9a Rewrite the PSE test suite to use couch_server
omit 966497c Simplify logic in mem3_rep
omit 55ff797 Update fabric_doc_open eunit tests
omit 82dabd7 Fix race on couch_db:reopen/1
omit c96df45 Fix default security object handling
omit 00d8379 Fix bug during purge
omit 1e2e8af Fix typos in couch_db_engine.erl
add 1e4f32f Ensure we only receive the correct DOWN message
add 2a3b4e7 Merge pull request #1553 from apache/ref-match-1544
add ed1db09 Fix session based replicator auth when endpoints have require_valid_user set
add 45f9c55 Fix typos in couch_db_engine.erl
add e994fc7 Fix bug during purge
add b899b50 Fix default security object handling
add 2949d2a Fix race on couch_db:reopen/1
add 207b3b0 Update fabric_doc_open eunit tests
add b663478 Simplify logic in mem3_rep
add e66ae51 Rewrite the PSE test suite to use couch_server
add 52f9509 Move PSE tests to their own app
add 95ac3a4 Rename PSE test modules
add edc767d Update PSE test definitions for new util module
add ee01e0c Update to use new couch_pse_tests app
add 91f6069 Enhance PSE tests with setup/teardown functions
add bff390d Resolve merge conflict
new f698ffa 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 (5a58bef)
\
N -- N -- N refs/heads/COUCHDB-3326-clustered-purge-pr4-on-compact-plugin (f698ffa)
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:
src/couch_mrview/src/couch_mrview_show.erl | 4 +-
.../src/couch_replicator_auth_session.erl | 90 +++++++++++++++++++---
2 files changed, 80 insertions(+), 14 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 f698ffaccc637fd505d7fa39de19a37c53363329
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], []).