Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-3149

Exception written to the log if db deleted while there is a change feed running

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      
      [info] 2016-09-14T20:08:23.217251Z node1@127.0.0.1 <0.23485.0> ea02496172 ea02496172 127.0.0.1  localhost:15984 DELETE /d1 200 ok 46
      
      [error] 2016-09-14T20:08:23.221676Z node1@127.0.0.1 <0.22945.0> -------- rexi_server error:{'EXIT',{{stop,{cb_state,<0.22937.0>,#Ref<0.0.1.15627>,true}},[{couch_event_listener_mfa,handle_event,3,[{file,"src/couch_event_listener_mfa.erl"},{line,91}]},{couch_event_listener,do_event,3,[{file,"src/couch_event_listener.erl"},{line,142}]},{rexi_server,init_p,3,[{file,"src/rexi_server.erl"
      },{line,139}]}]}} [{couch_event_listener,do_event,3,[{file,"src/couch_event_listener.erl"},{line,150}]},{rexi_server,init_p,3,[{file,"src/rexi_server.erl"},{line,139}]}]
      
      [info] 2016-09-14T20:08:23.222174Z node1@127.0.0.1 <0.22898.0> 549ae68ef1 549ae68ef1 127.0.0.1  localhost:15984 GET /d1/_changes?feed=longpoll 200 ok 32901
      

      Appears in the log if a database gets deleted while there is a change feed running. Both longpoll or continuous seem to trigger the behavior.

      Exception above in couch_event_listener_mfa:handle_event comes from

      https://github.com/apache/couchdb-couch-event/blob/master/src/couch_event_listener_mfa.erl#L91

      which, in turn comes from fabric_db_update_listener handle_db_event returning {stop, St} in:

      https://github.com/apache/couchdb-fabric/blob/master/src/fabric_db_update_listener.erl#L87

      It seems couch_event_listerner_mfa:handle_event doesn’t handle {stop, St} only, {ok, NewState} or just stop or it raises an exception.

      I tried to replace {stop, St} with {ok, St} and then with stop. But in both cases change feeds never stopped.

        Issue Links

          Activity

          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit b5340347294ac8047619df23b1586774d22e5b71 in couchdb-fabric's branch refs/heads/3149-delete-db-with-change-feed from Nick Vatamaniuc
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb-fabric.git;h=b534034 ]

          Avoid throwing exception when deleting db in db updater listener

          Handle db deletion explicitly. Previously handle_db_event callback returned
          `

          {stop, St}

          `. That return value was not handled by the caller, instead it
          resulted in it being used as reason in an erlang:error, which then ended up in
          the log.

          Jira: COUCHDB-3149

          Show
          jira-bot ASF subversion and git services added a comment - Commit b5340347294ac8047619df23b1586774d22e5b71 in couchdb-fabric's branch refs/heads/3149-delete-db-with-change-feed from Nick Vatamaniuc [ https://git-wip-us.apache.org/repos/asf?p=couchdb-fabric.git;h=b534034 ] Avoid throwing exception when deleting db in db updater listener Handle db deletion explicitly. Previously handle_db_event callback returned ` {stop, St} `. That return value was not handled by the caller, instead it resulted in it being used as reason in an erlang:error, which then ended up in the log. Jira: COUCHDB-3149
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user nickva opened a pull request:

          https://github.com/apache/couchdb-fabric/pull/69

          Avoid throwing exception when deleting db in db updater listener

          Handle db deletion explicitly. Previously handle_db_event callback returned
          `

          {stop, St}`. That return value was not handled by the caller, instead it
          resulted in it being used as reason in an erlang:error, which then ended up in
          the log.

          Jira: COUCHDB-3149

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

          $ git pull https://github.com/apache/couchdb-fabric 3149-delete-db-with-change-feed

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

          https://github.com/apache/couchdb-fabric/pull/69.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 #69

          ----
          commit b5340347294ac8047619df23b1586774d22e5b71
          Author: Nick Vatamaniuc <vatamane@apache.org>
          Date: 2016-09-15T15:16:19Z

          Avoid throwing exception when deleting db in db updater listener

          Handle db deletion explicitly. Previously handle_db_event callback returned
          `{stop, St}

          `. That return value was not handled by the caller, instead it
          resulted in it being used as reason in an erlang:error, which then ended up in
          the log.

          Jira: COUCHDB-3149


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user nickva opened a pull request: https://github.com/apache/couchdb-fabric/pull/69 Avoid throwing exception when deleting db in db updater listener Handle db deletion explicitly. Previously handle_db_event callback returned ` {stop, St}`. That return value was not handled by the caller, instead it resulted in it being used as reason in an erlang:error, which then ended up in the log. Jira: COUCHDB-3149 You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/couchdb-fabric 3149-delete-db-with-change-feed Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-fabric/pull/69.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 #69 ---- commit b5340347294ac8047619df23b1586774d22e5b71 Author: Nick Vatamaniuc <vatamane@apache.org> Date: 2016-09-15T15:16:19Z Avoid throwing exception when deleting db in db updater listener Handle db deletion explicitly. Previously handle_db_event callback returned `{stop, St} `. That return value was not handled by the caller, instead it resulted in it being used as reason in an erlang:error, which then ended up in the log. Jira: COUCHDB-3149
          Hide
          vatamane Nick Vatamaniuc added a comment -

          Here is an attempt at fixing it:

          https://github.com/apache/couchdb-fabric/pull/69

          But not familiar with that code, so probably took the wrong approach.

          Show
          vatamane Nick Vatamaniuc added a comment - Here is an attempt at fixing it: https://github.com/apache/couchdb-fabric/pull/69 But not familiar with that code, so probably took the wrong approach.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit b5340347294ac8047619df23b1586774d22e5b71 in couchdb-fabric's branch refs/heads/master from Nick Vatamaniuc
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb-fabric.git;h=b534034 ]

          Avoid throwing exception when deleting db in db updater listener

          Handle db deletion explicitly. Previously handle_db_event callback returned
          `

          {stop, St}

          `. That return value was not handled by the caller, instead it
          resulted in it being used as reason in an erlang:error, which then ended up in
          the log.

          Jira: COUCHDB-3149

          Show
          jira-bot ASF subversion and git services added a comment - Commit b5340347294ac8047619df23b1586774d22e5b71 in couchdb-fabric's branch refs/heads/master from Nick Vatamaniuc [ https://git-wip-us.apache.org/repos/asf?p=couchdb-fabric.git;h=b534034 ] Avoid throwing exception when deleting db in db updater listener Handle db deletion explicitly. Previously handle_db_event callback returned ` {stop, St} `. That return value was not handled by the caller, instead it resulted in it being used as reason in an erlang:error, which then ended up in the log. Jira: COUCHDB-3149
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/couchdb-fabric/pull/69

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/couchdb-fabric/pull/69
          Hide
          rnewson Robert Newson added a comment -

          I can also get still get this sometimes, with my previous patch applied;

          HTTP/1.1 404 Object Not Found
          Cache-Control: must-revalidate
          Content-Length: 58
          Content-Type: application/json
          Date: Fri, 16 Sep 2016 10:05:48 GMT
          Server: CouchDB/2.0.0-9add02f (Erlang OTP/18)
          X-Couch-Request-ID: 08ff181b7a
          X-CouchDB-Body-Time: 0

          {"error":"not_found","reason":"Database does not exist."}
          Show
          rnewson Robert Newson added a comment - I can also get still get this sometimes, with my previous patch applied; HTTP/1.1 404 Object Not Found Cache-Control: must-revalidate Content-Length: 58 Content-Type: application/json Date: Fri, 16 Sep 2016 10:05:48 GMT Server: CouchDB/2.0.0-9add02f (Erlang OTP/18) X-Couch-Request-ID: 08ff181b7a X-CouchDB-Body-Time: 0 {"error":"not_found","reason":"Database does not exist."}
          Hide
          rnewson Robert Newson added a comment -

          ignore that last. I had tried just doing `stop` instead of `

          {stop, St}

          ` and that's not correct.

          Your fix works correctly, clean termination of changes feed on db delete and no spam in the logs

          +1

          Show
          rnewson Robert Newson added a comment - ignore that last. I had tried just doing `stop` instead of ` {stop, St} ` and that's not correct. Your fix works correctly, clean termination of changes feed on db delete and no spam in the logs +1

            People

            • Assignee:
              Unassigned
              Reporter:
              vatamane Nick Vatamaniuc
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development