You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Benoit Chesneau <bc...@gmail.com> on 2011/10/05 07:10:34 UTC
Re: git commit: Open replicator database in child process
On Wed, Oct 5, 2011 at 2:12 AM, <fd...@apache.org> wrote:
> Updated Branches:
> refs/heads/master 3c24a94dd -> 0c7fbd3da
>
>
> Open replicator database in child process
>
> This is more correct and less confusing.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0c7fbd3d
> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0c7fbd3d
> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0c7fbd3d
>
> Branch: refs/heads/master
> Commit: 0c7fbd3dab5bf13215def4349dbba7f689a22ac6
> Parents: 3c24a94
> Author: Filipe David Manana <fd...@apache.org>
> Authored: Wed Oct 5 01:10:54 2011 +0100
> Committer: Filipe David Manana <fd...@apache.org>
> Committed: Wed Oct 5 01:12:45 2011 +0100
>
> ----------------------------------------------------------------------
> src/couchdb/couch_replication_manager.erl | 11 +++++++----
> 1 files changed, 7 insertions(+), 4 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/couchdb/blob/0c7fbd3d/src/couchdb/couch_replication_manager.erl
> ----------------------------------------------------------------------
> diff --git a/src/couchdb/couch_replication_manager.erl b/src/couchdb/couch_replication_manager.erl
> index 5885732..7d1860e 100644
> --- a/src/couchdb/couch_replication_manager.erl
> +++ b/src/couchdb/couch_replication_manager.erl
> @@ -223,9 +223,12 @@ code_change(_OldVsn, State, _Extra) ->
>
> changes_feed_loop() ->
> {ok, RepDb} = ensure_rep_db_exists(),
> + RepDbName = couch_db:name(RepDb),
> + couch_db:close(RepDb),
> Server = self(),
> Pid = spawn_link(
> fun() ->
> + {ok, Db} = couch_db:open_int(RepDbName, [sys_db]),
> ChangesFeedFun = couch_changes:handle_changes(
> #changes_args{
> include_docs = true,
> @@ -234,7 +237,7 @@ changes_feed_loop() ->
> db_open_options = [sys_db]
> },
> {json_req, null},
> - RepDb
> + Db
> ),
> ChangesFeedFun(
> fun({change, Change, _}, _) ->
> @@ -248,11 +251,11 @@ changes_feed_loop() ->
> (_, _) ->
> ok
> end
> - )
> + ),
> + couch_db:close(Db)
> end
> ),
> - couch_db:close(RepDb),
> - {Pid, couch_db:name(RepDb)}.
> + {Pid, RepDbName}.
>
>
> has_valid_rep_id({Change}) ->
>
>
Can't you ensure it in the process too ? What is the reason to have it
externally ?
- benoit
Re: git commit: Open replicator database in child process
Posted by Benoit Chesneau <bc...@gmail.com>.
On Wed, Oct 5, 2011 at 9:28 AM, Filipe David Manana <fd...@apache.org> wrote:
> On Wednesday, October 5, 2011, Benoit Chesneau <bc...@gmail.com> wrote:
>> On Wed, Oct 5, 2011 at 2:12 AM, <fd...@apache.org> wrote:
>>> Updated Branches:
>>> refs/heads/master 3c24a94dd -> 0c7fbd3da
>>>
>>>
>>> Open replicator database in child process
>>>
>>> This is more correct and less confusing.
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0c7fbd3d
>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0c7fbd3d
>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0c7fbd3d
>>>
>>> Branch: refs/heads/master
>>> Commit: 0c7fbd3dab5bf13215def4349dbba7f689a22ac6
>>> Parents: 3c24a94
>>> Author: Filipe David Manana <fd...@apache.org>
>>> Authored: Wed Oct 5 01:10:54 2011 +0100
>>> Committer: Filipe David Manana <fd...@apache.org>
>>> Committed: Wed Oct 5 01:12:45 2011 +0100
>>>
>>> ----------------------------------------------------------------------
>>> src/couchdb/couch_replication_manager.erl | 11 +++++++----
>>> 1 files changed, 7 insertions(+), 4 deletions(-)
>>> ----------------------------------------------------------------------
>>>
>>>
>>>
> http://git-wip-us.apache.org/repos/asf/couchdb/blob/0c7fbd3d/src/couchdb/couch_replication_manager.erl
>>> ----------------------------------------------------------------------
>>> diff --git a/src/couchdb/couch_replication_manager.erl
> b/src/couchdb/couch_replication_manager.erl
>>> index 5885732..7d1860e 100644
>>> --- a/src/couchdb/couch_replication_manager.erl
>>> +++ b/src/couchdb/couch_replication_manager.erl
>>> @@ -223,9 +223,12 @@ code_change(_OldVsn, State, _Extra) ->
>>>
>>> changes_feed_loop() ->
>>> {ok, RepDb} = ensure_rep_db_exists(),
>>> + RepDbName = couch_db:name(RepDb),
>>> + couch_db:close(RepDb),
>>> Server = self(),
>>> Pid = spawn_link(
>>> fun() ->
>>> + {ok, Db} = couch_db:open_int(RepDbName, [sys_db]),
>>> ChangesFeedFun = couch_changes:handle_changes(
>>> #changes_args{
>>> include_docs = true,
>>> @@ -234,7 +237,7 @@ changes_feed_loop() ->
>>> db_open_options = [sys_db]
>>> },
>>> {json_req, null},
>>> - RepDb
>>> + Db
>>> ),
>>> ChangesFeedFun(
>>> fun({change, Change, _}, _) ->
>>> @@ -248,11 +251,11 @@ changes_feed_loop() ->
>>> (_, _) ->
>>> ok
>>> end
>>> - )
>>> + ),
>>> + couch_db:close(Db)
>>> end
>>> ),
>>> - couch_db:close(RepDb),
>>> - {Pid, couch_db:name(RepDb)}.
>>> + {Pid, RepDbName}.
>>>
>>>
>>> has_valid_rep_id({Change}) ->
>>>
>>>
>>
>> Can't you ensure it in the process too ? What is the reason to have it
>> externally ?
>
> To return the name to the parent.
>
>>
>> - benoit
>>
>
> --
> Filipe David Manana,
>
> "Reasonable men adapt themselves to the world.
> Unreasonable men adapt the world to themselves.
> That's why all progress depends on unreasonable men."
>
ok.... So you could just retutn ?l2b(couch_config:get("replicator",
"db", "_replicator")).
Though it's probably safer ensure it first and it's probably the real
reason. I think a better change would be ensuring and opening it in
init, and close it in terminate. So we could eventually manage it on
code change.
- benoit
Re: git commit: Open replicator database in child process
Posted by Filipe David Manana <fd...@apache.org>.
On Wednesday, October 5, 2011, Benoit Chesneau <bc...@gmail.com> wrote:
> On Wed, Oct 5, 2011 at 2:12 AM, <fd...@apache.org> wrote:
>> Updated Branches:
>> refs/heads/master 3c24a94dd -> 0c7fbd3da
>>
>>
>> Open replicator database in child process
>>
>> This is more correct and less confusing.
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0c7fbd3d
>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0c7fbd3d
>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0c7fbd3d
>>
>> Branch: refs/heads/master
>> Commit: 0c7fbd3dab5bf13215def4349dbba7f689a22ac6
>> Parents: 3c24a94
>> Author: Filipe David Manana <fd...@apache.org>
>> Authored: Wed Oct 5 01:10:54 2011 +0100
>> Committer: Filipe David Manana <fd...@apache.org>
>> Committed: Wed Oct 5 01:12:45 2011 +0100
>>
>> ----------------------------------------------------------------------
>> src/couchdb/couch_replication_manager.erl | 11 +++++++----
>> 1 files changed, 7 insertions(+), 4 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0c7fbd3d/src/couchdb/couch_replication_manager.erl
>> ----------------------------------------------------------------------
>> diff --git a/src/couchdb/couch_replication_manager.erl
b/src/couchdb/couch_replication_manager.erl
>> index 5885732..7d1860e 100644
>> --- a/src/couchdb/couch_replication_manager.erl
>> +++ b/src/couchdb/couch_replication_manager.erl
>> @@ -223,9 +223,12 @@ code_change(_OldVsn, State, _Extra) ->
>>
>> changes_feed_loop() ->
>> {ok, RepDb} = ensure_rep_db_exists(),
>> + RepDbName = couch_db:name(RepDb),
>> + couch_db:close(RepDb),
>> Server = self(),
>> Pid = spawn_link(
>> fun() ->
>> + {ok, Db} = couch_db:open_int(RepDbName, [sys_db]),
>> ChangesFeedFun = couch_changes:handle_changes(
>> #changes_args{
>> include_docs = true,
>> @@ -234,7 +237,7 @@ changes_feed_loop() ->
>> db_open_options = [sys_db]
>> },
>> {json_req, null},
>> - RepDb
>> + Db
>> ),
>> ChangesFeedFun(
>> fun({change, Change, _}, _) ->
>> @@ -248,11 +251,11 @@ changes_feed_loop() ->
>> (_, _) ->
>> ok
>> end
>> - )
>> + ),
>> + couch_db:close(Db)
>> end
>> ),
>> - couch_db:close(RepDb),
>> - {Pid, couch_db:name(RepDb)}.
>> + {Pid, RepDbName}.
>>
>>
>> has_valid_rep_id({Change}) ->
>>
>>
>
> Can't you ensure it in the process too ? What is the reason to have it
> externally ?
To return the name to the parent.
>
> - benoit
>
--
Filipe David Manana,
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."