You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by eiri <gi...@git.apache.org> on 2016/01/08 20:40:03 UTC

[GitHub] couchdb-couch-mrview pull request: Remove duplicated monitor set o...

GitHub user eiri opened a pull request:

    https://github.com/apache/couchdb-couch-mrview/pull/37

    Remove duplicated monitor set on index opening

    When mrview index is opening it adds monitor on couch_file server
    of the index file. This is not necessary because couch_mrview_util's
    init_state called before already does that, so we are ending up
    with duplicated monitor reference.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cloudant/couchdb-couch-mrview fix-leaking-monitor

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-couch-mrview/pull/37.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #37
    
----
commit 2341c38c66c471d01b50972fb2e5b02c091b8bec
Author: Eric Avdey <ei...@eiri.ca>
Date:   2016-01-08T19:24:57Z

    Remove duplicated monitor set on index opening
    
    When mrview index is opening it adds monitor on couch_file server
    of the index file. This is not necessary because couch_mrview_util's
    init_state called before already does that, so we are ending up
    with duplicated monitor reference.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-mrview pull request: Remove duplicated monitor set o...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/couchdb-couch-mrview/pull/37


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-mrview pull request: Remove duplicated monitor set o...

Posted by tonysun83 <gi...@git.apache.org>.
Github user tonysun83 commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch-mrview/pull/37#discussion_r49237851
  
    --- Diff: src/couch_mrview_index.erl ---
    @@ -134,15 +134,15 @@ open(Db, State) ->
                     {ok, {OldSig, Header}} ->
                         % Matching view signatures.
                         NewSt = couch_mrview_util:init_state(Db, Fd, State, Header),
    -                    {ok, NewSt#mrst{fd_monitor=erlang:monitor(process, Fd)}};
    +                    {ok, NewSt};
                     % end of upgrade code for <= 1.2.x
                     {ok, {Sig, Header}} ->
                         % Matching view signatures.
                         NewSt = couch_mrview_util:init_state(Db, Fd, State, Header),
    -                    {ok, NewSt#mrst{fd_monitor=erlang:monitor(process, Fd)}};
    +                    {ok, NewSt};
                     _ ->
                         NewSt = couch_mrview_util:reset_index(Db, Fd, State),
    -                    {ok, NewSt#mrst{fd_monitor=erlang:monitor(process, Fd)}}
    +                    {ok, NewSt}
    --- End diff --
    
    could we do something like
    ```erlang
     NewSt = case (catch couch_file:read_header(Fd)) of
         % upgrade code for <= 1.2.x
         {ok, {OldSig, Header}} ->
             % Matching view signatures.
              couch_mrview_util:init_state(Db, Fd, State, Header),
         % end of upgrade code for <= 1.2.x
         {ok, {Sig, Header}} ->
             % Matching view signatures.
             couch_mrview_util:init_state(Db, Fd, State, Header),
        {ok, NewSt};
        _ ->
           couch_mrview_util:reset_index(Db, Fd, State),
        end,
    {ok, NewSt}
    ```



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-mrview pull request: Remove duplicated monitor set o...

Posted by tonysun83 <gi...@git.apache.org>.
Github user tonysun83 commented on the pull request:

    https://github.com/apache/couchdb-couch-mrview/pull/37#issuecomment-170136997
  
    +0.5


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-mrview pull request: Remove duplicated monitor set o...

Posted by eiri <gi...@git.apache.org>.
Github user eiri commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch-mrview/pull/37#discussion_r49238755
  
    --- Diff: src/couch_mrview_index.erl ---
    @@ -134,15 +134,15 @@ open(Db, State) ->
                     {ok, {OldSig, Header}} ->
                         % Matching view signatures.
                         NewSt = couch_mrview_util:init_state(Db, Fd, State, Header),
    -                    {ok, NewSt#mrst{fd_monitor=erlang:monitor(process, Fd)}};
    +                    {ok, NewSt};
                     % end of upgrade code for <= 1.2.x
                     {ok, {Sig, Header}} ->
                         % Matching view signatures.
                         NewSt = couch_mrview_util:init_state(Db, Fd, State, Header),
    -                    {ok, NewSt#mrst{fd_monitor=erlang:monitor(process, Fd)}};
    +                    {ok, NewSt};
                     _ ->
                         NewSt = couch_mrview_util:reset_index(Db, Fd, State),
    -                    {ok, NewSt#mrst{fd_monitor=erlang:monitor(process, Fd)}}
    +                    {ok, NewSt}
    --- End diff --
    
    @tonysun83 We rather rarely catch from `case` (probably because it look ugly, me been opinionated and all that). Theoretically I can do something like `{ok, couch_mrview_util:init_state(Db, Fd, State, Header)}` in clauses, but honestly I was trying to avoid mixing refactoring with such a small change.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-mrview pull request: Remove duplicated monitor set o...

Posted by davisp <gi...@git.apache.org>.
Github user davisp commented on the pull request:

    https://github.com/apache/couchdb-couch-mrview/pull/37#issuecomment-170142208
  
    +1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-mrview pull request: Remove duplicated monitor set o...

Posted by eiri <gi...@git.apache.org>.
Github user eiri commented on the pull request:

    https://github.com/apache/couchdb-couch-mrview/pull/37#issuecomment-170104698
  
    @davisp: Can you take a look, please, if I'm missing something subtle here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---